跳转第三方支付

h5
wangdong 6 months ago
parent 74e34fc94a
commit cc67bbd14f
  1. 11
      App.vue
  2. 56
      pages/checkout/cashier/index.vue

@ -24,6 +24,17 @@
// //
this.getStoreInfo() this.getStoreInfo()
}, },
onShow(options) {
console.log('app onShow', options);
let extraData = options.referrerInfo.extraData;
if (extraData) {
// wx.showToast({
// title: params.errStr,
// icon: 'none',
// });
uni.$emit('appShow', extraData);
}
},
methods: { methods: {

@ -135,11 +135,19 @@
// ID // ID
this.orderId = Number(orderId) this.orderId = Number(orderId)
// //
this.getCashierInfo() this.getCashierInfo();
uni.$on('appShow', this.solveShowMsg);
}, },
methods: { methods: {
solveShowMsg(msgData) {
console.log(msgData);
if (msgData.errCode === '0000') {
this.onShowSuccess({ message: msgData.errStr });
} else {
this.onPayFail({ message: msgData.errStr });
}
},
// //
getCashierInfo() { getCashierInfo() {
const app = this const app = this
@ -230,36 +238,30 @@
// //
if (app.disabled) return if (app.disabled) return
app.disabled = true app.disabled = true
if (app.curPaymentItem.method !== 'huifu') {
// API // API
CashierApi.orderPay(app.orderId, { CashierApi.orderPay(app.orderId, {
method: app.curPaymentItem.method, method: app.curPaymentItem.method,
client: app.platform, client: app.platform,
extra: app.getExtraAsUnify(app.curPaymentItem.method) extra: app.getExtraAsUnify(app.curPaymentItem.method)
})
.then(result => app.onSubmitCallback(result))
.finally(err => setTimeout(() => app.disabled = false, 10))
} else {
console.log(app.curPaymentItem.method);
CashierApi.unify({
outTradeNo: new Date().getTime(),
totalFee: 1,
}) })
.then(result => { .then(result => {
const { miniPayRequest } = result.data.data; console.log(result);
let appPayRequest = ''; if (app.curPaymentItem.method === 'huifu') {
appPayRequest = encodeURIComponent(JSON.stringify({ const { miniPayRequest } = result.data.payment;
sign: miniPayRequest.sign, let appPayRequest = '';
prepayid: miniPayRequest.prepayid, appPayRequest = encodeURIComponent(JSON.stringify({
})); sign: miniPayRequest.sign,
console.log(appPayRequest); prepayid: miniPayRequest.prepayid,
uni.navigateToMiniProgram({ }));
appId: miniPayRequest.miniuser, uni.navigateToMiniProgram({
path: `${miniPayRequest.minipath}?appPayRequest=${appPayRequest}`, appId: miniPayRequest.miniuser,
}); path: `${miniPayRequest.minipath}?appPayRequest=${appPayRequest}`,
});
} else {
app.onSubmitCallback(result)
}
}) })
.finally(err => setTimeout(() => app.disabled = false, 10)) .finally(err => setTimeout(() => app.disabled = false, 10))
}
}, },
// //

Loading…
Cancel
Save