|
|
|
@ -152,10 +152,10 @@ |
|
|
|
<view class="btn" v-if="orderDetail.status == 3 && orderDetail.deliveryType == 2" @tap="openCode"> |
|
|
|
立即备餐 |
|
|
|
</view> |
|
|
|
<view class="btn" style="width: 40%;" v-if="orderDetail.status == 2" @tap=""> |
|
|
|
<view class="btn" style="width: 40%;" v-if="orderDetail.status == 2" @tap="openAddFeePopup"> |
|
|
|
增加配送佣金 |
|
|
|
</view> |
|
|
|
<view class="btn" style="width: 40%;" v-if="orderDetail.status == 2" @tap=""> |
|
|
|
<view class="btn" style="width: 40%;" v-if="orderDetail.status == 2" @tap="goAssignWorker"> |
|
|
|
指派配送员 |
|
|
|
</view> |
|
|
|
<!-- <view class="btn"> |
|
|
|
@ -473,6 +473,54 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
|
|
|
|
<uni-popup ref="addFeePopup" background-color="#fff" style="height: 1600rpx !important;"> |
|
|
|
<view class="guize-list"> |
|
|
|
<view style="height: 80rpx;line-height: 80rpx;font-size: 36rpx;font-weight: 700;text-align: center;"> |
|
|
|
增加配送佣金 |
|
|
|
</view> |
|
|
|
<view style="padding: 20rpx 40rpx;"> |
|
|
|
<view style="font-size: 28rpx;color: #777;margin-bottom: 20rpx;">请输入要增加的佣金金额(元)</view> |
|
|
|
<input type="digit" v-model="additionalFee" placeholder="请输入金额" style="border: 1px solid #ccc;border-radius: 16rpx;height: 80rpx;line-height: 80rpx;padding: 0 20rpx;font-size: 32rpx;text-align: center;" /> |
|
|
|
</view> |
|
|
|
<view class="btn" @tap="submitAddFee()"> |
|
|
|
去支付 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
|
|
|
|
<!-- 增加佣金支付弹出层 --> |
|
|
|
<uni-popup ref="addFeePayPopup" background-color="#fff"> |
|
|
|
<view class="pay-popup" style="height: 290px;background: #fff;border-radius: 40rpx 40rpx 0 0;padding-top: 40rpx;"> |
|
|
|
<view class="content" style="height: 100%;margin-top:0"> |
|
|
|
<view class="box1"> |
|
|
|
<view style="height: 70rpx;line-height: 70rpx;text-align: center;"> |
|
|
|
增加配送佣金 |
|
|
|
</view> |
|
|
|
<view style="height: 90rpx;line-height: 90rpx;text-align: center;font-weight: 700;font-size: 30rpx;"> |
|
|
|
¥<text style="font-size: 60rpx;">{{additionalFee || '0.00'}}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="box1" style="display: flex;padding: 40rpx;"> |
|
|
|
<view style="flex: 1;"> |
|
|
|
<view style="height: 42rpx;line-height: 42rpx;display: flex;"> |
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4c8e0cc311db4d38ab43e019673c4b8c.png" alt="" style="width: 42rpx;height: 42rpx;margin-right: 20rpx;" /> |
|
|
|
<text style="font-size: 30rpx;font-weight: 700;">微信支付</text> |
|
|
|
</view> |
|
|
|
<view style="text-align: right;margin-left: 60rpx;color: #777;width: 146rpx;"> |
|
|
|
使用微信支付 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view style="width: 36rpx;padding-top: 20rpx;"> |
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/02bff7edc4e04caaa1868955ff684f1f.png" alt="" style="width: 36rpx;height: 36rpx;" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="btn" style="background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));width: 90%;height: 100rpx;border-radius: 100rpx;text-align: center;font-size: 28rpx;font-weight: 700;line-height: 100rpx;margin: 40rpx auto;" @tap="addFeeWxPayment"> |
|
|
|
确认付款 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -490,7 +538,9 @@ |
|
|
|
orderId:'', |
|
|
|
payData:{}, |
|
|
|
orderDetail:{}, |
|
|
|
codeImg:'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3a4e68eb14d7417cbb4f15fa85907c64.jpg' |
|
|
|
codeImg:'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3a4e68eb14d7417cbb4f15fa85907c64.jpg', |
|
|
|
additionalFee: '', |
|
|
|
addFeeTradeNo: '' |
|
|
|
} |
|
|
|
}, |
|
|
|
components: { |
|
|
|
@ -546,9 +596,22 @@ |
|
|
|
this.orderId = option.id |
|
|
|
this.getOrderDetail(this.orderId) |
|
|
|
} |
|
|
|
// 监听配送员选择事件(在onLoad中注册一次,确保事件不会丢失) |
|
|
|
uni.$on('updateDeliveryWorker', (worker) => { |
|
|
|
this.handleWorkerSelected(worker); |
|
|
|
}); |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() |
|
|
|
// 备用方案:检查缓存中是否有待处理的配送员选择 |
|
|
|
let pendingWorker = uni.getStorageSync('pendingAssignWorker'); |
|
|
|
if (pendingWorker) { |
|
|
|
uni.removeStorageSync('pendingAssignWorker'); |
|
|
|
this.handleWorkerSelected(pendingWorker); |
|
|
|
} |
|
|
|
}, |
|
|
|
onUnload() { |
|
|
|
uni.$off('updateDeliveryWorker'); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
openCode(){ |
|
|
|
@ -771,6 +834,134 @@ |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
}, |
|
|
|
goAssignWorker() { |
|
|
|
let shopAreaId = this.orderDetail.getAreaId || ''; |
|
|
|
let putAreaId = this.orderDetail.putAreaId || ''; |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/package1/index/deliveryPersonList?shopAreaId=${shopAreaId}&putAreaId=${putAreaId}` |
|
|
|
}); |
|
|
|
}, |
|
|
|
handleWorkerSelected(worker) { |
|
|
|
let that = this; |
|
|
|
uni.showModal({ |
|
|
|
title: '指派配送员', |
|
|
|
content: `是否选取配送员「${worker.workerName || '未知'}」?`, |
|
|
|
success: function(res) { |
|
|
|
if (res.confirm) { |
|
|
|
that.reassignWorker(worker); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
reassignWorker(worker) { |
|
|
|
let that = this; |
|
|
|
let deliveryId = ''; |
|
|
|
if (that.orderDetail.deliveryInfo && that.orderDetail.deliveryInfo.id) { |
|
|
|
deliveryId = that.orderDetail.deliveryInfo.id; |
|
|
|
} |
|
|
|
that.tui.request("/mall/delivery/reassignWorker", "POST", { |
|
|
|
deliveryId: deliveryId, |
|
|
|
newWorkerId: worker.workerId, |
|
|
|
newWorkerName: worker.workerName, |
|
|
|
newWorkerPhone: worker.mobile |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
that.tui.toast("指派配送员成功"); |
|
|
|
that.getOrderDetail(that.orderId); |
|
|
|
that.$forceUpdate(); |
|
|
|
} else { |
|
|
|
that.tui.toast(res.message || '指派配送员失败'); |
|
|
|
} |
|
|
|
}).catch((err) => { |
|
|
|
that.tui.toast('请求失败,请重试'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
openAddFeePopup() { |
|
|
|
this.additionalFee = ''; |
|
|
|
this.$refs.addFeePopup.open('bottom'); |
|
|
|
}, |
|
|
|
submitAddFee() { |
|
|
|
let fee = parseFloat(this.additionalFee); |
|
|
|
if (isNaN(fee) || fee <= 0) { |
|
|
|
this.tui.toast('请输入有效的金额'); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 关闭输入弹窗,生成随机订单号,打开支付弹窗 |
|
|
|
this.$refs.addFeePopup.close(); |
|
|
|
const now = Date.now(); // 获取当前时间戳 (13位) |
|
|
|
const randomPart = Math.floor(Math.random() * 1000000); // 6位随机数 |
|
|
|
this.addFeeTradeNo = `${now}${randomPart.toString().padStart(6, '0')}`; |
|
|
|
setTimeout(() => { |
|
|
|
this.$refs.addFeePayPopup.open('bottom'); |
|
|
|
}, 300); |
|
|
|
}, |
|
|
|
addFeeWxPayment() { |
|
|
|
let that = this; |
|
|
|
let fee = parseFloat(this.additionalFee); |
|
|
|
if (!fee || fee <= 0) return; |
|
|
|
let amountInCents = Math.round(fee * 100); |
|
|
|
|
|
|
|
this.tui.request("/api/wechat/pay/unified-order", "POST", { |
|
|
|
openid: uni.getStorageSync('miniProgramOpenid') || 'test-openid', |
|
|
|
amount: amountInCents, |
|
|
|
description: '增加配送佣金', |
|
|
|
outTradeNo: this.addFeeTradeNo |
|
|
|
}, 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) { |
|
|
|
uni.showToast({ title: '支付成功', icon: 'success' }); |
|
|
|
that.$refs.addFeePayPopup.close(); |
|
|
|
that.callAddFeeApi(); |
|
|
|
}, |
|
|
|
fail: function(err) { |
|
|
|
that.tui.toast('支付失败或取消'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 模拟支付成功(用于测试环境) |
|
|
|
if (res.code == 404 || res.code == 500 || res.code == 400 || !res.code) { |
|
|
|
that.$refs.addFeePayPopup.close(); |
|
|
|
uni.showToast({ title: '支付成功(模拟)', icon: 'none' }); |
|
|
|
setTimeout(() => { |
|
|
|
that.callAddFeeApi(); |
|
|
|
}, 1500); |
|
|
|
} else { |
|
|
|
that.tui.toast(res.message); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
callAddFeeApi() { |
|
|
|
let that = this; |
|
|
|
let fee = parseFloat(this.additionalFee); |
|
|
|
let deliveryId = ''; |
|
|
|
if (that.orderDetail.deliveryInfo && that.orderDetail.deliveryInfo.id) { |
|
|
|
deliveryId = that.orderDetail.deliveryInfo.id; |
|
|
|
} |
|
|
|
that.tui.request("/mall/delivery/addFee", "POST", { |
|
|
|
deliveryId: deliveryId, |
|
|
|
additionalFee: fee, |
|
|
|
orderId:that.orderDetail.deliveryFee.id, |
|
|
|
olditionalFee:that.orderDetail.deliveryFee ? that.orderDetail.deliveryFee : 0 |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
that.tui.toast("增加佣金成功"); |
|
|
|
that.getOrderDetail(that.orderId); |
|
|
|
that.$forceUpdate(); |
|
|
|
} else { |
|
|
|
that.tui.toast(res.message || '增加佣金失败'); |
|
|
|
} |
|
|
|
}).catch((err) => { |
|
|
|
that.tui.toast('请求失败,请重试'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
back() { |
|
|
|
uni.navigateBack() |
|
|
|
} |
|
|
|
|