【订单支付结果页】

1. 增加后端支付渠道的配置
pull/1/MERGE
YunaiV 2023-07-06 23:16:33 +08:00
parent 6316405712
commit 2afae4f007
4 changed files with 111 additions and 86 deletions

8
api/pay/channel.js Normal file
View File

@ -0,0 +1,8 @@
import request from "@/utils/request.js";
// 获得指定应用的开启的支付渠道编码列表
export function getEnableChannelCodeList(appId) {
return request.get("app-api/pay/channel/get-enable-code-list", {
appId
});
}

View File

@ -38,8 +38,12 @@ export function _toLogin(push, pathLogin) {
} else {
urlData += '?go_longin=1';
}
if (!Cache.has('snsapiKey')) {
auth.oAuth('snsapi_base', urlData);
if (true && !Cache.has('snsapiKey')) {
// TODO 芋艿:先临时禁用掉,改成普通登录页
// auth.oAuth('snsapi_base', urlData);
uni.navigateTo({
url: '/pages/users/login/index'
})
} else {
if (['/pages/user/index'].indexOf(login_back_url) == -1) {
uni.navigateTo({
@ -58,8 +62,9 @@ export function _toLogin(push, pathLogin) {
if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) == -1) {
// #ifdef MP
// TODO 芋艿:先临时禁用掉,改成普通登录页
uni.navigateTo({
url: '/pages/users/wechat_login/index'
url: '/pages/users/login/index'
})
// #endif
}

View File

@ -92,7 +92,7 @@
"h5" : {
"devServer" : {
"https" : false,
"disableHostCheck": true
"disableHostCheck" : true
},
"router" : {
"mode" : "history",

View File

@ -15,8 +15,7 @@
<view class="title">
支付方式
</view>
<view class="item acea-row row-between-wrapper" v-for="(item,index) in cartArr" :key="index"
v-show='item.status' @click="payType(item.channelCode)">
<view class="item acea-row row-between-wrapper" v-for="(item,index) in cartArr" :key="index" @click="payType(item.channelCode)">
<view class="left acea-row row-between-wrapper">
<view class="iconfont" :class="item.icon"></view>
<view class="text">
@ -40,6 +39,7 @@
import CountDown from "@/components/countDown";
import numberScroll from '@/components/numberScroll.vue'
import * as PayOrderApi from '@/api/pay/order.js';
import * as PayChannelApi from '@/api/pay/channel.js';
export default {
components: {
CountDown,
@ -52,31 +52,32 @@
payPrice: 0, //
invalidTime: 0, //
cartArr: [{ //
name: '微信支付',
name: '微信支付', //
icon: "icon-weixin2",
title: '使用微信快捷支付',
status: 1,
channelCode: "wx_pub" // TODO
channelCode: "wx_pub"
}, {
name: '微信支付', //
icon: "icon-weixin2",
title: '使用微信快捷支付',
channelCode: "wx_lite"
}, {
name: '支付宝支付',
icon: "icon-zhifubao",
title: '使用支付宝支付',
status: 1,
channelCode: "alipay_wap"
}, {
name: '余额支付',
icon: "icon-yuezhifu",
title: '可用余额',
status: 1,
},
//
{
name: '支付宝支付PC',
name: '支付宝支付PC', // PC
icon: "icon-zhifubao",
value: 'alipay_pc',
title: '使用支付宝支付',
status: 1,
channelCode: "alipay_pc"
}],
channelCode: '', //
@ -107,6 +108,7 @@
title: '加载订单中'
});
PayOrderApi.getOrder(this.orderId).then(res => {
//
if (res.data.status === 10) {
uni.showToast({
title: '支付成功'
@ -123,24 +125,13 @@
return;
}
console.log(res)
//
this.payPrice = res.data.price
this.invalidTime = res.data.expireTime
// TODO
// this.cartArr[0].status = res.data.wechat_pay_status || 0
this.cartArr[0].status = res.data.wechat_pay_status || 1
// TODO
// this.cartArr[1].status = res.data.ali_pay_status || 0;
this.cartArr[1].status = res.data.ali_pay_status || 1;
//#ifdef MP
this.cartArr[1].status = false;
//#endif
//
// that.cartArr[2].title = ':' + res.data.userInfo.now_money;
this.cartArr[2].number = res.data.now_money;
this.cartArr[2].status = res.data.yue_pay_status
this.channelCode = this.cartArr[0].channelCode;
//
this.removeDisableChannel(res.data.appId);
uni.hideLoading();
}).catch(err => {
uni.hideLoading();
@ -192,59 +183,7 @@
case 'WECHAT_PAY':
that.toPay = true;
// #ifdef MP
let mp_pay_name = ''
if (uni.requestOrderPayment) {
mp_pay_name = 'requestOrderPayment'
} else {
mp_pay_name = 'requestPayment'
}
uni[mp_pay_name]({
timeStamp: jsConfig.timestamp,
nonceStr: jsConfig.nonceStr,
package: jsConfig.package,
signType: jsConfig.signType,
paySign: jsConfig.paySign,
success: function(res) {
uni.hideLoading();
if (that.BargainId || that.combinationId || that.pinkId ||
that
.seckillId || that.discountId)
return that.$util.Tips({
title: that.$t(`支付成功`),
icon: 'success'
}, {
tab: 4,
url: goPages
});
return that.$util.Tips({
title: '支付成功',
icon: 'success'
}, {
tab: 5,
url: goPages
});
},
fail: function(e) {
uni.hideLoading();
return that.$util.Tips({
title: '取消支付'
}, {
tab: 5,
url: goPages + '&status=2'
});
},
complete: function(e) {
uni.hideLoading();
//
if (res.errMsg == 'requestPayment:cancel' || e.errMsg == 'requestOrderPayment:cancel') return that.$util
.Tips({
title: '取消支付'
}, {
tab: 5,
url: goPages + '&status=2'
});
},
})
//
// #endif
// #ifdef H5
//
@ -395,6 +334,10 @@
this.handleSubmitOrderResultForWxPub(displayContent)
return;
}
if (this.channelCode === 'wx_lite') {
this.handleSubmitOrderResultForWxLite(displayContent)
return;
}
}
},
/**
@ -436,7 +379,76 @@
})
})
},
handleSubmitOrderResultForWxLite(displayContent) {
const payConfig = JSON.parse(displayContent);
const that = this;
console.log(payConfig, '=================')
console.log(payConfig.timeStamp, '=================')
uni.requestPayment({
timeStamp: payConfig.timeStamp,
nonceStr: payConfig.nonceStr,
package: payConfig.packageValue,
signType: payConfig.signType,
paySign: payConfig.paySign,
success: function(res) {
uni.hideLoading();
return that.$util.Tips({
title: '支付成功',
icon: 'success'
}, {
tab: 5,
url: goPages
});
},
fail: function(e) {
uni.hideLoading();
return that.$util.Tips({
title: '取消支付'
}, {
tab: 5,
url: goPages + '&status=2'
});
},
complete: function(e) {
uni.hideLoading();
//
if (e.errMsg === 'requestPayment:cancel'
|| e.errMsg === 'requestPayment:fail cancel') {
return that.$util.Tips({
title: '取消支付'
});
}
return that.$util.Tips({
title: e.errMsg,
icon: 'error'
});
},
})
},
/**
* 移除被禁用的支付渠道
*/
removeDisableChannel(appId) {
// 1.1
// #ifndef MP
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_lite')
// #endif
// 1.2
if (!this.$wechat.isWeixin()) {
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_pub')
}
// 2.
PayChannelApi.getEnableChannelCodeList(appId).then(res => {
this.cartArr = this.cartArr.filter(item => res.data.includes(item.channelCode));
//
if (this.cartArr.length > 0) {
this.payType(this.cartArr[0].channelCode)
}
})
},
/**
* 设置支付方式
*/