|
|
|
@ -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; |
|
|
|
|