wangfukang 1 month ago
parent
commit
e48af574e3
  1. 45
      package1/address/addressList.vue
  2. 74
      package1/buyFood/buyFood.vue
  3. 76
      package1/ieBrowser/chat.vue
  4. 26
      package1/order/orderDetail.vue
  5. 125
      package1/order/returnOrder.vue

45
package1/address/addressList.vue

@ -47,16 +47,16 @@
<uni-icons type="right" size="16" color="#999"></uni-icons> <uni-icons type="right" size="16" color="#999"></uni-icons>
</view> </view>
<view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;"> <view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;">
<input type="number" v-model="addressForm.floor" placeholder="请填写所在楼层(仅限整数)" style="width: 100%;" /> <input type="text" v-model="addressForm.floor" @input="onFloorInput" placeholder="请填写所在楼层(仅限整数)" style="width: 100%;" />
</view> </view>
<view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;"> <view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;">
<input type="text" v-model="addressForm.roomNum" placeholder="请填写门牌号或所在机构科室" style="width: 100%;" /> <input type="text" maxlength="30" v-model="addressForm.roomNum" @input="onRoomNumInput" placeholder="请填写门牌号或所在机构科室" style="width: 100%;" />
</view> </view>
<view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;"> <view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;">
<input type="text" v-model="addressForm.receiverName" placeholder="收货人名字" style="width: 100%;" /> <input type="text" maxlength="20" v-model="addressForm.receiverName" @input="onReceiverNameInput" placeholder="收货人名字" style="width: 100%;" />
</view> </view>
<view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;"> <view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;">
<input type="number" maxlength="11" v-model="addressForm.receiverPhone" placeholder="联系电话" style="width: 100%;" /> <input type="number" maxlength="11" v-model="addressForm.receiverPhone" @input="onReceiverPhoneInput" placeholder="联系电话" style="width: 100%;" />
</view> </view>
<view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;justify-content: space-between;align-items: center;"> <view style="margin-bottom: 20rpx;display: flex;padding: 20rpx;justify-content: space-between;align-items: center;">
<text>设为默认地址</text> <text>设为默认地址</text>
@ -231,6 +231,29 @@
this.areaSearchInput = title; this.areaSearchInput = title;
this.closeAreaPopup(); 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() { submitAddress() {
if(this.areaTitleInput) { if(this.areaTitleInput) {
let match = this.areaList.find(a => a.title === 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.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(!/^-?\d+$/.test(this.addressForm.floor)) return this.tui.toast('楼层必须为整数');
if(!this.addressForm.roomNum) return this.tui.toast('请填写详细地址门牌号'); if(!this.addressForm.roomNum) return this.tui.toast('请填写详细地址门牌号最多30字');
if(!this.addressForm.receiverName) return this.tui.toast('请填写收件人'); if(this.addressForm.roomNum.length > 30) return this.tui.toast('详细地址最多30字');
if(!this.addressForm.receiverPhone) return this.tui.toast('请填写联系电话'); 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位手机号码'); 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"; let url = this.addressForm.id ? "/app/userAddress/edit" : "/app/userAddress/save";

74
package1/buyFood/buyFood.vue

@ -244,6 +244,21 @@
</block> </block>
<view class="fee-list"> <view class="fee-list">
<view class="coupon-row" @tap="openCouponPopup">
<view class="coupon-label">
优惠券
</view>
<view class="coupon-discount" v-if="selectedCoupon">
-{{selectedCoupon.discountAmount.toFixed(2)}}
</view>
<view class="coupon-available" v-else-if="availableCoupons.length > 0">
{{availableCoupons.length}} 张可用
</view>
<view class="coupon-empty" v-else>
无可用券
</view>
<uni-icons type="right" size="14" color="#999" style="margin-left:10rpx;"></uni-icons>
</view>
<view class="fee-row" v-if="isPaotui"> <view class="fee-row" v-if="isPaotui">
<view class="fee-label"> <view class="fee-label">
打包费 打包费
@ -301,21 +316,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="coupon-row" @tap="openCouponPopup">
<view class="coupon-label">
优惠券
</view>
<view class="coupon-discount" v-if="selectedCoupon">
-{{selectedCoupon.discountAmount.toFixed(2)}}
</view>
<view class="coupon-available" v-else-if="availableCoupons.length > 0">
{{availableCoupons.length}} 张可用
</view>
<view class="coupon-empty" v-else>
无可用券
</view>
<uni-icons type="right" size="14" color="#999" style="margin-left:10rpx;"></uni-icons>
</view>
<view class="total-row"> <view class="total-row">
<view class="total-label"> <view class="total-label">
合计 合计
@ -383,7 +384,7 @@
</view> </view>
</uni-popup> </uni-popup>
<!-- 支付弹出层 --> <!-- 支付弹出层 -->
<uni-popup ref="payPopup" background-color="#fff"> <uni-popup ref="payPopup" background-color="#fff" @change="onPayPopupChange">
<view class="pay-popup"> <view class="pay-popup">
<view class="content"> <view class="content">
<view class="box1"> <view class="box1">
@ -574,7 +575,8 @@
selectedCoupon: null, selectedCoupon: null,
addressBookVisible: false, addressBookVisible: false,
freeOrderEffectVisible: false, freeOrderEffectVisible: false,
freeOrderAmount: '0.00' freeOrderAmount: '0.00',
navigatingFromPayPopup: false
} }
}, },
components: { components: {
@ -807,6 +809,24 @@
this.commissionInputValue = value; this.commissionInputValue = value;
return 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() { confirmCommission() {
const value = this.formatCommissionValue(this.commissionInputValue); const value = this.formatCommissionValue(this.commissionInputValue);
this.customCommission = value; this.customCommission = value;
@ -1062,9 +1082,7 @@
that.handlePaymentSuccess(); that.handlePaymentSuccess();
}, },
fail: function(err) { fail: function(err) {
uni.redirectTo({ that.goPayOrderDetail();
url: '/package1/order/orderDetail?id=' + that.currentOrderId
});
} }
}); });
} else { } else {
@ -1073,6 +1091,7 @@
that.tui.request( that.tui.request(
`/hiver/order/payMallOrderSuccess?orderId=${that.currentOrderId}&workerId=${that.assignedWorker ? that.assignedWorker.workerId : ''}`, `/hiver/order/payMallOrderSuccess?orderId=${that.currentOrderId}&workerId=${that.assignedWorker ? that.assignedWorker.workerId : ''}`,
"POST", {}, false, false).then(res2 => { "POST", {}, false, false).then(res2 => {
that.navigatingFromPayPopup = true;
that.$refs.payPopup.close(); that.$refs.payPopup.close();
uni.showToast({ uni.showToast({
title: '支付成功(模拟)', title: '支付成功(模拟)',
@ -1097,10 +1116,9 @@
}) })
}, },
handlePaymentSuccess() { handlePaymentSuccess() {
this.navigatingFromPayPopup = true;
if (!this.isGroupBuy) { if (!this.isGroupBuy) {
uni.redirectTo({ this.goPayOrderConfirm();
url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount
});
} else { } else {
let isInitiating = !this.groupItem.groupId; let isInitiating = !this.groupItem.groupId;
let isJoining = !!this.groupItem.groupId; let isJoining = !!this.groupItem.groupId;
@ -1109,17 +1127,13 @@
this.$refs.pintuanPopup.open('center'); this.$refs.pintuanPopup.open('center');
return; return;
} else if (isJoining) { } else if (isJoining) {
uni.redirectTo({ this.goPayOrderConfirm();
url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount
});
} }
} }
}, },
onPintuanPopupChange(e) { onPintuanPopupChange(e) {
if(!e.show){ if(!e.show){
uni.redirectTo({ this.goPayOrderConfirm();
url: '/package1/order/orderConfirm?id=' + this.currentOrderId + '&amount=' + this.backendTotalAmount
});
} }
}, },
getMustFinishTime() { getMustFinishTime() {
@ -1212,6 +1226,7 @@
let mft = this.getMustFinishTime(); let mft = this.getMustFinishTime();
if (mft) payload.mustFinishTime = mft; if (mft) payload.mustFinishTime = mft;
payload.appointmentDelivery = deliveryType === 1 && this.formData.isImmediately === false ? 1 : 0;
if (deliveryType === 1 && !isJoiningFaceToFace) { if (deliveryType === 1 && !isJoiningFaceToFace) {
payload.addressId = this.formData.address ? this.formData.address.id : null; payload.addressId = this.formData.address ? this.formData.address.id : null;
@ -1286,6 +1301,7 @@
this.backendTotalAmount = totalAmount; this.backendTotalAmount = totalAmount;
this.currentOrderId = orderId; this.currentOrderId = orderId;
this.createdOrderInfo = res.result; this.createdOrderInfo = res.result;
this.navigatingFromPayPopup = false;
if(res.result.isFreeOrder == 1){ if(res.result.isFreeOrder == 1){
this.showFreeOrderEffect(res.result); this.showFreeOrderEffect(res.result);
} }

76
package1/ieBrowser/chat.vue

@ -77,6 +77,7 @@
<text>{{ item.mediaDuration || 1 }}''</text> <text>{{ item.mediaDuration || 1 }}''</text>
</view> </view>
<view class="bubble" v-else :class="{ muted: item.pending, blocked: item.blocked }">{{ item.content }}</view> <view class="bubble" v-else :class="{ muted: item.pending, blocked: item.blocked }">{{ item.content }}</view>
<view class="message-time" v-if="item.displayTime">{{ item.displayTime }}</view>
<view class="message-status" v-if="item.mine && messageStatusText(item)" :class="{ blocked: item.blocked }"> <view class="message-status" v-if="item.mine && messageStatusText(item)" :class="{ blocked: item.blocked }">
{{ messageStatusText(item) }} {{ messageStatusText(item) }}
</view> </view>
@ -511,8 +512,44 @@
} }
return item.localOnly 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) 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) { messageStatusText(item) {
if (!item || !item.mine) return '' if (!item || !item.mine) return ''
if (item.blocked) return item.blockTip || '内容未通过审核,请换一个更合适的内容' if (item.blocked) return item.blockTip || '内容未通过审核,请换一个更合适的内容'
@ -541,6 +578,7 @@
const messageId = item.id || item.messageId const messageId = item.id || item.messageId
const clientMsgId = item.clientMsgId || '' const clientMsgId = item.clientMsgId || ''
const mine = item.mine !== undefined && item.mine !== null ? item.mine : (currentUserId && String(item.senderId) === currentUserId) const mine = item.mine !== undefined && item.mine !== null ? item.mine : (currentUserId && String(item.senderId) === currentUserId)
const messageTime = this.pickMessageTime(item)
return { return {
domId: 'msg-' + (messageId || clientMsgId || Date.now() + '-' + Math.random().toString(16).slice(2)), domId: 'msg-' + (messageId || clientMsgId || Date.now() + '-' + Math.random().toString(16).slice(2)),
messageId, messageId,
@ -557,6 +595,9 @@
blockTip: item.auditTip || (item.isBlocked === 1 ? '内容未通过审核,请换一个更合适的内容' : ''), blockTip: item.auditTip || (item.isBlocked === 1 ? '内容未通过审核,请换一个更合适的内容' : ''),
localState: '', localState: '',
localOnly: false, localOnly: false,
createAt: item.createAt,
messageTime,
displayTime: this.formatMessageTime(messageTime),
mediaAuditStatus: item.mediaAuditStatus || 0 mediaAuditStatus: item.mediaAuditStatus || 0
} }
}, },
@ -701,6 +742,8 @@
local.poster = remote.poster || local.poster || '' local.poster = remote.poster || local.poster || ''
local.localOnly = false local.localOnly = false
local.localState = '' 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 if (local.messageType === 1 || local.messageType === 3) local.content = remote.content || local.content
this.saveLocalMessages() this.saveLocalMessages()
if (!wasBlocked && local.blocked && local.mine) { if (!wasBlocked && local.blocked && local.mine) {
@ -711,7 +754,7 @@
normalizePage(page) { normalizePage(page) {
if (!page) return [] if (!page) return []
const records = Array.isArray(page) ? page : (page.records || []) const records = Array.isArray(page) ? page : (page.records || [])
return records.map(this.normalizeMessage).reverse() return records.map(item => this.normalizeMessage(item)).reverse()
}, },
async loadLatestMessages() { async loadLatestMessages() {
if (!this.roomId) return if (!this.roomId) return
@ -885,6 +928,7 @@
// clientMsgId ACK // clientMsgId ACK
this.msgSeq = (this.msgSeq || 0) + 1 this.msgSeq = (this.msgSeq || 0) + 1
const clientMsgId = 'm-' + Date.now() + '-' + this.msgSeq const clientMsgId = 'm-' + Date.now() + '-' + this.msgSeq
const createAt = Date.now()
this.messages.push({ this.messages.push({
domId: 'msg-' + clientMsgId, domId: 'msg-' + clientMsgId,
clientMsgId, clientMsgId,
@ -900,7 +944,9 @@
blockTip: '', blockTip: '',
localState: media.localState || 'sending', localState: media.localState || 'sending',
localOnly: true, localOnly: true,
createAt: Date.now(), createAt,
messageTime: createAt,
displayTime: this.formatMessageTime(createAt),
mediaAuditStatus: media.mediaAuditStatus || 0 mediaAuditStatus: media.mediaAuditStatus || 0
}) })
this.saveLocalMessages() this.saveLocalMessages()
@ -962,6 +1008,11 @@
msg.blocked = ack.isBlocked === 1 msg.blocked = ack.isBlocked === 1
msg.localOnly = false msg.localOnly = false
msg.localState = '' msg.localState = ''
const messageTime = this.pickMessageTime(ack)
if (messageTime) {
msg.messageTime = messageTime
msg.displayTime = this.formatMessageTime(messageTime)
}
if (msg.blocked) { if (msg.blocked) {
if (msg.messageType === 1) msg.content = '这句话没有送出,请换一种更温柔的说法。' if (msg.messageType === 1) msg.content = '这句话没有送出,请换一种更温柔的说法。'
msg.blockTip = ack.auditTip || '内容未通过审核,请换一个更合适的内容' msg.blockTip = ack.auditTip || '内容未通过审核,请换一个更合适的内容'
@ -1577,19 +1628,7 @@
this.applyAck(msg) this.applyAck(msg)
return return
} }
this.messages.push({ this.messages.push(this.normalizeMessage(msg))
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.scrollToBottom() this.scrollToBottom()
}) })
ieSocket.onPresence((event) => { ieSocket.onPresence((event) => {
@ -2074,6 +2113,13 @@
background: rgba(255, 228, 236, .82); 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 { .image-bubble {
padding: 8rpx; padding: 8rpx;
background: rgba(255, 255, 255, 0.72); background: rgba(255, 255, 255, 0.72);

26
package1/order/orderDetail.vue

@ -268,6 +268,10 @@
<text>X{{item3.quantity}}</text> <text>X{{item3.quantity}}</text>
<text>{{item3.price}}</text> <text>{{item3.price}}</text>
</view> </view>
<view class="refund-goods-bottom" v-if="item3.packageFee != undefined && item3.packageFee > 0">
<text>餐盒费</text>
<text>{{item3.packageFee}}</text>
</view>
</view> </view>
</view> </view>
<view class="refund-info-row"> <view class="refund-info-row">
@ -363,6 +367,15 @@
{{orderDetail.packageFee == undefined ? '' : orderDetail.packageFee}} {{orderDetail.packageFee == undefined ? '' : orderDetail.packageFee}}
</view> </view>
</view> </view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;"
v-if="orderDetail.freeAmount != null && orderDetail.freeAmount > 0">
<view style="flex: 1;color: #ff6f2c;font-weight: 700;">
锦鲤免单
</view>
<view style="color: #ff6f2c;font-weight:700;">
{{orderDetail.freeAmount == undefined ? '' : orderDetail.freeAmount}}
</view>
</view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;" <view style="height: 80rpx;line-height: 80rpx;display: flex;"
v-if="orderDetail.deliveryType == 1"> v-if="orderDetail.deliveryType == 1">
<view style="flex: 1;color: #777;font-weight: 700;"> <view style="flex: 1;color: #777;font-weight: 700;">
@ -534,7 +547,7 @@
</view> </view>
</view> </view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;" <view style="height: 80rpx;line-height: 80rpx;display: flex;"
v-if="orderDetail.deliveryType == 1"> v-if="orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.finishTime">
<view style="flex: 1;color: #777;font-weight: 700;"> <view style="flex: 1;color: #777;font-weight: 700;">
送达时间 送达时间
</view> </view>
@ -542,6 +555,15 @@
{{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达' | formatTime}} {{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达' | formatTime}}
</view> </view>
</view> </view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;"
v-if="orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.finishTime == null">
<view style="flex: 1;color: #777;font-weight: 700;">
预计送达时间
</view>
<view style="color: #000;font-weight: 700;" v-if="orderDetail.deliveryInfo">
{{orderDetail.deliveryInfo.mustFinishTime ? orderDetail.deliveryInfo.mustFinishTime : '尽快送达' | formatTime}}
</view>
</view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;" <view style="height: 80rpx;line-height: 80rpx;display: flex;"
> >
<view style="flex: 1;color: #777;font-weight: 700;"> <view style="flex: 1;color: #777;font-weight: 700;">
@ -891,7 +913,7 @@
const minute = String(date.getMinutes()).padStart(2, '0'); const minute = String(date.getMinutes()).padStart(2, '0');
// --: // --:
return `${day}${hour}:${minute}`; return `${hour}:${minute}`;
}, },
formatTime(value) { formatTime(value) {
if (!value) return ''; if (!value) return '';

125
package1/order/returnOrder.vue

@ -190,11 +190,13 @@
{{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达' | formatTime}} {{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达' | formatTime}}
</view> </view>
</view> </view>
<view class="btn" @tap.stop="openReasonPopup"> <view class="action-row">
售后原因 <view class="btn secondary-btn" @tap.stop="openReasonPopup">
</view> 售后原因
<view class="btn" @tap.stop="submit()"> </view>
申请售后{{returnData.refundAmount}} <view class="btn primary-btn" @tap.stop="submit()">
申请售后{{refundShowAmount}}
</view>
</view> </view>
</view> </view>
</view> </view>
@ -291,10 +293,12 @@
returnData: { returnData: {
reason: '', reason: '',
pictures: '', pictures: '',
refundAmount: 0 refundAmount: 0,
refundType: 1
}, },
reasonOptions: ['配送超时', '收到的商品少了', '骑手送错地址', '收到的商品错了', '商家出餐超时', '餐品损坏或撒了', '商品质量问题'], reasonOptions: ['配送超时', '收到的商品少了', '骑手送错地址', '收到的商品错了', '商家出餐超时', '餐品损坏或撒了', '商品质量问题'],
selectedReasonOptions: [], selectedReasonOptions: [],
refundShowAmount: 0,
popupPageStyle: '', popupPageStyle: '',
payData: {}, payData: {},
orderDetail: {}, orderDetail: {},
@ -369,6 +373,8 @@
onLoad(option) { onLoad(option) {
if (option.order) { if (option.order) {
this.orderDetail = JSON.parse(decodeURIComponent(option.order)); this.orderDetail = JSON.parse(decodeURIComponent(option.order));
this.normalizeOrderCouponAmount()
this.updateRefundShowAmount()
} }
}, },
onShow() { onShow() {
@ -404,6 +410,7 @@
this.returnData.refundTypeStatus = 3 this.returnData.refundTypeStatus = 3
} }
this.changeProduct() this.changeProduct()
this.updateRefundShowAmount()
}, },
toggleReasonOption(item) { toggleReasonOption(item) {
let index = this.selectedReasonOptions.indexOf(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) { pictureAdd(id, huan) {
let that = this let that = this
uni.chooseMedia({ uni.chooseMedia({
@ -488,13 +549,20 @@
for (let i = 0; i < this.orderDetail.goodsList.length; i++) { for (let i = 0; i < this.orderDetail.goodsList.length; i++) {
if (this.orderDetail.goodsList[i].returnCount) { if (this.orderDetail.goodsList[i].returnCount) {
this.orderDetail.goodsList[i].quantity = 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 this.orderDetail.goodsList[i].price = Number(this.orderDetail.goodsList[i].price) + Number(this
.orderDetail.goodsList[i].packageFee) .orderDetail.goodsList[i].packageFee)
} } */
this.returnData.items.push(this.orderDetail.goodsList[i]) 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({ uni.showLoading({
title: '提交售后中...' title: '提交售后中...'
}); });
@ -537,23 +605,25 @@
.quantity) { .quantity) {
this.orderDetail.goodsList[index].returnCount += 1 this.orderDetail.goodsList[index].returnCount += 1
if (this.orderDetail.deliveryType == 1) { if (this.orderDetail.deliveryType == 1) {
this.returnData.refundAmount += Number(Number(this.orderDetail.goodsList[index].price + this this.returnData.refundAmount += Number((this.toAmount(this.orderDetail.goodsList[index].price) + this
.orderDetail.goodsList[index].packageFee).toFixed(2)) .toAmount(this.orderDetail.goodsList[index].packageFee)).toFixed(2))
} else { } 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.returnData.refundAmount = Number(this.returnData.refundAmount.toFixed(2))
this.updateRefundShowAmount()
} }
} else { } else {
if (this.orderDetail.goodsList[index].returnCount > 0) { if (this.orderDetail.goodsList[index].returnCount > 0) {
if (this.orderDetail.deliveryType == 1) { if (this.orderDetail.deliveryType == 1) {
this.returnData.refundAmount -= Number(Number(this.orderDetail.goodsList[index].price + this this.returnData.refundAmount -= Number((this.toAmount(this.orderDetail.goodsList[index].price) + this
.orderDetail.goodsList[index].packageFee).toFixed(2)) .toAmount(this.orderDetail.goodsList[index].packageFee)).toFixed(2))
} else { } 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.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 = this.orderDetail.goodsList[index].returnCount > 0 ?
this.orderDetail.goodsList[index].returnCount -= 1 : 0 this.orderDetail.goodsList[index].returnCount -= 1 : 0
@ -1111,4 +1181,31 @@
text-align: center; text-align: center;
margin: 40rpx auto; 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;
}
</style> </style>
Loading…
Cancel
Save