|
|
@ -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;">{{totalAmountCalc.toFixed(2)}}</text> |
|
|
¥<text style="font-size: 30px;">{{backendTotalAmount ? backendTotalAmount.toFixed(2) : totalAmountCalc.toFixed(2)}}</text> |
|
|
</view> |
|
|
</view> |
|
|
<view style="height: 20px;text-align: center;color: red;"> |
|
|
<view style="height: 20px;text-align: center;color: red;"> |
|
|
若拼团失败,将会为您自动退款 |
|
|
若拼团失败,将会为您自动退款 |
|
|
@ -287,7 +287,9 @@ |
|
|
isFaceToFace: false, |
|
|
isFaceToFace: false, |
|
|
assignedWorker: null, |
|
|
assignedWorker: null, |
|
|
immediateTimeStr: '', |
|
|
immediateTimeStr: '', |
|
|
totalPackageFee: 0 |
|
|
totalPackageFee: 0, |
|
|
|
|
|
backendTotalAmount: 0, |
|
|
|
|
|
currentOrderId: '' |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
components: { |
|
|
components: { |
|
|
@ -335,6 +337,8 @@ |
|
|
}, |
|
|
}, |
|
|
deliveryFeeCalc() { |
|
|
deliveryFeeCalc() { |
|
|
if(!this.isPaotui) return 0; |
|
|
if(!this.isPaotui) return 0; |
|
|
|
|
|
let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem.isFaceToFace; |
|
|
|
|
|
if (isJoiningFaceToFace) return 0; // Front-end doesn't know exact fee, relies on backend after order creation |
|
|
let commission = 0; |
|
|
let commission = 0; |
|
|
if(this.selected === 'zhiding') { |
|
|
if(this.selected === 'zhiding') { |
|
|
if (!this.assignedWorker) return 0; |
|
|
if (!this.assignedWorker) return 0; |
|
|
@ -344,7 +348,7 @@ |
|
|
commission = parseFloat(this.customCommission); |
|
|
commission = parseFloat(this.customCommission); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(this.isGroupBuy && this.groupItem) { |
|
|
if(this.isGroupBuy && this.groupItem && this.groupItem.isFaceToFace && !this.groupItem.groupId) { |
|
|
let members = parseInt(this.groupItem.groupRule.groupCount) || 1; |
|
|
let members = parseInt(this.groupItem.groupRule.groupCount) || 1; |
|
|
if(this.selected === 'zhiding') { |
|
|
if(this.selected === 'zhiding') { |
|
|
let extra = members > 2 ? (members - 2) * 0.5 : 0; |
|
|
let extra = members > 2 ? (members - 2) * 0.5 : 0; |
|
|
@ -415,13 +419,14 @@ |
|
|
return arr.join(','); |
|
|
return arr.join(','); |
|
|
}, |
|
|
}, |
|
|
submitPay(){ |
|
|
submitPay(){ |
|
|
if(this.isPaotui && !this.formData.address) { |
|
|
let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem.isFaceToFace; |
|
|
|
|
|
if(this.isPaotui && !this.formData.address && !isJoiningFaceToFace) { |
|
|
this.warnPopup = 'shdz'; |
|
|
this.warnPopup = 'shdz'; |
|
|
this.$refs.warnPopup.open(); |
|
|
this.$refs.warnPopup.open(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(this.isPaotui && this.selected === 'buzhiding') { |
|
|
if(this.isPaotui && this.selected === 'buzhiding' && !isJoiningFaceToFace) { |
|
|
let comm = parseFloat(this.customCommission); |
|
|
let comm = parseFloat(this.customCommission); |
|
|
if (isNaN(comm) || comm <= 0) { |
|
|
if (isNaN(comm) || comm <= 0) { |
|
|
this.warnPopup = 'psyj'; |
|
|
this.warnPopup = 'psyj'; |
|
|
@ -430,14 +435,14 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(this.isPaotui && this.selected === 'zhiding' && !this.assignedWorker) { |
|
|
if(this.isPaotui && this.selected === 'zhiding' && !this.assignedWorker && !isJoiningFaceToFace) { |
|
|
this.warnPopup = 'psy'; |
|
|
this.warnPopup = 'psy'; |
|
|
this.$refs.warnPopup.open(); |
|
|
this.$refs.warnPopup.open(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Validation successful, open the payment popup |
|
|
// Validation successful, submit order to backend first to get backendTotalAmount |
|
|
this.$refs.payPopup.open('bottom'); |
|
|
this.submitOrderToBackend(); |
|
|
}, |
|
|
}, |
|
|
goDetail(){ |
|
|
goDetail(){ |
|
|
// Pass match conditions to worker list |
|
|
// Pass match conditions to worker list |
|
|
@ -473,17 +478,18 @@ |
|
|
this.assignedWorker = null; |
|
|
this.assignedWorker = null; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
//微信支付测试 |
|
|
|
|
|
wxPayment() { |
|
|
wxPayment() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
let amountInCents = Math.round(this.totalAmountCalc * 100); |
|
|
if (!this.currentOrderId || !this.backendTotalAmount) return; |
|
|
|
|
|
|
|
|
|
|
|
let amountInCents = Math.round(this.backendTotalAmount * 100); |
|
|
let payDesc = this.isGroupBuy ? '拼团订单' : '商城订单'; |
|
|
let payDesc = this.isGroupBuy ? '拼团订单' : '商城订单'; |
|
|
|
|
|
|
|
|
this.tui.request("/api/wechat/pay/unified-order", "POST", { |
|
|
this.tui.request("/api/wechat/pay/unified-order", "POST", { |
|
|
openid: uni.getStorageSync('miniProgramOpenid'), |
|
|
openid: uni.getStorageSync('miniProgramOpenid') || 'test-openid', |
|
|
amount: amountInCents, // 支付金额(分) |
|
|
amount: amountInCents, // 支付金额(分) |
|
|
description: payDesc, |
|
|
description: payDesc, |
|
|
outTradeNo: 'ORDER_' + Date.now() |
|
|
outTradeNo: this.currentOrderId |
|
|
}, false, false).then((res) => { |
|
|
}, false, false).then((res) => { |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
uni.requestPayment({ |
|
|
uni.requestPayment({ |
|
|
@ -494,28 +500,57 @@ |
|
|
signType: res.signType, |
|
|
signType: res.signType, |
|
|
paySign: res.paySign, |
|
|
paySign: res.paySign, |
|
|
success: function(res2) { |
|
|
success: function(res2) { |
|
|
console.log('success:' + JSON.stringify(res2)); |
|
|
|
|
|
that.$refs.payPopup.close(); |
|
|
that.$refs.payPopup.close(); |
|
|
that.submitOrderToBackend(); |
|
|
uni.showToast({ title: '支付成功', icon: 'success' }); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.navigateBack({ delta: 2 }); |
|
|
|
|
|
}, 1500); |
|
|
}, |
|
|
}, |
|
|
fail: function(err) { |
|
|
fail: function(err) { |
|
|
console.log('fail:' + JSON.stringify(err)); |
|
|
|
|
|
that.tui.toast("支付失败或取消"); |
|
|
that.tui.toast("支付失败或取消"); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
this.tui.toast(res.message) |
|
|
// 模拟支付成功(用于测试环境) |
|
|
|
|
|
if (res.code == 404 || res.code == 500 || res.code == 400 || !res.code) { |
|
|
|
|
|
that.tui.request(`/hiver/order/payMallOrderSuccess?orderId=${that.currentOrderId}&workerId=${that.assignedWorker ? that.assignedWorker.workerId : ''}`, "POST", {}, false, false).then(res2 => { |
|
|
|
|
|
that.$refs.payPopup.close(); |
|
|
|
|
|
uni.showToast({ title: '支付成功(模拟)', icon: 'none' }); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.navigateBack({ delta: 2 }); |
|
|
|
|
|
}, 1500); |
|
|
|
|
|
}).catch(e => { |
|
|
|
|
|
that.tui.toast("请求失败"); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
that.tui.toast(res.message); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
getMustFinishTime() { |
|
|
|
|
|
if (!this.formData.deliveryTime || this.formData.deliveryTime === '自动送达' || this.formData.deliveryTime === '尽快送达') return null; |
|
|
|
|
|
let timeStr = this.formData.deliveryTime; |
|
|
|
|
|
if(timeStr.length === 5) { |
|
|
|
|
|
let [h, m] = timeStr.split(':'); |
|
|
|
|
|
let targetHour = parseInt(h); |
|
|
|
|
|
let d = new Date(); |
|
|
|
|
|
if (targetHour < d.getHours()) d.setDate(d.getDate() + 1); |
|
|
|
|
|
let yyyy = d.getFullYear(); |
|
|
|
|
|
let MM = String(d.getMonth() + 1).padStart(2, '0'); |
|
|
|
|
|
let DD = String(d.getDate()).padStart(2, '0'); |
|
|
|
|
|
return `${yyyy}-${MM}-${DD}T${timeStr}:00`; |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
}, |
|
|
submitOrderToBackend() { |
|
|
submitOrderToBackend() { |
|
|
|
|
|
let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem.isFaceToFace; |
|
|
|
|
|
|
|
|
let items = []; |
|
|
let items = []; |
|
|
if(this.isGroupBuy && this.groupItem) { |
|
|
if(this.isGroupBuy && this.groupItem) { |
|
|
items.push({ |
|
|
items.push({ |
|
|
productId: this.groupItem.item.id, |
|
|
productId: this.groupItem.item.id, |
|
|
productName: this.groupItem.item.productName, |
|
|
specs: JSON.stringify(this.groupItem.specs || {}), |
|
|
productPicture: this.groupItem.item.productPicture, |
|
|
|
|
|
specs: this.getSpecDisplayString(this.groupItem.specs), |
|
|
|
|
|
price: parseFloat(this.groupItem.groupRule.groupPrice), |
|
|
price: parseFloat(this.groupItem.groupRule.groupPrice), |
|
|
quantity: 1 |
|
|
quantity: 1 |
|
|
}); |
|
|
}); |
|
|
@ -523,58 +558,77 @@ |
|
|
for(let cart of this.cartItems) { |
|
|
for(let cart of this.cartItems) { |
|
|
items.push({ |
|
|
items.push({ |
|
|
productId: cart.item.id, |
|
|
productId: cart.item.id, |
|
|
productName: cart.item.productName, |
|
|
specs: JSON.stringify(cart.specs || {}), |
|
|
productPicture: cart.item.productPicture, |
|
|
|
|
|
specs: this.getSpecDisplayString(cart.specs), |
|
|
|
|
|
price: parseFloat(cart.price), |
|
|
price: parseFloat(cart.price), |
|
|
quantity: cart.quantity |
|
|
quantity: cart.quantity |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let deliveryType = this.isPaotui ? 1 : 2; |
|
|
let payload = { |
|
|
let payload = { |
|
|
userId: uni.getStorageSync('id') || 'test-user123', |
|
|
userId: uni.getStorageSync('id') || 'test-user123', |
|
|
shopId: this.shopItem.id, |
|
|
shopId: this.shopItem.id, |
|
|
orderType: this.isGroupBuy ? 2 : 1, |
|
|
deliveryType: deliveryType, |
|
|
deliveryType: this.isPaotui ? 1 : 2, |
|
|
|
|
|
totalAmount: this.totalAmountCalc, |
|
|
|
|
|
goodsAmount: this.goodsAmountCalc, |
|
|
|
|
|
packageFee: this.packageFee, |
|
|
packageFee: this.packageFee, |
|
|
addressId: this.isPaotui && this.formData.address ? this.formData.address.id : null, |
|
|
remark: '', |
|
|
getAreaId: this.shopItem.shopArea || null, |
|
|
items: items, |
|
|
putAreaId: this.isPaotui && this.formData.address ? this.formData.address.areaId : null, |
|
|
receiverName: this.formData.address ? this.formData.address.receiverName : '', |
|
|
items: items |
|
|
receiverPhone: this.formData.address ? this.formData.address.phone : '', |
|
|
|
|
|
receiverAddress: this.formData.address ? ((this.formData.address.areaName || '') + (this.formData.address.floor ? this.formData.address.floor + '层' : '') + (this.formData.address.roomNum || '')) : '', |
|
|
|
|
|
shopName: this.shopItem.shopName, |
|
|
|
|
|
shopPhone: this.shopItem.shopPhone || '', |
|
|
|
|
|
shopAddress: this.shopItem.shopAddress || '' |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let mft = this.getMustFinishTime(); |
|
|
|
|
|
if(mft) payload.mustFinishTime = mft; |
|
|
|
|
|
|
|
|
|
|
|
if (deliveryType === 1 && !isJoiningFaceToFace) { |
|
|
|
|
|
payload.addressId = this.formData.address ? this.formData.address.id : null; |
|
|
|
|
|
payload.getAreaId = this.shopItem.shopArea || null; |
|
|
|
|
|
payload.putAreaId = this.formData.address ? this.formData.address.areaId : null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(this.isGroupBuy && this.groupItem) { |
|
|
if(this.isGroupBuy && this.groupItem) { |
|
|
payload.groupTargetMembers = parseInt(this.groupItem.groupRule.groupCount); |
|
|
if (this.groupItem.groupId) { |
|
|
payload.groupPrice = parseFloat(this.groupItem.groupRule.groupPrice); |
|
|
payload.groupId = this.groupItem.groupId; |
|
|
|
|
|
} else { |
|
|
|
|
|
payload.groupParam = { |
|
|
|
|
|
targetMembers: parseInt(this.groupItem.groupRule.groupCount), |
|
|
|
|
|
isFaceToFace: this.groupItem.isFaceToFace ? 1 : 0, |
|
|
|
|
|
selfCommission: this.selected === 'buzhiding' ? parseFloat(this.customCommission || 0) : null |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(this.isPaotui) { |
|
|
if (this.isPaotui && !isJoiningFaceToFace) { |
|
|
if (this.selected === 'zhiding' && this.assignedWorker) { |
|
|
if (this.selected === 'zhiding' && this.assignedWorker) { |
|
|
payload.workerId = this.assignedWorker.workerId; |
|
|
payload.workerParam = { |
|
|
payload.workerCommission = parseFloat(this.assignedWorker.orderBkge || 0); |
|
|
workerId: this.assignedWorker.workerId, |
|
|
} else { |
|
|
orderBkge: parseFloat(this.assignedWorker.orderBkge || 0) |
|
|
payload.workerCommission = parseFloat(this.customCommission || 0); // Default unassigned pool |
|
|
}; |
|
|
|
|
|
} else if (this.selected === 'buzhiding') { |
|
|
|
|
|
payload.workerParam = { |
|
|
|
|
|
orderBkge: parseFloat(this.customCommission || 0) |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uni.showLoading({ title: '提交中' }); |
|
|
uni.showLoading({ title: '创建订单中...' }); |
|
|
this.tui.request("/order/submitMallOrder", "POST", payload, false, false).then(res => { |
|
|
this.tui.request("/mall/order/create", "POST", payload, false, false).then(res => { |
|
|
uni.hideLoading(); |
|
|
uni.hideLoading(); |
|
|
if(res.code == 200) { |
|
|
if(res.success && res.result) { |
|
|
let orderId = res.result; |
|
|
let orderId = res.result.id; |
|
|
// Simulate successful payment instantly |
|
|
let totalAmount = res.result.totalAmount; |
|
|
this.tui.request(`/hiver/order/payMallOrderSuccess?orderId=${orderId}&workerId=${payload.workerId || ''}`, "POST", {}, false, false).then(res2 => { |
|
|
this.backendTotalAmount = totalAmount; |
|
|
uni.showToast({ title: '支付成功并生成对应详情', icon: 'none' }); |
|
|
this.currentOrderId = orderId; |
|
|
setTimeout(() => { |
|
|
this.$refs.payPopup.open('bottom'); |
|
|
uni.navigateBack({ delta: 2 }); |
|
|
|
|
|
}, 1500); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
uni.showToast({ title: res.message || '下单失败', icon: 'none' }); |
|
|
uni.showToast({ title: res.message || '下单失败', icon: 'none' }); |
|
|
} |
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
uni.hideLoading(); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
//时间选择器获取时间数据 |
|
|
//时间选择器获取时间数据 |
|
|
|