|
|
|
@ -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; |
|
|
|
} |
|
|
|
}, |
|
|
|
//时间选择器获取时间数据 |
|
|
|
|