wangfukang 4 weeks ago
parent
commit
8cdb441936
  1. 147
      package1/buyFood/buyFood.vue

147
package1/buyFood/buyFood.vue

@ -230,7 +230,7 @@
支付剩余时间 59:09 支付剩余时间 59:09
</view> </view>
<view style="height: 45px;line-height: 45px;text-align: center;font-weight: 700;font-size: 15px;"> <view style="height: 45px;line-height: 45px;text-align: center;font-weight: 700;font-size: 15px;">
<text style="font-size: 30px;">449.96</text> <text style="font-size: 30px;">{{totalAmountCalc.toFixed(2)}}</text>
</view> </view>
<view style="height: 20px;text-align: center;color: red;"> <view style="height: 20px;text-align: center;color: red;">
若拼团失败将会为您自动退款 若拼团失败将会为您自动退款
@ -362,10 +362,14 @@
onShow() { onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.initAddress() this.initAddress()
const now = new Date(); const now = new Date();
now.setMinutes(now.getMinutes() + 30); const startTime = new Date(now);
this.immediateTimeStr = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`; const endTime = new Date(now);
startTime.setMinutes(startTime.getMinutes() + 20);
endTime.setMinutes(endTime.getMinutes() + 35);
const startStr = `${startTime.getHours().toString().padStart(2, '0')}:${startTime.getMinutes().toString().padStart(2, '0')}`;
const endStr = `${endTime.getHours().toString().padStart(2, '0')}:${endTime.getMinutes().toString().padStart(2, '0')}`;
this.immediateTimeStr = `${startStr}-${endStr}`;
// Listen for selected delivery person event // Listen for selected delivery person event
uni.$on('updateDeliveryWorker', (worker) => { uni.$on('updateDeliveryWorker', (worker) => {
@ -411,7 +415,6 @@
return arr.join(','); return arr.join(',');
}, },
submitPay(){ submitPay(){
this.$refs.payPopup.open('bottom');
if(this.isPaotui && !this.formData.address) { if(this.isPaotui && !this.formData.address) {
this.warnPopup = 'shdz'; this.warnPopup = 'shdz';
this.$refs.warnPopup.open(); this.$refs.warnPopup.open();
@ -433,6 +436,79 @@
return; return;
} }
// Validation successful, open the payment popup
this.$refs.payPopup.open('bottom');
},
goDetail(){
// Pass match conditions to worker list
let shopArea = this.shopItem.shopArea || '';
let putArea = this.formData.address ? this.formData.address.areaId : '';
uni.navigateTo({
url:`/package1/index/deliveryPersonList?shopAreaId=${shopArea}&putAreaId=${putArea}`
})
},
openAddressBook(){
this.$refs.bookPopup.open('bottom')
},
checkTime(type){
if (type === this.formData.isImmediately) {
if (type === false) {
this.$refs.model.open()
this.generateDeliveryTimes()
}
return;
}
this.formData.isImmediately = type;
if (this.formData.isImmediately === false) {
this.$refs.model.open()
this.generateDeliveryTimes()
}
},
checkVoucher(type) {
if (type == this.selected) return;
this.selected = type;
if(this.selected == 'buzhiding'){
this.formData.peisongyuan = "";
this.assignedWorker = null;
}
},
//
wxPayment() {
let that = this;
let amountInCents = Math.round(this.totalAmountCalc * 100);
let payDesc = this.isGroupBuy ? '拼团订单' : '商城订单';
this.tui.request("/api/wechat/pay/unified-order", "POST", {
openid: uni.getStorageSync('miniProgramOpenid'),
amount: amountInCents, //
description: payDesc,
outTradeNo: 'ORDER_' + Date.now()
}, false, false).then((res) => {
if (res.code == 200) {
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.timeStamp,
nonceStr: res.nonceStr,
package: res.package,
signType: res.signType,
paySign: res.paySign,
success: function(res2) {
console.log('success:' + JSON.stringify(res2));
that.$refs.payPopup.close();
that.submitOrderToBackend();
},
fail: function(err) {
console.log('fail:' + JSON.stringify(err));
that.tui.toast("支付失败或取消");
}
});
} else {
this.tui.toast(res.message)
}
})
},
submitOrderToBackend() {
let items = []; let items = [];
if(this.isGroupBuy && this.groupItem) { if(this.isGroupBuy && this.groupItem) {
items.push({ items.push({
@ -485,7 +561,7 @@
} }
uni.showLoading({ title: '提交中' }); uni.showLoading({ title: '提交中' });
this.tui.request("/hiver/order/submitMallOrder", "POST", payload, false, false).then(res => { this.tui.request("/order/submitMallOrder", "POST", payload, false, false).then(res => {
uni.hideLoading(); uni.hideLoading();
if(res.code == 200) { if(res.code == 200) {
let orderId = res.result; let orderId = res.result;
@ -501,65 +577,6 @@
} }
}); });
}, },
goDetail(){
// Pass match conditions to worker list
let shopArea = this.shopItem.shopArea || '';
let putArea = this.formData.address ? this.formData.address.areaId : '';
uni.navigateTo({
url:`/package1/index/deliveryPersonList?shopAreaId=${shopArea}&putAreaId=${putArea}`
})
},
openAddressBook(){
this.$refs.bookPopup.open('bottom')
},
checkTime(type){
if(type == this.formData.isImmediately){
}
this.formData.isImmediately = !this.formData.isImmediately
if(this.formData.isImmediately == false){
this.$refs.model.open()
this.generateDeliveryTimes()
}
},
checkVoucher(type) {
if (type == this.selected) return;
this.selected = type;
if(this.selected == 'buzhiding'){
this.formData.peisongyuan = "";
this.assignedWorker = null;
}
},
//
wxPayment() {
let that = this;
this.tui.request("/api/wechat/pay/unified-order", "POST", {
openid: uni.getStorageSync('miniProgramOpenid'),
amount: 1, //
description: '拼团订单',
outTradeNo: 'ORDER_' + Date.now()
}, false, false).then((res) => {
if (res.code == 200) {
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.timeStamp,
nonceStr: res.nonceStr,
package: res.package,
signType: res.signType,
paySign: res.paySign,
success: function(res2) {
console.log('success:' + JSON.stringify(res2));
},
fail: function(err) {
console.log('fail:' + JSON.stringify(err));
}
});
} else {
this.tui.toast(res.message)
}
})
},
// //
generateDeliveryTimes() { generateDeliveryTimes() {
const now = new Date(); const now = new Date();

Loading…
Cancel
Save