第三方支付

h5
wangdong 4 months ago
parent cc67bbd14f
commit dc51c18fbb
  1. 5
      App.vue
  2. 2
      common/enum/payment/Method.js
  3. 1
      manifest.json
  4. 75
      pages/checkout/cashier/index.vue

@ -26,13 +26,12 @@
},
onShow(options) {
console.log('app onShow', options);
let extraData = options.referrerInfo.extraData;
if (extraData) {
if (options.referrerInfo) {
// wx.showToast({
// title: params.errStr,
// icon: 'none',
// });
uni.$emit('appShow', extraData);
uni.$emit('appShow', options.referrerInfo);
}
},

@ -8,5 +8,5 @@ export default new Enum([
{ key: 'WECHAT', name: '微信支付', value: 'wechat' },
{ key: 'ALIPAY', name: '支付宝支付', value: 'alipay' },
{ key: 'BALANCE', name: '余额支付', value: 'balance' },
{ key: 'HUIFU', name: '支付', value: 'huifu' }
{ key: 'HUIFU', name: '银联支付', value: 'huifu' }
])

@ -123,6 +123,7 @@
"optimization" : {
"subPackages" : true
},
"embeddedAppIdList": ["wx014ad2ef80a147a7"],
"requiredPrivateInfos" : [ "chooseAddress", "getLocation" ]
},
"mp-alipay" : {

@ -19,9 +19,12 @@
<view v-for="(item, index) in methods" :key="index" class="pay-item dis-flex flex-x-between"
@click="handleSelectPayType(index)">
<view class="item-left dis-flex flex-y-center">
<view class="item-left_icon" :class="[item.method]">
<view v-if="item.method!=='huifu'" class="item-left_icon" :class="[item.method]">
<text class="iconfont" :class="[PayMethodIconEnum[item.method]]"></text>
</view>
<view v-else class="huifu-box">
<image :src="`${$picUrl}/static/yinlian.png`" mode="heightFix" class="huifu"></image>
</view>
<view class="item-left_text">
<text>{{ PayMethodEnum[item.method].name }}</text>
</view>
@ -137,15 +140,14 @@
//
this.getCashierInfo();
uni.$on('appShow', this.solveShowMsg);
uni.onAppShow()
},
methods: {
solveShowMsg(msgData) {
console.log(msgData);
if (msgData.errCode === '0000') {
this.onShowSuccess({ message: msgData.errStr });
} else {
this.onPayFail({ message: msgData.errStr });
solveShowMsg(info) {
console.log(info);
if (this.miniPayRequest && Object.keys(this.miniPayRequest).length > 0 && info.appId === this.miniPayRequest.miniuser) {
this.onTradeQuery(this.miniPayRequest.out_trade_no, this.curPaymentItem.method);
}
},
//
@ -194,7 +196,11 @@
// this.$toast('')
// return
// }
this.curPaymentItem = this.methods[index]
this.curPaymentItem = this.methods[index];
console.log(this.curPaymentItem);
if (this.curPaymentItem.method === 'huifu') {
this.createOrder();
}
},
//
@ -238,7 +244,34 @@
//
if (app.disabled) return
app.disabled = true
if (app.curPaymentItem.method === 'huifu') {
if (!app.miniPayRequest || Object.keys(app.miniPayRequest).length === 0) {
app.$toast(`暂无${app.PayMethodEnum[app.curPaymentItem.method].name}支付信息`);
return
}
let appPayRequest = '';
appPayRequest = encodeURIComponent(JSON.stringify({
sign: app.miniPayRequest.sign,
prepayid: app.miniPayRequest.prepayid,
}));
uni.openEmbeddedMiniProgram({
appId: app.miniPayRequest.miniuser,
path: `${app.miniPayRequest.minipath}?appPayRequest=${appPayRequest}`,
success(res) {
console.log('success', res)
},
fail(e) {
console.log('fail', e);
}
});
} else {
// API
this.createOrder();
}
},
createOrder() {
const app = this;
CashierApi.orderPay(app.orderId, {
method: app.curPaymentItem.method,
client: app.platform,
@ -247,16 +280,9 @@
.then(result => {
console.log(result);
if (app.curPaymentItem.method === 'huifu') {
const { miniPayRequest } = result.data.payment;
let appPayRequest = '';
appPayRequest = encodeURIComponent(JSON.stringify({
sign: miniPayRequest.sign,
prepayid: miniPayRequest.prepayid,
}));
uni.navigateToMiniProgram({
appId: miniPayRequest.miniuser,
path: `${miniPayRequest.minipath}?appPayRequest=${appPayRequest}`,
});
const { miniPayRequest, out_trade_no } = result.data.payment;
app.miniPayRequest = miniPayRequest;
app.miniPayRequest.out_trade_no = out_trade_no;
} else {
app.onSubmitCallback(result)
}
@ -422,7 +448,7 @@
.payment-method {
width: 94%;
margin: 0 auto 20rpx auto;
padding: 0 40rpx;
padding: 0 40rpx 0 20rpx;
background-color: #ffffff;
border-radius: 20rpx;
@ -436,7 +462,8 @@
}
.item-left_icon {
margin-right: 20rpx;
width: 100rpx;
text-align: center;
font-size: 44rpx;
&.wechat {
@ -455,6 +482,14 @@
color: #009fe8;
}
}
.huifu-box {
width: 100rpx;
display: flex;
justify-content: center;
.huifu {
height: 44rpx;
}
}
.item-left_text {
font-size: 28rpx;

Loading…
Cancel
Save