diff --git a/package1/address/addressList.vue b/package1/address/addressList.vue index 4f8d3d0..98d8d1c 100644 --- a/package1/address/addressList.vue +++ b/package1/address/addressList.vue @@ -47,16 +47,16 @@ - + - + - + - + 设为默认地址 @@ -231,6 +231,29 @@ this.areaSearchInput = title; this.closeAreaPopup(); }, + onFloorInput(e) { + const value = (e.detail.value || '').toString(); + const hasMinus = value.charAt(0) === '-'; + let nextValue = value.replace(/[^\d-]/g, '').replace(/-/g, ''); + if (hasMinus) nextValue = '-' + nextValue; + this.addressForm.floor = nextValue; + return nextValue; + }, + onRoomNumInput(e) { + const nextValue = (e.detail.value || '').toString().slice(0, 30); + this.addressForm.roomNum = nextValue; + return nextValue; + }, + onReceiverNameInput(e) { + const nextValue = (e.detail.value || '').toString().slice(0, 20); + this.addressForm.receiverName = nextValue; + return nextValue; + }, + onReceiverPhoneInput(e) { + const nextValue = (e.detail.value || '').toString().replace(/\D/g, '').slice(0, 11); + this.addressForm.receiverPhone = nextValue; + return nextValue; + }, submitAddress() { if(this.areaTitleInput) { let match = this.areaList.find(a => a.title === this.areaTitleInput); @@ -242,11 +265,17 @@ } } if(!this.addressForm.areaId) return this.tui.toast('请搜索并选择楼座'); - if(!this.addressForm.floor) return this.tui.toast('请填写所在楼层'); + this.addressForm.floor = (this.addressForm.floor || '').toString(); + this.addressForm.roomNum = (this.addressForm.roomNum || '').toString().trim(); + this.addressForm.receiverName = (this.addressForm.receiverName || '').toString().trim(); + this.addressForm.receiverPhone = (this.addressForm.receiverPhone || '').toString().replace(/\D/g, ''); + if(!this.addressForm.floor) return this.tui.toast('请填写所在楼层,楼层必须为整数数字'); if(!/^-?\d+$/.test(this.addressForm.floor)) return this.tui.toast('楼层必须为整数'); - if(!this.addressForm.roomNum) return this.tui.toast('请填写详细地址门牌号'); - if(!this.addressForm.receiverName) return this.tui.toast('请填写收件人'); - if(!this.addressForm.receiverPhone) return this.tui.toast('请填写联系电话'); + if(!this.addressForm.roomNum) return this.tui.toast('请填写详细地址门牌号最多30字'); + if(this.addressForm.roomNum.length > 30) return this.tui.toast('详细地址最多30字'); + if(!this.addressForm.receiverName) return this.tui.toast('请填写收件人最多20字'); + if(this.addressForm.receiverName.length > 20) return this.tui.toast('收货人名字最多20字'); + if(!this.addressForm.receiverPhone) return this.tui.toast('请输入有效的11位手机号码'); if(!/^1[3-9]\d{9}$/.test(this.addressForm.receiverPhone)) return this.tui.toast('请输入有效的11位手机号码'); let url = this.addressForm.id ? "/app/userAddress/edit" : "/app/userAddress/save"; diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue index 04d8ce5..a199918 100644 --- a/package1/buyFood/buyFood.vue +++ b/package1/buyFood/buyFood.vue @@ -244,6 +244,21 @@ + + + 优惠券 + + + -¥{{selectedCoupon.discountAmount.toFixed(2)}} + + + 有 {{availableCoupons.length}} 张可用 + + + 无可用券 + + + 打包费 @@ -301,21 +316,7 @@ - - - 优惠券 - - - -¥{{selectedCoupon.discountAmount.toFixed(2)}} - - - 有 {{availableCoupons.length}} 张可用 - - - 无可用券 - - - + 合计 @@ -383,7 +384,7 @@ - + @@ -574,7 +575,8 @@ selectedCoupon: null, addressBookVisible: false, freeOrderEffectVisible: false, - freeOrderAmount: '0.00' + freeOrderAmount: '0.00', + navigatingFromPayPopup: false } }, components: { @@ -807,6 +809,24 @@ this.commissionInputValue = value; return value; }, + onPayPopupChange(e) { + if (!e.show && this.currentOrderId && !this.navigatingFromPayPopup) { + this.goPayOrderDetail(); + } + }, + goPayOrderDetail() { + if (!this.currentOrderId) return; + this.navigatingFromPayPopup = true; + uni.redirectTo({ + url: '/package1/order/orderDetail?id=' + this.currentOrderId + }); + }, + goPayOrderConfirm() { + this.navigatingFromPayPopup = true; + uni.redirectTo({ + url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount + }); + }, confirmCommission() { const value = this.formatCommissionValue(this.commissionInputValue); this.customCommission = value; @@ -1062,9 +1082,7 @@ that.handlePaymentSuccess(); }, fail: function(err) { - uni.redirectTo({ - url: '/package1/order/orderDetail?id=' + that.currentOrderId - }); + that.goPayOrderDetail(); } }); } else { @@ -1073,6 +1091,7 @@ that.tui.request( `/hiver/order/payMallOrderSuccess?orderId=${that.currentOrderId}&workerId=${that.assignedWorker ? that.assignedWorker.workerId : ''}`, "POST", {}, false, false).then(res2 => { + that.navigatingFromPayPopup = true; that.$refs.payPopup.close(); uni.showToast({ title: '支付成功(模拟)', @@ -1097,10 +1116,9 @@ }) }, handlePaymentSuccess() { + this.navigatingFromPayPopup = true; if (!this.isGroupBuy) { - uni.redirectTo({ - url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount - }); + this.goPayOrderConfirm(); } else { let isInitiating = !this.groupItem.groupId; let isJoining = !!this.groupItem.groupId; @@ -1109,17 +1127,13 @@ this.$refs.pintuanPopup.open('center'); return; } else if (isJoining) { - uni.redirectTo({ - url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount - }); + this.goPayOrderConfirm(); } } }, onPintuanPopupChange(e) { if(!e.show){ - uni.redirectTo({ - url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount - }); + this.goPayOrderConfirm(); } }, getMustFinishTime() { @@ -1212,6 +1226,7 @@ let mft = this.getMustFinishTime(); if (mft) payload.mustFinishTime = mft; + payload.appointmentDelivery = deliveryType === 1 && this.formData.isImmediately === false ? 1 : 0; if (deliveryType === 1 && !isJoiningFaceToFace) { payload.addressId = this.formData.address ? this.formData.address.id : null; @@ -1286,6 +1301,7 @@ this.backendTotalAmount = totalAmount; this.currentOrderId = orderId; this.createdOrderInfo = res.result; + this.navigatingFromPayPopup = false; if(res.result.isFreeOrder == 1){ this.showFreeOrderEffect(res.result); } diff --git a/package1/ieBrowser/chat.vue b/package1/ieBrowser/chat.vue index cb22142..97ca118 100644 --- a/package1/ieBrowser/chat.vue +++ b/package1/ieBrowser/chat.vue @@ -77,6 +77,7 @@ {{ item.mediaDuration || 1 }}'' {{ item.content }} + {{ item.displayTime }} {{ messageStatusText(item) }} @@ -511,8 +512,44 @@ } return item.localOnly }) + locals.forEach(item => { + if (!item.messageTime) item.messageTime = this.pickMessageTime(item) + if (!item.displayTime) item.displayTime = this.formatMessageTime(item.messageTime) + }) return remote.concat(locals) }, + pickMessageTime(item) { + if (!item) return '' + return item.createTime || item.createdTime || item.sendTime || item.sentTime || item.messageTime || + item.createdAt || item.createAt || item.updateTime || '' + }, + parseMessageTime(value) { + if (!value) return 0 + if (typeof value === 'number') { + const time = value < 10000000000 ? value * 1000 : value + return Number.isNaN(time) ? 0 : time + } + const text = String(value) + let time = new Date(text).getTime() + if (Number.isNaN(time)) { + time = new Date(text.replace(/-/g, '/')).getTime() + } + return Number.isNaN(time) ? 0 : time + }, + formatMessageTime(value) { + const time = this.parseMessageTime(value) + if (!time) return '' + const date = new Date(time) + const now = new Date() + const timeText = `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}` + const dayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime() + const msgDayStart = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() + if (msgDayStart === dayStart) return timeText + if (msgDayStart === dayStart - 24 * 60 * 60 * 1000) return `昨天 ${timeText}` + const dateText = `${date.getMonth() + 1}/${date.getDate()}` + if (date.getFullYear() === now.getFullYear()) return `${dateText} ${timeText}` + return `${date.getFullYear()}/${dateText} ${timeText}` + }, messageStatusText(item) { if (!item || !item.mine) return '' if (item.blocked) return item.blockTip || '内容未通过审核,请换一个更合适的内容' @@ -541,6 +578,7 @@ const messageId = item.id || item.messageId const clientMsgId = item.clientMsgId || '' const mine = item.mine !== undefined && item.mine !== null ? item.mine : (currentUserId && String(item.senderId) === currentUserId) + const messageTime = this.pickMessageTime(item) return { domId: 'msg-' + (messageId || clientMsgId || Date.now() + '-' + Math.random().toString(16).slice(2)), messageId, @@ -557,6 +595,9 @@ blockTip: item.auditTip || (item.isBlocked === 1 ? '内容未通过审核,请换一个更合适的内容' : ''), localState: '', localOnly: false, + createAt: item.createAt, + messageTime, + displayTime: this.formatMessageTime(messageTime), mediaAuditStatus: item.mediaAuditStatus || 0 } }, @@ -701,6 +742,8 @@ local.poster = remote.poster || local.poster || '' local.localOnly = false local.localState = '' + local.messageTime = remote.messageTime || local.messageTime + local.displayTime = remote.displayTime || local.displayTime if (local.messageType === 1 || local.messageType === 3) local.content = remote.content || local.content this.saveLocalMessages() if (!wasBlocked && local.blocked && local.mine) { @@ -711,7 +754,7 @@ normalizePage(page) { if (!page) return [] const records = Array.isArray(page) ? page : (page.records || []) - return records.map(this.normalizeMessage).reverse() + return records.map(item => this.normalizeMessage(item)).reverse() }, async loadLatestMessages() { if (!this.roomId) return @@ -885,6 +928,7 @@ // 同一毫秒内连续发送(如连点表情)必须保证 clientMsgId 唯一,否则 ACK 会串消息 this.msgSeq = (this.msgSeq || 0) + 1 const clientMsgId = 'm-' + Date.now() + '-' + this.msgSeq + const createAt = Date.now() this.messages.push({ domId: 'msg-' + clientMsgId, clientMsgId, @@ -900,7 +944,9 @@ blockTip: '', localState: media.localState || 'sending', localOnly: true, - createAt: Date.now(), + createAt, + messageTime: createAt, + displayTime: this.formatMessageTime(createAt), mediaAuditStatus: media.mediaAuditStatus || 0 }) this.saveLocalMessages() @@ -962,6 +1008,11 @@ msg.blocked = ack.isBlocked === 1 msg.localOnly = false msg.localState = '' + const messageTime = this.pickMessageTime(ack) + if (messageTime) { + msg.messageTime = messageTime + msg.displayTime = this.formatMessageTime(messageTime) + } if (msg.blocked) { if (msg.messageType === 1) msg.content = '这句话没有送出,请换一种更温柔的说法。' msg.blockTip = ack.auditTip || '内容未通过审核,请换一个更合适的内容' @@ -1577,19 +1628,7 @@ this.applyAck(msg) return } - this.messages.push({ - domId: 'msg-' + (msg.messageId || Date.now()), - messageId: msg.messageId, - clientMsgId: msg.clientMsgId, - messageType: msg.messageType || 1, - mediaDuration: msg.mediaDuration, - mediaSize: msg.mediaSize, - mediaFormat: msg.mediaFormat, - poster: msg.poster || '', - mediaAuditStatus: msg.mediaAuditStatus || 0, - content: msg.content, - mine: String(msg.senderId || '') === String(uni.getStorageSync('id') || '') - }) + this.messages.push(this.normalizeMessage(msg)) this.scrollToBottom() }) ieSocket.onPresence((event) => { @@ -2074,6 +2113,13 @@ background: rgba(255, 228, 236, .82); } + .message-time { + margin-top: 8rpx; + color: rgba(22, 27, 46, 0.34); + font-size: 19rpx; + line-height: 28rpx; + } + .image-bubble { padding: 8rpx; background: rgba(255, 255, 255, 0.72); diff --git a/package1/order/orderDetail.vue b/package1/order/orderDetail.vue index 5c7dee8..19e38c4 100644 --- a/package1/order/orderDetail.vue +++ b/package1/order/orderDetail.vue @@ -268,6 +268,10 @@ X{{item3.quantity}} ¥{{item3.price}} + + 餐盒费 + ¥{{item3.packageFee}} + @@ -363,6 +367,15 @@ ¥{{orderDetail.packageFee == undefined ? '' : orderDetail.packageFee}} + + + 锦鲤免单 + + + ¥{{orderDetail.freeAmount == undefined ? '' : orderDetail.freeAmount}} + + @@ -534,7 +547,7 @@ + v-if="orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.finishTime"> 送达时间 @@ -542,6 +555,15 @@ {{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达' | formatTime}} + + + 预计送达时间 + + + {{orderDetail.deliveryInfo.mustFinishTime ? orderDetail.deliveryInfo.mustFinishTime : '尽快送达' | formatTime}} + + @@ -891,7 +913,7 @@ const minute = String(date.getMinutes()).padStart(2, '0'); // 拼接格式:日-日-时:分 - return `${day}日${hour}:${minute}`; + return `${hour}:${minute}`; }, formatTime(value) { if (!value) return ''; diff --git a/package1/order/returnOrder.vue b/package1/order/returnOrder.vue index 2f75abe..8fd0cdf 100644 --- a/package1/order/returnOrder.vue +++ b/package1/order/returnOrder.vue @@ -190,11 +190,13 @@ {{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达' | formatTime}} - - 售后原因 - - - 申请售后¥{{returnData.refundAmount}} + + + 售后原因 + + + 申请售后¥{{refundShowAmount}} + @@ -291,10 +293,12 @@ returnData: { reason: '', pictures: '', - refundAmount: 0 + refundAmount: 0, + refundType: 1 }, reasonOptions: ['配送超时', '收到的商品少了', '骑手送错地址', '收到的商品错了', '商家出餐超时', '餐品损坏或撒了', '商品质量问题'], selectedReasonOptions: [], + refundShowAmount: 0, popupPageStyle: '', payData: {}, orderDetail: {}, @@ -369,6 +373,8 @@ onLoad(option) { if (option.order) { this.orderDetail = JSON.parse(decodeURIComponent(option.order)); + this.normalizeOrderCouponAmount() + this.updateRefundShowAmount() } }, onShow() { @@ -404,6 +410,7 @@ this.returnData.refundTypeStatus = 3 } this.changeProduct() + this.updateRefundShowAmount() }, toggleReasonOption(item) { let index = this.selectedReasonOptions.indexOf(item); @@ -424,6 +431,60 @@ } } }, + toAmount(value) { + let num = Number(value) + return isNaN(num) ? 0 : num + }, + getCouponAmount() { + if (this.toAmount(this.orderDetail.userCouponNum) > 0) { + return this.toAmount(this.orderDetail.userCouponNum) + } + if (this.orderDetail.userCoupon && this.orderDetail.userCoupon.length > 0) { + let couponAmount = 0 + for (let i = 0; i < this.orderDetail.userCoupon.length; i++) { + couponAmount += this.toAmount(this.orderDetail.userCoupon[i].discountAmount) + } + return couponAmount + } + if (this.toAmount(this.orderDetail.couponDiscountFee) > 0) { + return this.toAmount(this.orderDetail.couponDiscountFee) + } + return 0 + }, + normalizeOrderCouponAmount() { + if (this.toAmount(this.orderDetail.userCouponNum) > 0) { + return + } + if (this.orderDetail.userCoupon && this.orderDetail.userCoupon.length > 0) { + let couponAmount = 0 + for (let i = 0; i < this.orderDetail.userCoupon.length; i++) { + couponAmount += this.toAmount(this.orderDetail.userCoupon[i].discountAmount) + } + this.orderDetail.userCouponNum = Number(couponAmount.toFixed(2)) + } else if (this.toAmount(this.orderDetail.couponDiscountFee) > 0) { + this.orderDetail.userCouponNum = this.toAmount(this.orderDetail.couponDiscountFee) + } + }, + getRefundRatio() { + let couponAmount = this.getCouponAmount() + let freeAmount = this.toAmount(this.orderDetail.freeAmount) + if (couponAmount <= 0 && freeAmount <= 0) { + return 0 + } + let allAmount = this.toAmount(this.orderDetail.totalAmount) + couponAmount + freeAmount + if (allAmount <= 0) { + return 0 + } + return Number(((couponAmount + freeAmount) / allAmount).toFixed(4)) + }, + updateRefundShowAmount() { + let refundAmount = this.toAmount(this.returnData.refundAmount) + if (this.sellTime == 0 || this.sellTime == 1 || this.returnData.refundType == 1 || this.returnData.refundType == 2) { + let ratio = this.getRefundRatio() + refundAmount = refundAmount - refundAmount * ratio + } + this.refundShowAmount = Number(refundAmount.toFixed(2)) + }, pictureAdd(id, huan) { let that = this uni.chooseMedia({ @@ -488,13 +549,20 @@ for (let i = 0; i < this.orderDetail.goodsList.length; i++) { if (this.orderDetail.goodsList[i].returnCount) { this.orderDetail.goodsList[i].quantity = this.orderDetail.goodsList[i].returnCount - if (this.orderDetail.deliveryType == 1) { + /* if (this.orderDetail.deliveryType == 1) { this.orderDetail.goodsList[i].price = Number(this.orderDetail.goodsList[i].price) + Number(this .orderDetail.goodsList[i].packageFee) - } + } */ this.returnData.items.push(this.orderDetail.goodsList[i]) } } + if (this.returnData.refundType == 1 && this.returnData.items.length == 0) { + uni.showToast({ + title: '请选择需要售后的商品', + icon: 'none' + }); + return; + } uni.showLoading({ title: '提交售后中...' }); @@ -537,23 +605,25 @@ .quantity) { this.orderDetail.goodsList[index].returnCount += 1 if (this.orderDetail.deliveryType == 1) { - this.returnData.refundAmount += Number(Number(this.orderDetail.goodsList[index].price + this - .orderDetail.goodsList[index].packageFee).toFixed(2)) + this.returnData.refundAmount += Number((this.toAmount(this.orderDetail.goodsList[index].price) + this + .toAmount(this.orderDetail.goodsList[index].packageFee)).toFixed(2)) } else { - this.returnData.refundAmount += Number(this.orderDetail.goodsList[index].price) + this.returnData.refundAmount += this.toAmount(this.orderDetail.goodsList[index].price) } this.returnData.refundAmount = Number(this.returnData.refundAmount.toFixed(2)) + this.updateRefundShowAmount() } } else { if (this.orderDetail.goodsList[index].returnCount > 0) { if (this.orderDetail.deliveryType == 1) { - this.returnData.refundAmount -= Number(Number(this.orderDetail.goodsList[index].price + this - .orderDetail.goodsList[index].packageFee).toFixed(2)) + this.returnData.refundAmount -= Number((this.toAmount(this.orderDetail.goodsList[index].price) + this + .toAmount(this.orderDetail.goodsList[index].packageFee)).toFixed(2)) } else { - this.returnData.refundAmount -= Number(this.orderDetail.goodsList[index].price) + this.returnData.refundAmount -= this.toAmount(this.orderDetail.goodsList[index].price) } this.returnData.refundAmount = Number(this.returnData.refundAmount.toFixed(2)) + this.updateRefundShowAmount() } this.orderDetail.goodsList[index].returnCount = this.orderDetail.goodsList[index].returnCount > 0 ? this.orderDetail.goodsList[index].returnCount -= 1 : 0 @@ -1111,4 +1181,31 @@ text-align: center; margin: 40rpx auto; } + + .action-row { + display: flex; + align-items: center; + gap: 20rpx; + margin: 36rpx auto 10rpx; + } + + .action-row .btn { + flex: 1; + width: auto; + height: 88rpx; + line-height: 88rpx; + margin: 0; + font-size: 28rpx; + box-sizing: border-box; + } + + .action-row .secondary-btn { + background: #fff; + border: 2rpx solid rgba(0, 35, 28, 0.12); + color: #243f38; + } + + .action-row .primary-btn { + color: #00231C; + } \ No newline at end of file