wangfukang 4 weeks ago
parent
commit
b6450c16b1
  1. 265
      package1/buyFood/buyFood.vue
  2. 22
      package1/group/groupBuySingle.vue
  3. 70
      package1/index/deliveryPersonList.vue

265
package1/buyFood/buyFood.vue

@ -59,7 +59,7 @@
立即送出
</view>
<view style="font-size: 10px;color: #777;">
预计18:47-19:02送达
预计{{immediateTimeStr}}送达
</view>
</view>
<view class="time1" @tap="checkTime(false)" :style="{'background':formData.isImmediately==false?'linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1))':'#eee'}">
@ -86,13 +86,19 @@
</view>
</view>
<view style="padding: 20px;">
<view style="display: flex;font-size: 14px;font-weight: bold;line-height: 25px;margin-bottom: 15px;">
<view style="display: flex;font-size: 14px;font-weight: bold;line-height: 25px;margin-bottom: 15px;align-items: center;">
<view style="width:50%;display: flex;align-items: center;">
<view class="radio-check" v-if="selected === 'buzhiding'">
<uni-icons type="checkmarkempty" size="12"></uni-icons>
</view>
<view class="radio-no-check" @tap="checkVoucher('buzhiding')" v-else></view>
不指定
</view>
<view style="width: 50%;display: flex;justify-content: flex-end;align-items: center;" v-if="selected === 'buzhiding'">
<text style="color: #777; font-weight: normal; margin-right: 5px; font-size: 12px;">佣金 </text>
<input type="digit" v-model="customCommission" style="width: 70px; border-bottom: 1px solid #ccc; text-align: center; font-size: 14px; font-weight: normal; height: 25px; min-height: 25px;" placeholder="金额" />
</view>
</view>
<view class="" style="display: flex;font-size: 14px;font-weight: bold;line-height: 25px;">
<view style="width:50%;display: flex;">
<view class="radio-check" v-if="selected === 'zhiding'">
@ -102,7 +108,7 @@
指定配送员
</view>
<view style="width: 50%;color: #777;text-align: right;" @tap="goDetail">
配送员
{{ assignedWorker ? assignedWorker.workerName + ' ' + assignedWorker.mobile : '配送员' }}
<uni-icons type="right" size="12"></uni-icons>
</view>
</view>
@ -110,58 +116,78 @@
</view>
<view class="box1">
<view style="width: 100%;line-height: 35px;font-size: 14px;font-weight: 700;">
竹仔园牛仔农庄(第六分店)
{{shopItem.shopName || '未知道商家'}}
</view>
<block v-if="!isGroupBuy">
<view style="display: flex;padding: 10px;background: #eee;border-radius: 10px; margin-bottom:10px;" v-for="(cartItem, index) in cartItems" :key="index">
<view class="goods-img">
<img :src="cartItem.item.productPicture" alt="">
</view>
<view class="goods-content">
<view class="goods-name">
{{cartItem.item.productName}}
</view>
<view class="goods-content-center" v-if="cartItem.specs">
<view class="goods-deal1">
{{getSpecDisplayString(cartItem.specs)}}
</view>
</view>
<view class="goods-content-bottom">
<view style="width: 45%;">
X{{cartItem.quantity}}
</view>
<view style="display: flex;padding: 10px;background: #eee;border-radius: 10px;">
<view class="pintuan-left-price" style="flex:1;">
{{cartItem.price}}
</view>
</view>
</view>
</view>
</block>
<block v-else>
<view style="display: flex;padding: 10px;background: #eee;border-radius: 10px; margin-bottom:10px;" v-if="groupItem">
<view class="goods-img">
<img src="/static/images/img/shangpintu.png" alt="">
<img :src="groupItem.item.productPicture" alt="">
</view>
<view class="goods-content">
<view class="goods-name">
牛仔农庄(医专店)
{{groupItem.item.productName}}
</view>
<view class="goods-content-center">
<view class="goods-content-center" v-if="groupItem.specs">
<view class="goods-deal1">
打分不要啦
{{getSpecDisplayString(groupItem.specs)}}
</view>
</view>
<view class="goods-content-bottom">
<view style="width: 45%;">
X1
</view>
<view class="pintuan-left-price">
90.00
<view class="pintuan-left-price" style="flex:1;">
<view style="background: rgba(255, 57, 57, 0.2);padding: 0px 6px;border-radius: 10px;margin-left: 10px;">
<text>拼团</text>
<text style="color: red;">59.9</text>
<text style="color: red;">{{groupItem.groupRule.groupPrice}}</text>
</view>
</view>
</view>
</view>
</view>
</block>
<view>
<view style="height: 40px;line-height: 40px;display: flex;">
<view style="flex: 1;color: #777;font-weight: 700;">
打包费
</view>
<view style="color: #000;font-weight:700;">
1
{{packageFee.toFixed(2)}}
</view>
</view>
<view style="height: 40px;line-height: 40px;display: flex;">
<view style="flex: 1;color: #777;font-weight: 700;">
配送费
</view>
<view style="color: #000;font-weight:700;">
5
</view>
</view>
<view style="height: 40px;line-height: 40px;display: flex;">
<view style="height: 40px;line-height: 40px;display: flex;" v-if="isPaotui">
<view style="flex: 1;color: #777;font-weight: 700;">
优惠券
配送费 <text v-if="isGroupBuy" style="font-size: 10px;color: #999;">(均摊)</text>
</view>
<view style="color: #000;font-weight:700;">
-1 <uni-icons type="right" size="12"></uni-icons>
{{deliveryFeeCalc.toFixed(2)}}
</view>
</view>
</view>
@ -171,7 +197,7 @@
合计
</view>
<view class="">
90.00
{{totalAmountCalc.toFixed(2)}}
</view>
</view>
<view style="height:80px;"></view>
@ -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;
}
},
//

