choosePay: {
type: [{
name: '微信支付',
pic: "/zhy/resource/images/pay/wx.png",
id: 1,
hide: 0,
},
{
name: '余额支付',
pic: "/zhy/resource/images/pay/local.png",
id: 2,
hide: 0,
}
],
curr: 1,
alert: false
},
onLoad加代码
this.setIntegralSetting(() => {
})
toPayReserveOrder() {
this.toggleAlertPay();
},
changePayType(e) {
let idx = e.currentTarget.dataset.index;
//console.log(fee)
if (idx == 2 && this.data.user.balance - this.data.info.order_amount < 0) {
app.tips('余额不足!');
return;
} else {
this.setData({
['choosePay.curr']: idx
})
}
},
toggleAlertPay() {
this.setData({
['choosePay.alert']: !this.data.choosePay.alert
})
},
onBuyMoneyTab() {
var _this = this;
var pay_type = _this.data.choosePay.curr;
const param = {
user_id: this.data.user.id,
store_id: this.data.store_id,
name: this.data.name,
phone: this.data.phone,
pay_type: pay_type,
time_id: this.data.time_id,
desktype_id: this.data.desktype_id,
ping_order_type: this.data.ping_order_type,
ping_order_no: this.data.ping_order_no,
}
app.api.apiOfflinepingreserveorderSetorder(param).then((res) => {
var pay_type = _this.data.choosePay.curr;
this.setData({
order_id: res.data.order_id
});
if (pay_type == 2) {
_this.setData({
['choosePay.alert']: false
})
_this.setData({
ajax: false,
})
app.reTo("/plugin/offlineping/orderinfo/orderinfo?order_id=" + this.data.order_id);
} else {
this.wxpayAjax(res.data);
}
}).catch((res) => {
app.tips(res);
});
},
wxpayAjax(payStamp) {
let data = payStamp;
let _this = this;
wx.requestPayment({
appId: data.appId,
nonceStr: data.nonceStr,
package: data.package,
paySign: data.paySign,
prepay_id: data.prepay_id,
signType: data.signType,
timeStamp: data.timeStamp,
success: function (res) {
_this.setData({
['choosePay.alert']: false
})
_this.setData({
ajax: false,
})
app.timePass(100).then(() => {
app.reTo("/plugin/offlineping/orderinfo/orderinfo?order_id=" + _this.data.order_id);
})
},
fail: () => {
}
})
},
<van-popup-gray show="{{choosePay.alert}}" position="bottom" bind:click-overlay="toggleAlertPay">
<view class='choicepayTit'>请选择支付方式</view>
<view class='webChat' wx:for="{{choosePay.type}}" wx:key="choose" bindtap='changePayType' data-index="{{item.id}}" wx:if="{{!item.hide}}">
<image src='{{item.pic}}' class='payIcon'></image>
<view>{{item.id == 2 ? integraSetting.recharge.name+'支付' : item.name}}</view>
<view>{{item.id == 2? integraSetting.recharge.name+':' + user.balance : ''}}</view>
<image src='/zhy/resource/images/pay/right.png' class='iconRight' wx:if="{{choosePay.curr == item.id}}"></image>
</view>
<view class="pay-footer">
<button bindtap="onBuyMoneyTab">确定支付</button>
</view>
<!-- <view style="height: 100rpx;"></view> -->
</van-popup-gray>
"usingComponents": {
"van-popup-gray": "/zhy/vant/popup-gray/index"
}