完善订单页面
This commit is contained in:
@ -54,10 +54,10 @@
|
||||
<!-- 使用余额支付优惠的折扣 -->
|
||||
<view style="margin-top: 52rpx;" v-if="bill.dis">
|
||||
<view class="title1 d-b-c">
|
||||
<view style="color: #4C9F44;">优惠</view>
|
||||
<view>折扣优惠</view>
|
||||
<view>
|
||||
<text style="margin-right: 6rpx;"> - </text>
|
||||
<price-format color="#303133" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dis"></price-format>
|
||||
<text style="margin-right: 6rpx;color: #FA2B21;"> - </text>
|
||||
<price-format color="#FA2B21" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dis"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -75,8 +75,9 @@
|
||||
<view class="price2 bg-white" style="margin: 0; padding: 56rpx 22rpx 42rpx;">
|
||||
<view class="d-b-c price-block" style="margin: 0;">
|
||||
<view class="d-f d-c j-c-b">
|
||||
<view class="">
|
||||
<view>
|
||||
合计: <price-format color="#FF5951" :subscript-size="26" :first-size="40" :second-size="40" :price="bill.total"></price-format>
|
||||
<text style="margin-left: 10rpx;color: #FA2B21;font-size: 26rpx;">8折</text>
|
||||
</view>
|
||||
<view class="d-f j-c-c a-i-c" style="margin-top: 10rpx;" @click="closeBillPopup">
|
||||
<view class="price-detail">费用明细</view>
|
||||
@ -171,7 +172,7 @@
|
||||
<view :class="payType == 'wxpay' ? 'item active' : 'item'" @tap="payTypeFunc('wxpay')" style="padding-bottom: 10rpx;">
|
||||
<view class="d-s-c">
|
||||
<view class="icon-box d-c-c mr10"><span class="icon iconfont icon-weixin"></span></view>
|
||||
<text class="key">微信支付:</text>
|
||||
<text class="key">微信支付</text>
|
||||
</view>
|
||||
<view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
|
||||
</view>
|
||||
@ -244,6 +245,9 @@
|
||||
payType: 'wxpay', // 支付方式 wxpay\balance
|
||||
balance: 0,
|
||||
order: {},
|
||||
result: '',
|
||||
loadding: true,
|
||||
_submitting: false
|
||||
};
|
||||
},
|
||||
|
||||
@ -257,6 +261,17 @@
|
||||
this.getData();
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
switch(this.result) {
|
||||
case 'success':
|
||||
uni.$emit('payment', { result: true, order_id: this.orderId })
|
||||
break;
|
||||
case 'fail':
|
||||
default: uni.$emit('payment', { result: false, order_id: this.orderId })
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
getData() {
|
||||
let self = this;
|
||||
@ -264,12 +279,12 @@
|
||||
title: '加载中'
|
||||
});
|
||||
|
||||
const reserveDate = uni.getStorageSync('reserveDate') || null
|
||||
self.date = reserveDate
|
||||
self.countSelectedTime = reserveDate && reserveDate.duration ? reserveDate.duration : 0
|
||||
if (self.typeId == 2) {
|
||||
self.countSelectedTime = 4
|
||||
}
|
||||
// const reserveDate = uni.getStorageSync('reserveDate') || null
|
||||
// self.date = reserveDate
|
||||
// self.countSelectedTime = reserveDate && reserveDate.duration ? reserveDate.duration : 0
|
||||
// if (self.typeId == 2) {
|
||||
// self.countSelectedTime = 4
|
||||
// }
|
||||
|
||||
// 获取余额
|
||||
self._post(
|
||||
@ -372,7 +387,6 @@
|
||||
total: result.light_all_price
|
||||
}
|
||||
}
|
||||
console.log("🚀 ~ self.bill:", self.bill)
|
||||
|
||||
self.loadding = false;
|
||||
}
|
||||
@ -401,58 +415,158 @@
|
||||
|
||||
// 去支付
|
||||
toConfirm() {
|
||||
if (this._submitting) return;
|
||||
this._submitting = true;
|
||||
if (this.countSelectedTime === 0) {
|
||||
uni.showToast({title: '请选择时间后再预定', icon: 'none'});
|
||||
this._submitting = false;
|
||||
return;
|
||||
}
|
||||
const finish = () => { this._submitting = false; };
|
||||
if (this.payType == 'wxpay') {
|
||||
// 包装原有回调,确保无论成功失败都解锁
|
||||
const oldWxPay = this.wxPay;
|
||||
this.wxPay = (...args) => {
|
||||
oldWxPay.apply(this, args);
|
||||
this.wxPay = oldWxPay;
|
||||
};
|
||||
oldWxPay.call(this);
|
||||
setTimeout(finish, 3000); // 兜底3秒自动解锁
|
||||
} else if (this.payType == 'balance') {
|
||||
const oldBalancePay = this.balancePay;
|
||||
this.balancePay = (...args) => {
|
||||
oldBalancePay.apply(this, args);
|
||||
this.balancePay = oldBalancePay;
|
||||
};
|
||||
oldBalancePay.call(this);
|
||||
setTimeout(finish, 3000);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
},
|
||||
|
||||
// 微信支付
|
||||
wxPay() {
|
||||
let self = this;
|
||||
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
self._post(
|
||||
'order.groundOrder/submitStoreOrder',
|
||||
{
|
||||
app_id: self.getAppId(),
|
||||
ground_id: self.venueId,
|
||||
room_id: self.roomId,
|
||||
hours: 1,
|
||||
day_time: self.date ? self.date.date : '',
|
||||
start_time: self.date ? self.date.startTime : '',
|
||||
end_time: self.date ? self.date.endTime : '',
|
||||
},
|
||||
function(res) {
|
||||
console.log("🚀 ~ order res:", res)
|
||||
self._post(
|
||||
'user.groundOrder/pay',
|
||||
{
|
||||
app_id: self.getAppId(),
|
||||
order_id: res.data.lists.id
|
||||
},
|
||||
function(res) {
|
||||
const data = res.data
|
||||
console.log("🚀 ~ pay data:", data)
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: data.payment.timeStamp,
|
||||
nonceStr: data.payment.nonceStr,
|
||||
package: 'prepay_id=' + data.payment.prepay_id,
|
||||
signType: 'MD5',
|
||||
paySign: data.payment.paySign,
|
||||
success: res => {
|
||||
console.log("🚀 ~ pay success res:", res)
|
||||
},
|
||||
fail: res => {
|
||||
console.log("🚀 ~ pay fail res:", res)
|
||||
uni.reLaunch({
|
||||
url: '/pages/order/cg-my-order',
|
||||
});
|
||||
},
|
||||
|
||||
try {
|
||||
self._post(
|
||||
'user.groundOrder/pay',
|
||||
{
|
||||
app_id: self.getAppId(),
|
||||
order_id: this.orderId
|
||||
},
|
||||
function(res) {
|
||||
const data = res.data
|
||||
console.log("🚀 ~ pay data:", data)
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: data.payment.timeStamp,
|
||||
nonceStr: data.payment.nonceStr,
|
||||
package: 'prepay_id=' + data.payment.prepay_id,
|
||||
signType: 'MD5',
|
||||
paySign: data.payment.paySign,
|
||||
success: res => {
|
||||
self.result = 'success'
|
||||
console.log("🚀 ~ pay success res:", res)
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'none'
|
||||
});
|
||||
self.loadding = false;
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
},
|
||||
fail: res => {
|
||||
console.log("🚀 ~ pay error res:", res)
|
||||
self.result = 'fail'
|
||||
self.loadding = false;
|
||||
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
},
|
||||
});
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
console.log("🚀 ~ pay error res:", res)
|
||||
self.result = 'fail'
|
||||
self.loadding = false;
|
||||
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
|
||||
// 余额支付
|
||||
balancePay() {
|
||||
let self = this;
|
||||
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
|
||||
try {
|
||||
self._post(
|
||||
'ground.ground/yuePay',
|
||||
{
|
||||
app_id: self.getAppId(),
|
||||
order_id: this.orderId
|
||||
},
|
||||
function(res) {
|
||||
if (res.code == 1) {
|
||||
self.result = 'success'
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'none'
|
||||
});
|
||||
self.loadding = false;
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
} else {
|
||||
self.result = 'fail'
|
||||
self.loadding = false;
|
||||
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
}
|
||||
)
|
||||
self.loadding = false;
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
self.result = 'fail'
|
||||
self.loadding = false;
|
||||
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user