22
package1/group/groupBuySingle.vue

@ -318,10 +318,10 @@
</scroll-view>
<view class="bottom" style="padding-bottom: 20px;height: 80px;z-index: 10;">
<view v-if="isPintuan" class="pintuan1">
<view class="pintuan2" style="border-bottom-left-radius: 50px;border-top-left-radius: 50px;" @tap="submitPintuan">
<view class="pintuan2" style="border-bottom-left-radius: 50px;border-top-left-radius: 50px;" @tap="submitPintuan(true)">
面对面团
</view>
<view class="pintuan2" style="background: rgba(0, 35, 28, 1);border-bottom-right-radius: 50px;border-top-right-radius: 50px;color: rgba(166, 255, 234, 1);" @tap="submitPintuan">
<view class="pintuan2" style="background: rgba(0, 35, 28, 1);border-bottom-right-radius: 50px;border-top-right-radius: 50px;color: rgba(166, 255, 234, 1);" @tap="submitPintuan(false)">
拼团购买{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}}
</view>
</view>
@ -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) {

70
package1/index/deliveryPersonList.vue

@ -31,52 +31,52 @@
</view>
<view class="sort-member" style="display: flex;padding-left: 10rpx;">
<uni-icons type="search" size="12"></uni-icons>
<input type="text" placeholder="搜索" style="height: 60rpx;line-height: 60rpx;">
<input type="text" placeholder="搜索" style="height: 60rpx;line-height: 60rpx;" v-model="keyword" @confirm="getShopList">
</view>
</view>
<view class="man-box">
<view class="man-box" v-for="(worker, index) in workerList" :key="index" @tap="selectWorker(worker)">
<view class="man-title">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/801c569079da4540990c1cc634186fdd.png" alt=""
style="width: 120rpx;height: 120rpx;" />
<img :src="worker.icon || 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/801c569079da4540990c1cc634186fdd.png'" alt=""
style="width: 120rpx;height: 120rpx;border-radius:60rpx;" />
<view class="man-title1">
<view class="man-title2">
<view class="man-name">
潘潘安
{{worker.workerName || '未知'}}
</view>
<view style="flex:1;">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/d27fa14c6bb7426482ed7821919d3aa7.png"
alt="" style="width: 140rpx;height: 32rpx;margin-top: 18rpx;" />
alt="" style="width: 140rpx;height: 32rpx;margin-top: 18rpx;" v-if="worker.rebateAmount > 0" />
</view>
<view class="man-type">
跑腿单
<view class="shop-menu-purchase man-name">
¥{{worker.orderBkge}}
</view>
</view>
<view class="man-rate">
<view class="shop-rate">
<view class="shop-rate-num">5</view>
<view class="shop-rate-num">{{worker.score || 5}}</view>
<view style="padding-top: 2px;">
<uni-rate :disabled="true" size="16" disabledColor="rgba(255, 184, 84, 1)" value="5" />
<uni-rate :disabled="true" size="16" disabledColor="rgba(255, 184, 84, 1)" :value="worker.score || 5" />
</view>
</view>
<view class="man-num">
平均配送时长 <text style="font-size: 30rpx;font-weight: 700;color: #000;">32</text>分钟
平均配送时长 <text style="font-size: 30rpx;font-weight: 700;color: #000;">{{worker.avgTime || 30}}</text>分钟
</view>
</view>
</view>
</view>
<view class="man-dingdan">
<view class="man-dingdan1">
当前待取 <text style="font-size:36rpx;font-weight:700;color: #000;">5</text>
当前待取 <text style="font-size:36rpx;font-weight:700;color: #000;">{{worker.orderGetCount || 0}}</text>
</view>
<view class="man-dingdan1">
当前待送 <text style="font-size:36rpx;font-weight:700;color: #000;">2</text>
当前待送 <text style="font-size:36rpx;font-weight:700;color: #000;">{{worker.orderPutCount || 0}}</text>
</view>
<view class="man-dingdan1">
待接单数 <text style="font-size:36rpx;font-weight:700;color: #000;">1</text>
待接单数 <text style="font-size:36rpx;font-weight:700;color: #000;">{{worker.orderWaitCount || 0}}</text>
</view>
</view>
<view class="man-mank">
备注:<text style="color: #000;">可接校外美食街可代取快递一件1元3件2.5多取多优惠</text>
备注:<text style="color: #000;">{{worker.remark || '无'}}</text>
</view>
</view>
</view>
@ -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;
}
</style>
Loading…
Cancel
Save