123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 |
- <template>
- <navBar title="订单支付" :scrollTop="scrollTop" :orderId="state.orderId" navbgClass="nav-bgXin" fontColor='#fff'>
- </navBar>
- <navBgCar :activeNum='5'></navBgCar>
- <view class="content-value">
- <view class="t-card">
- <view @click="savaHandle(item)" class="ul-item" v-for="(item, index) in state.dataArray" :key="index">
- <image style="width: 100%; height: 146rpx;" :src="`${$imgUrl}issuance/equity-bg.png`"
- mode='scaleToFill'>
- </image>
- <view class="item-value">
- <view class="money">
- <text class='unit'>¥</text>
- <text>{{ item.fee * 0.01 }}</text>
- </view>
- <view class="content">
- <view class="title">
- {{ item.payName }}
- </view>
- </view>
- <view class="r-btn">
- {{ item.payStatusName }}
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
-
- <script setup lang="ts">
- import { onLoad, onPageScroll,onShow} from "@dcloudio/uni-app";
- import { reactive, ref } from "vue";
- import {
- PAYMENTORDERAPPLY,
- aliPayConfigIdTwo,
- obtainUserId,
- getOpenId, payApply, payQuery,orderQueryDetail
- } from "@/utils/network/api.js";
- import { request, requestNew } from "@/utils/network/request.js";
- import { stringToJson } from "@/utils/network/encryption";
- import { fileURL } from "@/datas/fileURL.js";
- import navBgCar from "./components/nav-bg-car1";
- import navBar from "@/components/nav-bar/nav-bar2.vue";
- const imgURL = `${fileURL}image/`;
- import { confirm, navTo } from "@/utils/utils";
- import {
- OrderStatus
- } from "@/datas/enum";
- import useOrderSkip from "@/composables/order/useOrderSkip";
- import {
- setItem,getItem
- } from "@/utils/storage";
- const tools = require("../../static/etcUtil/tools.js");
- const { gotoActiveOrder } = useOrderSkip();
- let imageUrl = ""
-
- let logo
- const scrollTop = ref(0); //滚动距离
- var counter = 0;
- const dingwei=(func)=>{
- uni.getLocation({
- type: 'gcj02',
- success: function (res) {
- console.log("经纬福", res)
- state.longitude = res.longitude;
- state.latitude = res.latitude;
- func()
- },
- fail: function (res) {
- console.log("拒绝获取定位失败回调")
- // 拒绝获取定位失败回调
- state.isclick = true
- uni.showModal({
- title: '提示',
- content: '请手动开启定位权限',
- showCancel: false,
- success: () => {
- uni.openSetting({
- success: (settingdata) => {
- if (settingdata.authSetting['scope.userLocation']) {
- console.log('用户重新授权');
- } else {
- console.log('用户仍未授权');
- }
- }
- });
- }
- });
- },
- })
- }
- function myFunc() {
- counter++;
- console.log("====")
- if (counter == 2) {
- clearInterval(intervalId);
- state.isclick = true
- console.log("改为true");
- }
- }
-
- var intervalId = setInterval(myFunc, 2000);
- const savaHandle = (val) => {
- console.log("val", val, state.isclick)
- if (state.isclick) {
- if (val.payStatus == "SUCCESS") {
- return;
- }
- state.isclick = false
- console.log("state.isclick", state.isclick, val.payStatus)
- if(state.xianxia=='1'){
- dingwei(function (res) {
- payMethods(val)
- });
- }else{
- payMethods(val)
- }
- }
- };
- const payMethods=(val)=>{
- console.log("val===",val)
- if (val.payStatus === 'UNPAY') {
- myFunc()
- // #ifdef MP-ALIPAY
- my.getAuthCode({
- scopes: 'auth_base',
- success: res => {
- const optionsUser = {
- type: 2,
- data: {
- payConfigId: aliPayConfigIdTwo,
- code: res.authCode
- },
- method: "POST",
- showLoading: true,
- };
- console.log('支付宝用户编号请求:', optionsUser)
- requestNew(obtainUserId, optionsUser).then((res) => {
- console.log('支付宝用户编号返回:', res)
- const data = res;
- const optionsali = {
- type: 2,
- data: {
- orderId: state.orderId,
- wxOpenid: data.openId ? data.openId : data.alipayUserId,
- payType: val.payType
- },
- method: "POST",
- showLoading: true,
- };
- console.log('支付下单请求:', optionsali)
- requestNew(PAYMENTORDERAPPLY, optionsali).then((res) => {
- const data = res;
- console.log('支付下单返回:', data)
- my.tradePay({
- // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号 trade_no
- tradeNO: data.tranPackage,
- success: res => {
- console.log("支付成功", res);
- refresh();
- },
- fail: res => {
- console.log("支付失败", res);
- },
- });
-
- },
- (err) => {
- state.isclick = true
- console.log("err")
- }
- );
- });
- },
- fail: err => {
- console.log('my.getAuthCode 调用失败', err)
- state.isclick = true
- }
- });
-
- // #endif
- // #ifdef MP-WEIXIN
- const options = {
- type: 2,
- data: {
- orderId: state.orderId,
- wxOpenId: state.openidData.openid,
- payType: val.payType,
- longitude: state.longitude, //经度
- latitude: state.latitude //纬度
- },
- method: "POST",
- showLoading: true,
- };
- requestNew(payApply, options).then((res) => {
- const data = res;
- console.log("data======111", data)
- if (data) {
- console.log("进来了")
- uni.requestPayment({
- provider: "wxpay",
- orderInfo: "",
- timeStamp: data.timestamp,
- nonceStr: data.noncestr,
- package: data.wxPackage ? data.wxPackage : "",
- signType: data.signType,
- paySign: data.sign,
- success: function (e) {
- console.log("支付成功", res);
- state.payOK=true
- refresh();
- },
- fail: function (err) {
- state.isclick = true
- confirm(err, () => { }, "支付失败", false);
- },
- });
- } else {
- state.isclick = true
- console.log("state.isclick", state.isclick)
- }
-
- },
- (err) => {
- state.isclick = true
- console.log("err")
- }
- );
-
-
- // #endif
- }
- }
- const refresh = () => {
- state.isclick = true
- let source = ""
- // #ifdef MP-ALIPAY
- source = "ALI"
- // #endif
- // #ifdef MP-WEIXIN
- source = "WECHAT"
- // #endif
- var data = {
- orderId: state.orderId,
- wxOpenId: state.openidData.openid,
- };
- const options = {
- type: 2,
- data: data,
- method: "POST",
- showLoading: true,
- };
- console.log("输出内容", options);
- requestNew(payQuery, options).then((res) => {
- console.log("res====", res)
- const data = res;
- console.log(data);
- if (data.paymentStatus == 'ALLSUCCESS') {
- gotoEditUserOrUnitInfo()
- }
- state.dataArray = data.datas;
- for (let i = 0; i < state.dataArray.length; i++) {
- if (state.dataArray[i].payType === 'HANDLE') {
- state.dataArray[i].payName = '权益金'
- } else if (state.dataArray[i].payType === 'MARGIN') {
- state.dataArray[i].payName = '保证金'
- } else if (state.dataArray[i].payType === 'PRESTORE') {
- state.dataArray[i].payName = '预存金'
- } else if (state.dataArray[i].payType === 'EQUITY') {
- state.dataArray[i].payName = '权益费'
- } else if (state.dataArray[i].payType === 'REPAIROBU') {
- state.dataArray[i].payName = '增补obu'
- } else if (state.dataArray[i].payType === 'CHANGECARD') {
- state.dataArray[i].payName = '更换卡'
- } else if (state.dataArray[i].payType === 'CHANGEOBU') {
- state.dataArray[i].payName = '更换签'
- } else if (state.dataArray[i].payType === 'CHANGEALL') {
- state.dataArray[i].payName = '更换卡签'
- } else {
- state.dataArray[i].payName = '未知费'
- }
- if (state.dataArray[i].payStatus === 'SUCCESS') {
- state.dataArray[i].payStatusName = '已支付'
- } else if (state.dataArray[i].payStatus === 'PAYING') {
- state.dataArray[i].payStatusName = '支付中'
- } else if (state.dataArray[i].payStatus === 'FAILED') {
- state.dataArray[i].payStatusName = '支付失败'
- } else if (state.dataArray[i].payStatus === 'UNPAY') {
- state.dataArray[i].payStatusName = '未支付'
- } else if (state.dataArray[i].payStatus === 'CLOSED') {
- state.dataArray[i].payStatusName = '已关闭'
- } else if (state.dataArray[i].payStatus === 'CANCELED') {
- state.dataArray[i].payStatusName = '已撤销'
- } else if (state.dataArray[i].payStatus === 'REFUND') {
- state.dataArray[i].payStatusName = '转入退费'
- } else {
- state.dataArray[i].payStatusName = '未知'
- }
- }
- console.log("state.dataArray", state.dataArray)
- });
- }
- onShow(()=>{
- // 支付完跳转到广告页,回来再次查询跳转 (签约完回来也要查询)
- if(state.payOK){
- refreshFirst()
- }
- })
- onLoad((option : any) => {
- console.log("传递过来的到支付页面", option)
- state.orderId = option.orderId;
- state.isValueCard = option.isValueCard;
- state.vehicleId = option.vehicleId;
- state.orderQuery = option.orderQuery;
- state.qdSignUrl = option.qdSignUrl;
- state.qdSignAppId = option.qdSignAppId;
- state.qtSign = option.qtSign;
- state.xianxia = option.xianxia;
- state.cardType = option.cardType;
-
- // #ifdef MP-WEIXIN
- uni.login({
- provider: "weixin",
- success: function (e) {
- const options1 = {
- type: 2,
- data: {
- "jsCode": e.code
- },
- method: "POST",
- showLoading: true,
- };
- requestNew(getOpenId, options1).then((res) => {
- const result = res;
- state.openidData = stringToJson(result.data);
- refreshFirst()
- })
- },
- })
- // #endif
-
- // #ifdef MP-ALIPAY
- refreshFirst()
- // #endif
-
-
-
- });
- // 车辆详情
- const orderDetail = () => {
- const options = {
- type: 2,
- data: {
- orderNo:state.orderId
- },
- method: "POST",
- showLoading: true,
- };
- return new Promise(async (resolve, reject) => {
- const res = await requestNew(orderQueryDetail, options);
- setItem('orderQueryActivate', res)
-
- resolve(res);
- }).catch((error) => {
- reject(error);
- });
- }
- const refreshFirst = () => {
- let source = ""
-
- // #ifdef MP-ALIPAY
- imageUrl = imgURL + "applyCard/alibaba.png";
- source = "ALI"
-
- // #endif
- // #ifdef MP-WEIXIN
- imageUrl = imgURL + "applyCard/wechat.png";
- source = "WECHAT"
- // #endif
- var data = {
- orderId: state.orderId,
- wxOpenId: state.openidData.openid,
- };
- const options = {
- type: 2,
- data: data,
- method: "POST",
- showLoading: true,
- };
- console.log("输出内容", options);
- requestNew(payQuery, options).then((res) => {
- const data = res;
- console.log(data);
- if (data.paymentStatus == 'ALLSUCCESS') {
- // isValueCard 1 储值卡 2 记账卡
- if (state.orderQuery == '1') {
- console.log("state.qtSign",state.qtSign,state.qtSign=='0')
- // 记账卡
- if(state.cardType=='1'){
- // 去诺德签约
- if(state.qtSign=='0'){
- // 去签约,已经签约完,回来查订单详情,如果是激活就去激活
- orderDetail().then((res) => {
- if (res['orderStep'] == OrderStatus['待激活']) {
- // 已签约
- gotoActiveOrder(getItem('orderQueryActivate'))
- }else{
- // 未签约
- if(state.qdSignAppId){
- uni.navigateToMiniProgram({
- appId: state.qdSignAppId,
- path: state.qdSignUrl,
- extraData: {},
- envVersion:'release',
- success(res) {
- state.payOK=true
- console.log(res);
- },
- complete(res) {
- console.log(res);
- },
- fail(res) {
- console.log(res);
- // 未成功跳转到车主小程序
- },
- });
- }else{
- const params = encodeURIComponent(JSON.stringify(state.qdSignUrl))
- tools.toUrl(`/subpackage/personal-center/webview?url=` + params)
- }
- }
- })
-
-
- }else{
- // 签约
- uni.redirectTo({
- url: `/subpackage/orders/release-products?orderId=${state.orderId}&orderQuery=${state.orderQuery}`
- });
- }
- }else{
- gotoActiveOrder(getItem('orderQueryActivate'))
- }
-
- }else{
- if (state.isValueCard == 1) {
- // 不签约
- uni.switchTab({
- url: "/pages/order/order"
- })
- } else {
- // 签约
- uni.redirectTo({
- url: `/subpackage/orders/release-products?orderId=${state.orderId}&orderQuery=${state.orderQuery}`
- });
- }
- }
- }
- state.dataArray = data.datas;
- for (let i = 0; i < state.dataArray.length; i++) {
- if (state.dataArray[i].payType === 'HANDLE') {
- state.dataArray[i].payName = '权益金'
- } else if (state.dataArray[i].payType === 'MARGIN') {
- state.dataArray[i].payName = '保证金'
- } else if (state.dataArray[i].payType === 'PRESTORE') {
- state.dataArray[i].payName = '预存金'
- } else if (state.dataArray[i].payType === 'EQUITY') {
- state.dataArray[i].payName = '权益费'
- } else if (state.dataArray[i].payType === 'REPAIROBU') {
- state.dataArray[i].payName = '增补obu'
- } else if (state.dataArray[i].payType === 'CHANGECARD') {
- state.dataArray[i].payName = '更换卡'
- } else if (state.dataArray[i].payType === 'CHANGEOBU') {
- state.dataArray[i].payName = '更换签'
- } else if (state.dataArray[i].payType === 'CHANGEALL') {
- state.dataArray[i].payName = '更换卡签'
- } else {
- state.dataArray[i].payName = '未知费'
- }
- if (state.dataArray[i].payStatus === 'SUCCESS') {
- state.dataArray[i].payStatusName = '已支付'
- } else if (state.dataArray[i].payStatus === 'PAYING') {
- state.dataArray[i].payStatusName = '支付中'
- } else if (state.dataArray[i].payStatus === 'FAILED') {
- state.dataArray[i].payStatusName = '支付失败'
- } else if (state.dataArray[i].payStatus === 'UNPAY') {
- state.dataArray[i].payStatusName = '未支付'
- } else if (state.dataArray[i].payStatus === 'CLOSED') {
- state.dataArray[i].payStatusName = '已关闭'
- } else if (state.dataArray[i].payStatus === 'CANCELED') {
- state.dataArray[i].payStatusName = '已撤销'
- } else if (state.dataArray[i].payStatus === 'REFUND') {
- state.dataArray[i].payStatusName = '转入退费'
- } else {
- state.dataArray[i].payStatusName = '未知'
- }
- }
- console.log("state.dataArray", state.dataArray)
- });
- }
- //解析URL获取参数
- const getRequest = (urlStr) => {
- if (typeof urlStr == "undefined") {
- // 获取url中"?"符后的字符串
- var url = decodeURI(location.search);
- } else {
- var url = "?" + urlStr.split("?")[1];
- }
- var theRequest = new Object();
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- var strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
- }
- }
- return theRequest;
- };
- //监听页面滚动
- onPageScroll((e) => {
- scrollTop.value = e.scrollTop;
- });
-
- // isValueCard 1 储值卡 2 记账卡
- const gotoEditUserOrUnitInfo = () => {
- if (state.orderQuery == '1') {
- if(state.cardType=='1'){
- if(state.qtSign=='0'){
- if(state.qdSignAppId){
- // 去外边签约
- uni.navigateToMiniProgram({
- appId: state.qdSignAppId,
- path: state.qdSignUrl,
- extraData: {},
- envVersion:'release',
- success(res) {
- state.payOK=true
- console.log(res);
- },
- complete(res) {
- console.log(res);
- },
- fail(res) {
- console.log(res);
- // 未成功跳转到车主小程序
- },
- });
- }else{
- const params = encodeURIComponent(JSON.stringify(state.qdSignUrl))
- tools.toUrl(`/subpackage/personal-center/webview?url=` + params)
- }
- }else{
- // 签约
- uni.redirectTo({
- url:`/subpackage/orders/release-products?orderId=${state.orderId}&orderQuery=${state.orderQuery}`
- });
- }
- }else{
- gotoActiveOrder(getItem('orderQueryActivate'))
- }
-
- }else{
- if (state.isValueCard == 1) {
- // 不签约
- uni.switchTab({
- url: "/pages/order/order"
- })
- } else {
- uni.redirectTo({
- url: `/subpackage/orders/release-products?orderId=${state.orderId}&orderQuery=${state.orderQuery}`
- });
- }
- }
- }
- const state = reactive({
- isValueCard: 1, //卡的类型
- radiolist1: [], //选择卡的数据列表
- choiceCardShow: false, //选择卡的弹出框
- isSign: '',
- id: "",
- orderId: "",
- userType: 1, //1 个人 2单位
- type: 0, //0 客车 1货车
- vehiclePlateColor: "",
- data: {
- show: false,
- src: imgURL + "applyCard/edit.png",
- },
- dataArray: [],
- list: [
- {
- bg: imgURL + "applyCard/product-bg.png",
- icon: imgURL + "applyCard/wechat.png",
- title: "【货车】微信车主服务",
- tip: "绑定微信支付,无需绑定银行卡",
- },
- ],
- openid: "",
- isclick: true,//防止重复点击
- vehicleId: "",
- orderQuery: "0",
- longitude: "",
- latitude: "",
- openidData: {},
- qdSignUrl:"",
- qdSignAppId:"",
- qtSign:"",
- xianxia:"",//线下订单 1
- payOK:false,
- cardType:"",
- });
- </script>
-
- <style lang="scss" scoped>
- ::v-deep .u-radio {
- display: flex !important;
- align-items: center !important;
- float: none !important;
- }
-
- ::v-deep .u-icon__icon {
- top: -4px !important;
- }
-
- .bottomTip {
- margin-top: 100rpx;
- text-align: center;
- font-size: 28rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #b3b3b3;
- }
-
- .content-value {
- position: absolute;
- top: 370rpx;
- width: 100%;
- min-height: calc(100% - 370rpx);
- box-sizing: border-box;
- padding: 0 30rpx 210rpx;
-
- .t-card {
- background-color: #fff;
- padding: 40rpx 30rpx;
- border-radius: 12rpx;
- }
-
- .img-pos {
- position: absolute;
- left: 500rpx;
- top: -38rpx;
- right: 50rpx;
-
- .img-flex {
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- .car-img {
- width: 86rpx;
- height: 42rpx;
- }
-
- .flag-img {
- width: 30rpx;
- height: 35rpx;
- }
- }
- }
- }
-
- .flex {
- display: flex;
- align-items: center;
- }
-
- .action {
- margin-top: 30rpx;
- padding-left: 20rpx;
- padding-right: 20rpx;
- padding-bottom: 30rpx;
-
- .button {
- height: 80rpx;
- background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
- border-radius: 40rpx;
- font-size: 32rpx;
- font-weight: 400;
- color: #ffffff;
- line-height: 80rpx;
- }
- }
-
- .action-btn {
- margin-left: 45rpx;
- width: 121rpx;
- height: 61rpx;
- border: 1px solid rgba(255, 255, 255, 1);
- border-radius: 30rpx;
- background: rgba(255, 255, 255, 0.2);
-
- text-align: center;
- font-size: 30rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- line-height: 61rpx;
- }
-
- .tag1 {
- padding: 5rpx;
- background: rgba(0, 179, 139, 0.5);
- border-radius: 6rpx;
- font-size: 22rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- }
-
- .tag3 {
- padding: 5rpx;
- background: rgba(139, 112, 228, 0.5);
- border-radius: 6rpx;
- font-size: 22rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- }
-
- .tag2 {
- padding: 5rpx;
- background: rgba(249, 97, 60, 0.5);
- border-radius: 6rpx;
- font-size: 22rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- }
-
- .ul-item {
- display: flex;
- align-items: center;
-
- &:nth-child(n+2) {
- margin-top: 30rpx;
- }
-
- .item-value {
- padding: 20rpx;
- position: absolute;
- display: flex;
- align-items: center;
- width: 81%;
- box-sizing: border-box;
- height: 146rpx;
-
- .money {
- color: #fff;
- font-size: 46rpx;
- font-family: SourceHanSansCN, SourceHanSansCN;
- font-weight: 400;
- flex: 1;
-
- .unit {
- font-size: 29rpx;
- margin-right: 2rpx;
- }
- }
-
- .content {
- margin-left: 60rpx;
- flex: 2;
-
- .title {
- font-weight: 400;
- font-family: SourceHanSansCN, SourceHanSansCN;
- font-size: 36rpx;
- color: #2C3246;
- }
- }
-
- .r-btn {
- width: 139rpx;
- height: 65rpx;
- background: radial-gradient(at 0% 0%, #C6B077 0%, #DFCC96 100%);
- border-radius: 33rpx;
- font-family: SourceHanSansCN, SourceHanSansCN;
- font-weight: 400;
- font-size: 26rpx;
- color: #FFFFFF;
- line-height: 65rpx;
- text-align: center;
- flex: 1;
- }
- }
-
- .icon-tip {
- width: 100rpx;
- height: 100rpx;
- }
- }
-
- ::v-deep .u-mode-center-box {
- border-radius: 10rpx;
- }
-
- .squire {
- padding: 30rpx 30rpx 50rpx 50rpx;
- }
-
- .mask-close {
- text-align: right;
- }
-
- .icon-closed {
- width: 48rpx;
- height: 48rpx;
- }
-
- .mask-title {
- text-align: center;
- font-size: 32rpx;
- color: $uni-text-color-black;
- margin-bottom: 50rpx;
- }
- </style>
|