From b6450c16b1d49f0987d6b354387c2228dd880142 Mon Sep 17 00:00:00 2001
From: wangfukang <15630117759@163.com>
Date: Fri, 20 Mar 2026 14:37:31 +0800
Subject: [PATCH] 11
---
package1/buyFood/buyFood.vue | 297 ++++++++++++++++++++++----
package1/group/groupBuySingle.vue | 22 +-
package1/index/deliveryPersonList.vue | 70 ++++--
3 files changed, 320 insertions(+), 69 deletions(-)
diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue
index 44bb3fa..486a0b5 100644
--- a/package1/buyFood/buyFood.vue
+++ b/package1/buyFood/buyFood.vue
@@ -59,7 +59,7 @@
立即送出
- 预计18:47-19:02送达
+ 预计{{immediateTimeStr}}送达
@@ -86,12 +86,18 @@
-
-
-
+
+
+
+
+
+
+ 不指定
+
+
+ 佣金 ¥
+
-
- 不指定
@@ -102,7 +108,7 @@
指定配送员
- 配送员
+ {{ assignedWorker ? assignedWorker.workerName + ' ' + assignedWorker.mobile : '配送员' }}
@@ -110,58 +116,78 @@
- 竹仔园牛仔农庄(第六分店)
+ {{shopItem.shopName || '未知道商家'}}
-
-
-
-
-
-
- 牛仔农庄(医专店)
+
+
+
+
+
-
-
- 打分;不要啦
+
+
+ {{cartItem.item.productName}}
-
-
-
- X1
+
+
+ {{getSpecDisplayString(cartItem.specs)}}
+
-
- ¥90.00
-
- 拼团
- ¥59.9
+
+
+ X{{cartItem.quantity}}
+
+
+ ¥{{cartItem.price}}
-
-
-
-
- 打包费
+
+
+
+
+
-
- ¥1
+
+
+ {{groupItem.item.productName}}
+
+
+
+ {{getSpecDisplayString(groupItem.specs)}}
+
+
+
+
+ X1
+
+
+
+ 拼团
+ ¥{{groupItem.groupRule.groupPrice}}
+
+
+
+
+
+
- 配送费
+ 打包费
- ¥5
+ ¥{{packageFee.toFixed(2)}}
-
+
- 优惠券
+ 配送费 (均摊)
- -¥1
+ ¥{{deliveryFeeCalc.toFixed(2)}}
@@ -171,7 +197,7 @@
合计
- ¥90.00
+ ¥{{totalAmountCalc.toFixed(2)}}
@@ -218,6 +244,15 @@
},
content: [],
selected: 'buzhiding',
+ customCommission: '0',
+ shopItem: {},
+ cartItems: [],
+ groupItem: null,
+ isGroupBuy: false,
+ isFaceToFace: false,
+ assignedWorker: null,
+ immediateTimeStr: '',
+ totalPackageFee: 0
}
},
components: {
@@ -225,11 +260,86 @@
addressList
},
onLoad(option) {
-
+ if (option.shopItem) {
+ this.shopItem = JSON.parse(decodeURIComponent(option.shopItem));
+ }
+ if (option.cart) {
+ this.cartItems = JSON.parse(decodeURIComponent(option.cart));
+ this.isGroupBuy = false;
+ }
+ if (option.item) {
+ this.groupItem = JSON.parse(decodeURIComponent(option.item));
+ this.isGroupBuy = this.groupItem.orderType === 2;
+ this.isFaceToFace = this.groupItem.isFaceToFace || false;
+ }
+ if (option.packageFee) {
+ this.totalPackageFee = parseFloat(option.packageFee) || 0;
+ }
+ },
+ computed: {
+ goodsAmountCalc() {
+ if(this.isGroupBuy && this.groupItem) {
+ return parseFloat(this.groupItem.groupRule.groupPrice);
+ } else {
+ return this.cartItems.reduce((acc, curr) => acc + (curr.quantity * parseFloat(curr.price)), 0);
+ }
+ },
+ packageFee() {
+ if (this.totalPackageFee > 0) return this.totalPackageFee;
+ let fee = 0;
+ if(this.isGroupBuy && this.groupItem && this.groupItem.item) {
+ fee = parseFloat(this.groupItem.item.lunchBox || 0);
+ } else if (this.cartItems && this.cartItems.length > 0) {
+ for(let cart of this.cartItems) {
+ if(cart.item) {
+ fee += parseFloat(cart.item.lunchBox || 0) * cart.quantity;
+ }
+ }
+ }
+ return fee;
+ },
+ deliveryFeeCalc() {
+ if(!this.isPaotui) return 0;
+ let commission = 0;
+ if(this.selected === 'zhiding') {
+ if (!this.assignedWorker) return 0;
+ commission = parseFloat(this.assignedWorker.orderBkge || 3);
+ } else {
+ if (this.customCommission !== '' && this.customCommission !== null && !isNaN(parseFloat(this.customCommission))) {
+ commission = parseFloat(this.customCommission);
+ }
+ }
+ if(this.isGroupBuy && this.groupItem) {
+ let members = parseInt(this.groupItem.groupRule.groupCount) || 1;
+ if(this.selected === 'zhiding') {
+ let extra = members > 2 ? (members - 2) * 0.5 : 0;
+ return Math.ceil(((commission + extra) / members) * 10) / 10;
+ } else {
+ return Math.ceil((commission / members) * 10) / 10;
+ }
+ }
+ return commission;
+ },
+ totalAmountCalc() {
+ return this.goodsAmountCalc + this.packageFee + this.deliveryFeeCalc;
+ }
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.initAddress()
+
+ const now = new Date();
+ now.setMinutes(now.getMinutes() + 30);
+ this.immediateTimeStr = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`;
+
+ // Listen for selected delivery person event
+ uni.$on('updateDeliveryWorker', (worker) => {
+ this.assignedWorker = worker;
+ this.selected = 'zhiding';
+ });
+ },
+ onUnload() {
+ uni.$off('updateDeliveryWorker');
},
methods: {
initAddress() {
@@ -259,12 +369,108 @@
closeAddressBook() {
this.$refs.bookPopup.close();
},
+ getSpecDisplayString(specs) {
+ if(!specs) return '';
+ let arr = [];
+ for(let k in specs) { arr.push(specs[k]); }
+ return arr.join(',');
+ },
submitPay(){
- this.$refs.warnPopup.open()
+ if(this.isPaotui && !this.formData.address) {
+ this.warnPopup = 'shdz';
+ this.$refs.warnPopup.open();
+ return;
+ }
+
+ if(this.isPaotui && this.selected === 'buzhiding') {
+ let comm = parseFloat(this.customCommission);
+ if (isNaN(comm) || comm <= 0) {
+ this.warnPopup = 'psyj';
+ this.$refs.warnPopup.open();
+ return;
+ }
+ }
+
+ if(this.isPaotui && this.selected === 'zhiding' && !this.assignedWorker) {
+ this.warnPopup = 'psy';
+ this.$refs.warnPopup.open();
+ return;
+ }
+
+ let items = [];
+ if(this.isGroupBuy && this.groupItem) {
+ items.push({
+ productId: this.groupItem.item.id,
+ productName: this.groupItem.item.productName,
+ productPicture: this.groupItem.item.productPicture,
+ specs: this.getSpecDisplayString(this.groupItem.specs),
+ price: parseFloat(this.groupItem.groupRule.groupPrice),
+ quantity: 1
+ });
+ } else {
+ for(let cart of this.cartItems) {
+ items.push({
+ productId: cart.item.id,
+ productName: cart.item.productName,
+ productPicture: cart.item.productPicture,
+ specs: this.getSpecDisplayString(cart.specs),
+ price: parseFloat(cart.price),
+ quantity: cart.quantity
+ });
+ }
+ }
+
+ let payload = {
+ userId: uni.getStorageSync('id') || 'test-user123',
+ shopId: this.shopItem.id,
+ orderType: this.isGroupBuy ? 2 : 1,
+ deliveryType: this.isPaotui ? 1 : 2,
+ totalAmount: this.totalAmountCalc,
+ goodsAmount: this.goodsAmountCalc,
+ packageFee: this.packageFee,
+ addressId: this.isPaotui && this.formData.address ? this.formData.address.id : null,
+ getAreaId: this.shopItem.shopArea || null,
+ putAreaId: this.isPaotui && this.formData.address ? this.formData.address.areaId : null,
+ items: items
+ };
+
+ if(this.isGroupBuy && this.groupItem) {
+ payload.groupTargetMembers = parseInt(this.groupItem.groupRule.groupCount);
+ payload.groupPrice = parseFloat(this.groupItem.groupRule.groupPrice);
+ }
+
+ if(this.isPaotui) {
+ if(this.selected === 'zhiding' && this.assignedWorker) {
+ payload.workerId = this.assignedWorker.workerId;
+ payload.workerCommission = parseFloat(this.assignedWorker.orderBkge || 0);
+ } else {
+ payload.workerCommission = parseFloat(this.customCommission || 0); // Default unassigned pool
+ }
+ }
+
+ uni.showLoading({ title: '提交中' });
+ this.tui.request("/hiver/order/submitMallOrder", "POST", payload, false, false).then(res => {
+ uni.hideLoading();
+ if(res.code == 200) {
+ let orderId = res.result;
+ // Simulate successful payment instantly
+ this.tui.request(`/hiver/order/payMallOrderSuccess?orderId=${orderId}&workerId=${payload.workerId || ''}`, "POST", {}, false, false).then(res2 => {
+ uni.showToast({ title: '支付成功并生成对应详情', icon: 'none' });
+ setTimeout(() => {
+ uni.navigateBack({ delta: 2 });
+ }, 1500);
+ });
+ } else {
+ uni.showToast({ title: res.message || '下单失败', icon: 'none' });
+ }
+ });
},
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'
+ url:`/package1/index/deliveryPersonList?shopAreaId=${shopArea}&putAreaId=${putArea}`
})
},
openAddressBook(){
@@ -285,7 +491,8 @@
if (type == this.selected) return;
this.selected = type;
if(this.selected == 'buzhiding'){
- this.formData.peisongyuan = ""
+ this.formData.peisongyuan = "";
+ this.assignedWorker = null;
}
},
//时间选择器获取时间数据
@@ -594,4 +801,4 @@
padding: 10px;
overflow: scroll;
}
-
\ No newline at end of file
+
diff --git a/package1/group/groupBuySingle.vue b/package1/group/groupBuySingle.vue
index b0b1224..cc76c36 100644
--- a/package1/group/groupBuySingle.vue
+++ b/package1/group/groupBuySingle.vue
@@ -318,10 +318,10 @@
-
+
面对面团
-
+
拼团购买¥{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}}
@@ -605,21 +605,23 @@
uni.showToast({ title: '已加入购物车', icon: 'none' });
this.$refs.pintuanPopup.close();
},
- submitPintuan() {
+ submitPintuan(isFaceToFace) {
let specChoices = {};
for (let spec of this.parsedSpecs) {
specChoices[spec.name] = spec.selected;
}
+ let packageFee = parseFloat(this.currentItem.lunchBox || 0);
// Pack data for checkout
let goData = {
item: this.currentItem,
groupRule: this.selectedGroupRule,
- specs: specChoices
+ specs: specChoices,
+ orderType: 2, // 2 indicates Group Buy
+ isFaceToFace: isFaceToFace || false
};
// Directly navigate to checkout
uni.navigateTo({
- // Update this url to actual checkout path
- url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData))
+ url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData)) + '&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' + packageFee
});
this.$refs.pintuanPopup.close();
},
@@ -672,9 +674,15 @@
this.$refs.warnPopup.open()
return;
}
+
+ let totalPackageFee = 0;
+ for (let cartItem of this.cartItems) {
+ totalPackageFee += parseFloat(cartItem.item.lunchBox || 0) * cartItem.quantity;
+ }
+
// 类似普通订单结算逻辑
uni.navigateTo({
- url: '/package1/buyFood/buyFood?cart=' + encodeURIComponent(JSON.stringify(this.cartItems))
+ url: '/package1/buyFood/buyFood?cart=' + encodeURIComponent(JSON.stringify(this.cartItems)) + '&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' + totalPackageFee
});
},
goDetail(type) {
diff --git a/package1/index/deliveryPersonList.vue b/package1/index/deliveryPersonList.vue
index b717c3c..15f7d21 100644
--- a/package1/index/deliveryPersonList.vue
+++ b/package1/index/deliveryPersonList.vue
@@ -31,52 +31,52 @@
-
+
-
+
-
+
- 潘潘安
+ {{worker.workerName || '未知'}}
+ alt="" style="width: 140rpx;height: 32rpx;margin-top: 18rpx;" v-if="worker.rebateAmount > 0" />
-
- 跑腿单
+
- 5
+ {{worker.score || 5}}
-
+
- 平均配送时长 32分钟
+ 平均配送时长 {{worker.avgTime || 30}}分钟
- 当前待取 5
+ 当前待取 {{worker.orderGetCount || 0}}
- 当前待送 2
+ 当前待送 {{worker.orderPutCount || 0}}
- 待接单数 1
+ 待接单数 {{worker.orderWaitCount || 0}}
- 备注:可接校外美食街;可代取快递,一件1元,3件2.5元,多取多优惠
+ 备注:{{worker.remark || '无'}}
@@ -104,18 +104,43 @@
id: 2,
title: '配送费低'
}],
+ shopAreaId: '',
+ putAreaId: '',
+ workerList: [],
+ keyword: ''
}
},
onLoad(option) {
-
+ this.shopAreaId = option.shopAreaId || '';
+ this.putAreaId = option.putAreaId || '';
+ this.getShopList();
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
},
methods: {
+ getShopList() {
+ // Fake request to our new endpoint
+ let payload = {
+ shopAreaId: this.shopAreaId,
+ putAreaId: this.putAreaId,
+ baozhang: this.baozhang,
+ xiangtong: this.xiangtong,
+ keyword: this.keyword
+ };
+ this.tui.request("/worker/getMatchingWorkerList", "POST", payload, false, false).then(res => {
+ if(res.code == 200) {
+ this.workerList = res.result || [];
+ }
+ });
+ },
+ selectWorker(worker) {
+ uni.$emit('updateDeliveryWorker', worker);
+ uni.navigateBack();
+ },
searchShop(type, value) {
if (type == 'area') {
- this.searchForm.shopArea = value
+ // this.searchForm.shopArea = value
} else if (type == 'baozhang') {
this.baozhang = !this.baozhang
} else if (type == 'xiangtong') {
@@ -306,4 +331,15 @@
color: #777;
font-weight: 700;
}
+ .shop-menu-purchase{
+ display: flex;
+ background: rgba(255, 57, 57, 0.1);
+ height: 36rpx;
+ line-height: 36rpx;
+ padding: 0 0 0 4rpx;
+ border-radius: 8rpx;
+ font-weight: 700;
+ margin-top: 10rpx;
+ color: #777;
+ }
\ No newline at end of file