From 5841fac3da5b3fe7920a9dafb01b7d3c8cfa3dc4 Mon Sep 17 00:00:00 2001 From: tianyi <13521030702@163.com> Date: Tue, 24 Mar 2026 14:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E5=BC=B9=E5=87=BA=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package1/buyFood/buyFood.vue | 476 +++++++++++++++++++++++++---------- 1 file changed, 339 insertions(+), 137 deletions(-) diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue index 6f97722..3eb4fce 100644 --- a/package1/buyFood/buyFood.vue +++ b/package1/buyFood/buyFood.vue @@ -45,16 +45,20 @@ 请选择收货地址 - - {{formData.address.areaName || ''}}{{formData.address.floor ? formData.address.floor + '层' : ''}}{{formData.address.roomNum || ''}} {{formData.address.receiverName || ''}} + + {{formData.address.areaName || ''}}{{formData.address.floor ? formData.address.floor + '层' : ''}}{{formData.address.roomNum || ''}} + {{formData.address.receiverName || ''}} - + 更换地址 - + 立即送出 @@ -62,12 +66,14 @@ 预计{{immediateTimeStr}}送达 - + 预约配送 - + {{formData.deliveryTime}} @@ -77,7 +83,8 @@ - + 配送员 @@ -86,7 +93,8 @@ - + @@ -94,9 +102,12 @@ 不指定 - + 佣金 ¥ - + @@ -120,7 +131,8 @@ - + @@ -145,7 +157,8 @@ - + @@ -163,7 +176,8 @@ X1 - + 拼团 ¥{{groupItem.groupRule.groupPrice}} @@ -193,7 +207,7 @@ - + 合计 @@ -210,15 +224,22 @@ - + - 填写收货地址 - 填写配送佣金 - 指定配送员 + 填写收货地址 + 填写配送佣金 + 指定配送员 @@ -227,10 +248,12 @@ - 支付剩余时间 59:09 + 支付剩余时间 59:09 - - ¥{{backendTotalAmount ? backendTotalAmount.toFixed(2) : totalAmountCalc.toFixed(2)}} + + ¥{{backendTotalAmount ? backendTotalAmount.toFixed(2) : totalAmountCalc.toFixed(2)}} 若拼团失败,将会为您自动退款 @@ -239,7 +262,8 @@ - + 微信支付 @@ -247,7 +271,8 @@ - + @@ -256,8 +281,54 @@ - + + + + + + + + 差1人即可成团 + + + + 快呼唤小伙伴参加吧! + + + + + + + + + + + + + + + + + + + + + 剩余23:59:23结束 + + + 分享至微信 + + + + + + + + > @@ -268,14 +339,14 @@ export default { data() { return { - warnPopup:'shdz', + warnPopup: 'shdz', isPaotui: true, menuButtonInfo: {}, - formData:{ - address:null, - isImmediately:true, - deliveryTime:'', - peisongyuan:'' + formData: { + address: null, + isImmediately: true, + deliveryTime: '', + peisongyuan: '' }, content: [], selected: 'buzhiding', @@ -315,7 +386,7 @@ }, computed: { goodsAmountCalc() { - if(this.isGroupBuy && this.groupItem) { + 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); @@ -324,11 +395,11 @@ packageFee() { if (this.totalPackageFee > 0) return this.totalPackageFee; let fee = 0; - if(this.isGroupBuy && this.groupItem && this.groupItem.item) { + 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) { + for (let cart of this.cartItems) { + if (cart.item) { fee += parseFloat(cart.item.lunchBox || 0) * cart.quantity; } } @@ -336,21 +407,24 @@ return fee; }, deliveryFeeCalc() { - 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 + 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; - if(this.selected === 'zhiding') { + 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))) { + if (this.customCommission !== '' && this.customCommission !== null && !isNaN(parseFloat(this + .customCommission))) { commission = parseFloat(this.customCommission); } } - if(this.isGroupBuy && this.groupItem && this.groupItem.isFaceToFace && !this.groupItem.groupId) { + if (this.isGroupBuy && this.groupItem && this.groupItem.isFaceToFace && !this.groupItem.groupId) { 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; return Math.ceil(((commission + extra) / members) * 10) / 10; } else { @@ -371,8 +445,10 @@ const endTime = new Date(now); startTime.setMinutes(startTime.getMinutes() + 20); endTime.setMinutes(endTime.getMinutes() + 35); - const startStr = `${startTime.getHours().toString().padStart(2, '0')}:${startTime.getMinutes().toString().padStart(2, '0')}`; - const endStr = `${endTime.getHours().toString().padStart(2, '0')}:${endTime.getMinutes().toString().padStart(2, '0')}`; + const startStr = + `${startTime.getHours().toString().padStart(2, '0')}:${startTime.getMinutes().toString().padStart(2, '0')}`; + const endStr = + `${endTime.getHours().toString().padStart(2, '0')}:${endTime.getMinutes().toString().padStart(2, '0')}`; this.immediateTimeStr = `${startStr}-${endStr}`; // Listen for selected delivery person event @@ -391,7 +467,9 @@ this.formData.address = cachedAddress; } else { let that = this; - that.tui.request("/app/userAddress/list", "GET", {userId:uni.getStorageSync('id')}, false, true).then((res) => { + that.tui.request("/app/userAddress/list", "GET", { + userId: uni.getStorageSync('id') + }, false, true).then((res) => { if (res.code == 200 && res.result && res.result.length > 0) { // Find default address or use the first one let target = res.result.find(item => item.isDefault == 1) || res.result[0]; @@ -413,20 +491,23 @@ this.$refs.bookPopup.close(); }, getSpecDisplayString(specs) { - if(!specs) return ''; + if (!specs) return ''; let arr = []; - for(let k in specs) { arr.push(specs[k]); } + for (let k in specs) { + arr.push(specs[k]); + } return arr.join(','); }, - submitPay(){ - let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem.isFaceToFace; - if(this.isPaotui && !this.formData.address && !isJoiningFaceToFace) { + submitPay() { + let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem + .isFaceToFace; + if (this.isPaotui && !this.formData.address && !isJoiningFaceToFace) { this.warnPopup = 'shdz'; this.$refs.warnPopup.open(); return; } - if(this.isPaotui && this.selected === 'buzhiding' && !isJoiningFaceToFace) { + if (this.isPaotui && this.selected === 'buzhiding' && !isJoiningFaceToFace) { let comm = parseFloat(this.customCommission); if (isNaN(comm) || comm <= 0) { this.warnPopup = 'psyj'; @@ -435,7 +516,7 @@ } } - if(this.isPaotui && this.selected === 'zhiding' && !this.assignedWorker && !isJoiningFaceToFace) { + if (this.isPaotui && this.selected === 'zhiding' && !this.assignedWorker && !isJoiningFaceToFace) { this.warnPopup = 'psy'; this.$refs.warnPopup.open(); return; @@ -444,19 +525,19 @@ // Validation successful, submit order to backend first to get backendTotalAmount this.submitOrderToBackend(); }, - goDetail(){ + 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?shopAreaId=${shopArea}&putAreaId=${putArea}` + url: `/package1/index/deliveryPersonList?shopAreaId=${shopArea}&putAreaId=${putArea}` }) }, - openAddressBook(){ + openAddressBook() { this.$refs.bookPopup.open('bottom') - + }, - checkTime(type){ + checkTime(type) { if (type === this.formData.isImmediately) { if (type === false) { this.$refs.model.open() @@ -473,7 +554,7 @@ checkVoucher(type) { if (type == this.selected) return; this.selected = type; - if(this.selected == 'buzhiding'){ + if (this.selected == 'buzhiding') { this.formData.peisongyuan = ""; this.assignedWorker = null; } @@ -481,10 +562,10 @@ wxPayment() { let that = this; if (!this.currentOrderId || !this.backendTotalAmount) return; - + let amountInCents = Math.round(this.backendTotalAmount * 100); let payDesc = this.isGroupBuy ? '拼团订单' : '商城订单'; - + this.tui.request("/api/wechat/pay/unified-order", "POST", { openid: uni.getStorageSync('miniProgramOpenid') || 'test-openid', amount: amountInCents, // 支付金额(分) @@ -501,9 +582,14 @@ paySign: res.paySign, success: function(res2) { that.$refs.payPopup.close(); - uni.showToast({ title: '支付成功', icon: 'success' }); + uni.showToast({ + title: '支付成功', + icon: 'success' + }); setTimeout(() => { - uni.navigateBack({ delta: 2 }); + uni.navigateBack({ + delta: 2 + }); }, 1500); }, fail: function(err) { @@ -513,11 +599,18 @@ } else { // 模拟支付成功(用于测试环境) 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.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' }); + uni.showToast({ + title: '支付成功(模拟)', + icon: 'none' + }); setTimeout(() => { - uni.navigateBack({ delta: 2 }); + uni.navigateBack({ + delta: 2 + }); }, 1500); }).catch(e => { that.tui.toast("请求失败"); @@ -529,9 +622,10 @@ }) }, getMustFinishTime() { - if (!this.formData.deliveryTime || this.formData.deliveryTime === '自动送达' || this.formData.deliveryTime === '尽快送达') return null; + if (!this.formData.deliveryTime || this.formData.deliveryTime === '自动送达' || this.formData.deliveryTime === + '尽快送达') return null; let timeStr = this.formData.deliveryTime; - if(timeStr.length === 5) { + if (timeStr.length === 5) { let [h, m] = timeStr.split(':'); let targetHour = parseInt(h); let d = new Date(); @@ -544,10 +638,11 @@ return null; }, submitOrderToBackend() { - let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem.isFaceToFace; - + let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem + .isFaceToFace; + let items = []; - if(this.isGroupBuy && this.groupItem) { + if (this.isGroupBuy && this.groupItem) { items.push({ productId: this.groupItem.item.id, specs: JSON.stringify(this.groupItem.specs || {}), @@ -555,7 +650,7 @@ quantity: 1 }); } else { - for(let cart of this.cartItems) { + for (let cart of this.cartItems) { items.push({ productId: cart.item.id, specs: JSON.stringify(cart.specs || {}), @@ -575,14 +670,16 @@ items: items, receiverName: this.formData.address ? this.formData.address.receiverName : '', 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 || '')) : '', + 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 (mft) payload.mustFinishTime = mft; if (deliveryType === 1 && !isJoiningFaceToFace) { payload.addressId = this.formData.address ? this.formData.address.id : null; @@ -590,14 +687,15 @@ payload.putAreaId = this.formData.address ? this.formData.address.areaId : null; } - if(this.isGroupBuy && this.groupItem) { + if (this.isGroupBuy && this.groupItem) { if (this.groupItem.groupId) { 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 + selfCommission: this.selected === 'buzhiding' ? parseFloat(this.customCommission || 0) : + null }; } } @@ -615,17 +713,22 @@ } } - uni.showLoading({ title: '创建订单中...' }); + uni.showLoading({ + title: '创建订单中...' + }); this.tui.request("/mall/order/create", "POST", payload, false, false).then(res => { uni.hideLoading(); - if(res.success && res.result) { + if (res.success && res.result) { let orderId = res.result.id; let totalAmount = res.result.totalAmount; this.backendTotalAmount = totalAmount; this.currentOrderId = orderId; this.$refs.payPopup.open('bottom'); } else { - uni.showToast({ title: res.message || '下单失败', icon: 'none' }); + uni.showToast({ + title: res.message || '下单失败', + icon: 'none' + }); } }).catch(err => { uni.hideLoading(); @@ -637,25 +740,25 @@ const today = new Date(now); const tomorrow = new Date(now); tomorrow.setDate(tomorrow.getDate() + 1); - + // 星期几 const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']; const todayWeekday = weekdays[today.getDay()]; const todayStr = `今天 (${todayWeekday})`; - + // 明天的日期格式:月-日(不补零) const month = tomorrow.getMonth() + 1; const day = tomorrow.getDate(); const tomorrowStr = `${month}-${day}`; - + // ----- 生成今天的时间列表 ----- const todayTimelist = [{ timestr: '自动送达' }]; - + const currentHour = now.getHours(); const currentMinute = now.getMinutes(); - + // 计算下一个半小时点 let nextHour = currentHour; let nextMinute = 30; @@ -663,7 +766,7 @@ nextHour = currentHour + 1; nextMinute = 0; } - + // 从下一个半小时点开始,直到 23:30 for (let h = nextHour; h <= 23; h++) { const startMin = (h === nextHour) ? nextMinute : 0; @@ -675,7 +778,7 @@ }); } } - + // ----- 生成明天的时间列表(全天 00:00 ~ 23:30)----- const tomorrowTimelist = []; for (let h = 0; h <= 23; h++) { @@ -687,7 +790,7 @@ }); } } - + this.content = [{ timezh: todayStr, timelist: todayTimelist @@ -805,10 +908,10 @@ .pintuan-left-price { width: 55%; - text-align: right; - font-weight: 700; - color: #000; - display: flex; + text-align: right; + font-weight: 700; + color: #000; + display: flex; } .goods-content-bottom { @@ -816,7 +919,8 @@ line-height: 28px; color: #777; } - .address-box{ + + .address-box { background: #fff; height: 40px; line-height: 40px; @@ -824,13 +928,15 @@ font-weight: 700; padding: 0 20px; } - .time-box{ + + .time-box { background: #fff; display: flex; height: 70px; padding: 10px; } - .time1{ + + .time1 { height: 50px; flex: 1; border-radius: 10px; @@ -839,6 +945,7 @@ line-height: 20px; padding-top: 5px; } + .radio-check { background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1)); width: 24px; @@ -848,7 +955,7 @@ line-height: 24px; margin: 0 10px 0 0; } - + .radio-no-check { width: 24px; height: 24px; @@ -856,6 +963,7 @@ border: 1px solid #eee; margin: 0 10px 0 0; } + .buy-bottom { position: fixed; bottom: 0; @@ -867,7 +975,7 @@ z-index: 99; box-shadow: 0 -10px 15px rgba(0, 0, 0, 0.3); } - + .bottom-btn { width: 90%; height: 50px; @@ -879,6 +987,7 @@ border-radius: 50px; margin: 10px auto; } + .btn { width: 95%; height: 50px; @@ -890,65 +999,158 @@ text-align: center; margin: 20px auto 0; } - .ziqu-box{ + + .ziqu-box { background: #eee; - width: 90%; - margin: 0 auto; - border-radius: 10px; - position: relative; - overflow: hidden; + width: 90%; + margin: 0 auto; + border-radius: 10px; + position: relative; + overflow: hidden; } - .ziqu-xuanfu{ + + .ziqu-xuanfu { position: absolute; - top: 0; - right: 0; - padding: 5px 10px; - background: rgba(166, 255, 234, 1); - border-top-right-radius: 10px; - border-bottom-left-radius: 10px; - font-weight: 700; - font-size: 10px; - } - .ziqu-address{ - display: flex; - height: 50px; - background: #fff; - width: 90%; - border-radius: 10px; - font-size: 13px; - margin: 30px auto 0; - font-weight: bold; - line-height: 50px; - img{ - width: 20px; - height: 20px; - margin: 15px 10px 0 15px; - } + top: 0; + right: 0; + padding: 5px 10px; + background: rgba(166, 255, 234, 1); + border-top-right-radius: 10px; + border-bottom-left-radius: 10px; + font-weight: 700; + font-size: 10px; } - .ziqu-time-box{ - width: 90%; - margin: 10px auto; - display: flex; - font-weight: 700; + + .ziqu-address { + display: flex; + height: 50px; + background: #fff; + width: 90%; + border-radius: 10px; + font-size: 13px; + margin: 30px auto 0; + font-weight: bold; + line-height: 50px; + + img { + width: 20px; + height: 20px; + margin: 15px 10px 0 15px; + } } - .ziqu-call-box{ + + .ziqu-time-box { + width: 90%; + margin: 10px auto; + display: flex; + font-weight: 700; + } + + .ziqu-call-box { width: 90%; display: flex; height: 35px; line-height: 35px; margin: 0 auto 10px; } - .ziqu-call{ - flex: 1; + + .ziqu-call { + flex: 1; } - .book-popup-content{ + + .book-popup-content { position: relative; height: 600px; width: 100%; padding: 10px; overflow: scroll; } - .vue-ref{ + + .vue-ref { border-radius: 10px !important; } - + + .pintuan-popup { + background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/780a024aefb7431ba21cf16efc8a482e.png') no-repeat; + background-size: 100%; + width: 300px; + height: 480px; + position: relative; + } + + .kaituan1 { + height: 60px; + font-size: 22px; + font-weight: 700; + margin-top: 10px; + } + + .kaituan1-title { + position: relative; + text-align: center; + + img { + width: 60px; + height: 11px; + position: absolute; + bottom: 0; + right: 125px; + } + } + + .kaituan1-title1 { + font-size: 15px; + height: 30px; + line-height: 30px; + text-align: center; + } + + .kaituan2 { + display: flex; + width: 90%; + margin: 20px auto; + } + + .kaituan22 { + flex: 1; + } + + .kaituan3 { + height: 40px; + line-height: 40px; + text-align: center; + color: #777; + } + + .kaituan4 { + width: 85%; + height: 50px; + background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1)); + border-radius: 50px; + text-align: center; + line-height: 50px; + font-size: 15px; + font-weight: 700; + margin: 10px auto; + } + + .kaituan5 { + margin: 20px 0 20px; + } + + .weipincheng { + width: 45px; + height: 45px; + background: rgba(166, 255, 234, 0.24); + border-radius: 45px; + text-align: center; + font-size: 60rpx; + font-weight: 700; + margin-left: -6rpx; + z-index: 97; + color: #02fbdd; + border: 1px solid #a6ffea; + line-height: 40px; + margin: 0 auto; + } + \ No newline at end of file