fix:修复bug
This commit is contained in:
+154
-87
@@ -4,7 +4,13 @@
|
||||
<view class="page-header">
|
||||
<view class="header-top">
|
||||
<view class="header-left">
|
||||
<view class="header-title">{{ getOrderStatusText() }}</view>
|
||||
<view class="header-title-row">
|
||||
<text class="header-title">{{ getOrderStatusText() }}</text>
|
||||
<!-- 优惠券/会员卡可用提示标签 -->
|
||||
<view v-if="orderInfo.orderStatus === 'in_used' && canUsePromotionTag" class="promotion-tag">
|
||||
{{ $t('order.canUsePromotion') }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="header-desc">{{ getStatusDesc() }}</view>
|
||||
</view>
|
||||
<view class="header-right" v-if="orderInfo.orderStatus === 'in_used'">
|
||||
@@ -78,6 +84,14 @@
|
||||
<view class="rent-label">{{ $t('order.paymentMethod') }}</view>
|
||||
<view class="rent-value">{{ getPayWayText() }}</view>
|
||||
</view>
|
||||
<!-- 优惠信息显示 - 订单完成且使用了优惠 -->
|
||||
<view class="rent-item" v-if="isOrderCompleted() && orderInfo.discountTypeName">
|
||||
<view class="rent-label">{{ $t('order.usedPromotion') }}</view>
|
||||
<view class="rent-value promotion-value">
|
||||
<image src="/static/promotion-icon.png" class="promotion-icon" mode="aspectFit"></image>
|
||||
{{ orderInfo.discountTypeName }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="rent-item" v-if="isOrderCompleted() && orderInfo.endTime">
|
||||
<view class="rent-label">{{ $t('order.returnTime') }}</view>
|
||||
<view class="rent-value">{{ orderInfo.endTime }}</view>
|
||||
@@ -94,7 +108,7 @@
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="" style="font-size: 24rpx;text-align: center;">
|
||||
产品归还入仓后,订单仍未结束,请前往<text @click="contactService" style="color:#07c160 ;">客服中心</text>联系工作人员。
|
||||
{{ $t('order.returnProblemTip') }}<text @click="contactService" style="color:#07c160 ;">{{ $t('user.customerService') }}</text>{{ $t('order.contactStaff') }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -209,8 +223,12 @@
|
||||
cancelOrder,
|
||||
reportDeviceNoEject,
|
||||
convertToOwned,
|
||||
closeWithMaxFee
|
||||
closeWithMaxFee,
|
||||
getInUseOrder
|
||||
} from '@/config/api/order.js'
|
||||
import {
|
||||
withdrawDeposit
|
||||
} from '@/config/api/user.js'
|
||||
import {
|
||||
addUserFeedback
|
||||
} from '@/config/api/feedback.js'
|
||||
@@ -222,7 +240,7 @@
|
||||
} from "@/config/url.js"
|
||||
import { useI18n } from '@/utils/i18n.js'
|
||||
|
||||
const { t: $t } = useI18n()
|
||||
const { t } = useI18n()
|
||||
const instance = getCurrentInstance()
|
||||
const $orderMonitor = instance?.proxy?.$orderMonitor || null
|
||||
|
||||
@@ -251,7 +269,12 @@
|
||||
isSupportExpressReturn: 'yes',
|
||||
freeRentTime: '',
|
||||
unitPrice: '',
|
||||
orderType: ''
|
||||
orderType: '',
|
||||
canUseMember: false,
|
||||
canUseCoupon: false,
|
||||
userMemberCardId: '',
|
||||
userPurchaseId: '',
|
||||
discountTypeName: ''
|
||||
})
|
||||
const timer = ref(null)
|
||||
const statusCheckTimer = ref(null)
|
||||
@@ -264,8 +287,28 @@
|
||||
const countdownRemaining = ref(0)
|
||||
const showExpressAction = ref(false)
|
||||
const countdownTimer = ref(null)
|
||||
const feeRuleText = ref('5.0元/60分钟 前15分钟内归还免费 不足60分钟按60分钟计费 封顶99元 持续计费至99元视为买断')
|
||||
const feeRuleText = ref('')
|
||||
const convertToOwnPopup = ref(null)
|
||||
|
||||
// 计算属性:是否显示优惠券/会员卡可用提示
|
||||
const canUsePromotionTag = computed(() => {
|
||||
return orderInfo.value.canUseMember === true || orderInfo.value.canUseCoupon === true
|
||||
})
|
||||
|
||||
// 计算属性:是否使用了优惠
|
||||
const hasUsedPromotion = computed(() => {
|
||||
return !!(orderInfo.value.userMemberCardId || orderInfo.value.userPurchaseId)
|
||||
})
|
||||
// 获取已使用优惠的文本
|
||||
const getUsedPromotionText = () => {
|
||||
if (orderInfo.value.userMemberCardId) {
|
||||
return t('user.myCards')
|
||||
} else if (orderInfo.value.userPurchaseId) {
|
||||
return t('user.myCoupons')
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
// 判断订单是否已完成
|
||||
const isOrderCompleted = () => {
|
||||
return orderInfo.value.orderStatus === 'used_done' ||
|
||||
@@ -275,27 +318,27 @@
|
||||
// 获取订单状态文字
|
||||
const getOrderStatusText = () => {
|
||||
const statusMap = {
|
||||
'waiting_for_payment': $t('order.waitingForPayment'),
|
||||
'payment_in_progress': $t('order.paymentInProgress'),
|
||||
'payment_successful': $t('order.paymentSuccess'),
|
||||
'in_used': $t('order.inUse'),
|
||||
'payment_failed': $t('order.paymentFailed'),
|
||||
'order_cancelled': $t('order.cancelled'),
|
||||
'used_done': $t('order.finished'),
|
||||
'used_down': $t('order.finished')
|
||||
'waiting_for_payment': t('order.waitingForPayment'),
|
||||
'payment_in_progress': t('order.paymentInProgress'),
|
||||
'payment_successful': t('order.paymentSuccess'),
|
||||
'in_used': t('order.inUse'),
|
||||
'payment_failed': t('order.paymentFailed'),
|
||||
'order_cancelled': t('order.cancelled'),
|
||||
'used_done': t('order.finished'),
|
||||
'used_down': t('order.finished')
|
||||
}
|
||||
return statusMap[orderInfo.value.orderStatus] || $t('order.orderDetail')
|
||||
return statusMap[orderInfo.value.orderStatus] || t('order.orderDetail')
|
||||
}
|
||||
|
||||
// 获取状态描述
|
||||
const getStatusDesc = () => {
|
||||
const descMap = {
|
||||
'waiting_for_payment': $t('order.pleasePaySoon'),
|
||||
'in_used': $t('order.pleaseReturnInTime'),
|
||||
'used_done': $t('order.returnedThankYou'),
|
||||
'used_down': $t('order.returnedThankYou'),
|
||||
'order_cancelled': $t('order.orderCancelled'),
|
||||
'payment_failed': $t('order.paymentFailedRetry')
|
||||
'waiting_for_payment': t('order.pleasePaySoon'),
|
||||
'in_used': t('order.pleaseReturnInTime'),
|
||||
'used_done': t('order.returnedThankYou'),
|
||||
'used_down': t('order.returnedThankYou'),
|
||||
'order_cancelled': t('order.orderCancelled'),
|
||||
'payment_failed': t('order.paymentFailedRetry')
|
||||
}
|
||||
return descMap[orderInfo.value.orderStatus] || ''
|
||||
}
|
||||
@@ -303,11 +346,11 @@
|
||||
// 获取支付方式文本
|
||||
const getPayWayText = () => {
|
||||
const payWayMap = {
|
||||
'wx_score_pay': $t('order.depositFree'),
|
||||
'wx_member_pay': $t('order.memberOrder'),
|
||||
'wx_pay': $t('order.depositPay')
|
||||
'wx_score_pay': t('order.depositFree'),
|
||||
'wx_member_pay': t('order.memberOrder'),
|
||||
'wx_pay': t('order.depositPay')
|
||||
}
|
||||
return payWayMap[orderInfo.value.payWay] || $t('order.depositFree')
|
||||
return payWayMap[orderInfo.value.payWay] || t('order.depositFree')
|
||||
}
|
||||
|
||||
// 获取免费时长显示
|
||||
@@ -321,13 +364,13 @@
|
||||
if (!orderInfo.value.unitPrice || !orderInfo.value.orderType) return '-'
|
||||
|
||||
const orderTypeMap = {
|
||||
'hours': $t('time.hours'),
|
||||
'minutes': $t('time.minutes'),
|
||||
'halfhours': $t('time.halfHours')
|
||||
'hours': t('time.hours'),
|
||||
'minutes': t('time.minutes'),
|
||||
'halfhours': t('time.halfHours')
|
||||
}
|
||||
|
||||
const orderTypeText = orderTypeMap[orderInfo.value.orderType] || orderInfo.value.orderType
|
||||
return `${orderInfo.value.unitPrice}${$t('unit.yuan')}/${orderTypeText}`
|
||||
return `${orderInfo.value.unitPrice}${t('unit.yuan')}/${orderTypeText}`
|
||||
}
|
||||
|
||||
// 格式化倒计时(显示为 HH:MM:SS 格式)
|
||||
@@ -378,21 +421,21 @@
|
||||
if (totalMinutes >= 60) {
|
||||
const hours = Math.floor(totalMinutes / 60)
|
||||
const minutes = totalMinutes % 60
|
||||
usedTime = minutes > 0 ? `${hours}小时${minutes}分钟` : `${hours}小时`
|
||||
usedTime = minutes > 0 ? `${hours}${t('time.hour')}${minutes}${t('time.minute')}` : `${hours}${t('time.hour')}`
|
||||
} else {
|
||||
usedTime = `${totalMinutes}分钟`
|
||||
usedTime = `${totalMinutes}${t('time.minute')}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果还是没有值,使用默认值
|
||||
if (!usedTime) {
|
||||
usedTime = '0分钟'
|
||||
usedTime = `0${t('time.minute')}`
|
||||
}
|
||||
|
||||
// 解析时长字符串,例如 "1小时5分钟" 或 "5分钟"
|
||||
const hourMatch = usedTime.match(/(\d+)小时/)
|
||||
const minuteMatch = usedTime.match(/(\d+)分钟/)
|
||||
const hourMatch = usedTime.match(new RegExp(`(\\d+)${t('time.hour')}`))
|
||||
const minuteMatch = usedTime.match(new RegExp(`(\\d+)${t('time.minute')}`))
|
||||
|
||||
let displayNumber = ''
|
||||
let displayUnit = ''
|
||||
@@ -400,19 +443,19 @@
|
||||
if (hourMatch && minuteMatch) {
|
||||
// 有小时也有分钟,如 "1小时5分钟"
|
||||
displayNumber = `${hourMatch[1]}`
|
||||
displayUnit = `小时${minuteMatch[1]}分钟`
|
||||
displayUnit = `${t('time.hour')}${minuteMatch[1]}${t('time.minute')}`
|
||||
} else if (hourMatch) {
|
||||
// 只有小时,如 "1小时"
|
||||
displayNumber = hourMatch[1]
|
||||
displayUnit = '小时'
|
||||
displayUnit = t('time.hour')
|
||||
} else if (minuteMatch) {
|
||||
// 只有分钟,如 "5分钟"
|
||||
displayNumber = minuteMatch[1]
|
||||
displayUnit = '分钟'
|
||||
displayUnit = t('time.minute')
|
||||
} else {
|
||||
// 默认情况
|
||||
displayNumber = '0'
|
||||
displayUnit = '分钟'
|
||||
displayUnit = t('time.minute')
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -424,7 +467,7 @@
|
||||
// 获取使用时长标签文本
|
||||
const getUsedTimeLabel = () => {
|
||||
// 使用中状态显示"已使用",已完成状态显示"使用时长"
|
||||
return orderInfo.value.orderStatus === 'in_used' ? $t('order.used') : $t('order.duration')
|
||||
return orderInfo.value.orderStatus === 'in_used' ? t('order.used') : t('order.duration')
|
||||
}
|
||||
|
||||
// 获取订单费用(不含单位)
|
||||
@@ -663,7 +706,7 @@
|
||||
if (currentStatusChecks.value >= maxStatusChecks.value) {
|
||||
clearStatusCheckTimer()
|
||||
uni.showToast({
|
||||
title: $t('order.pleaseRefreshManually'),
|
||||
title: t('order.pleaseRefreshManually'),
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
@@ -709,6 +752,13 @@
|
||||
orderInfo.value.unitPrice = orderData.unitPrice || ''
|
||||
orderInfo.value.orderType = orderData.orderType || ''
|
||||
|
||||
// 保存优惠券/会员卡相关信息
|
||||
orderInfo.value.canUseMember = orderData.canUseMember === true
|
||||
orderInfo.value.canUseCoupon = orderData.canUseCoupon === true
|
||||
orderInfo.value.userMemberCardId = orderData.userMemberCardId || ''
|
||||
orderInfo.value.userPurchaseId = orderData.userPurchaseId || ''
|
||||
orderInfo.value.discountTypeName = orderData.discountTypeName || ''
|
||||
|
||||
// 保存快递归还开始时间(小时为单位)
|
||||
orderInfo.value.expressReturnStart = orderData.expressReturnStart || null
|
||||
|
||||
@@ -741,7 +791,7 @@
|
||||
// 显示订单完成提示
|
||||
if (orderInfo.value.orderStatus === 'used_done' || orderInfo.value.orderStatus === 'used_down') {
|
||||
uni.showToast({
|
||||
title: $t('order.orderCompleted'),
|
||||
title: t('order.orderCompleted'),
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
@@ -763,7 +813,7 @@
|
||||
|
||||
try {
|
||||
if (!orderInfo.value.orderId) {
|
||||
throw new Error($t('order.orderIdRequired'))
|
||||
throw new Error(t('order.orderIdRequired'))
|
||||
}
|
||||
|
||||
isLoadingOrder.value = true
|
||||
@@ -813,12 +863,12 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error(result.msg || $t('order.getOrderFailed'))
|
||||
throw new Error(result.msg || t('order.getOrderFailed'))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取订单详情错误:', error)
|
||||
uni.showToast({
|
||||
title: error.message || $t('order.getOrderFailed'),
|
||||
title: error.message || t('order.getOrderFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -834,22 +884,15 @@
|
||||
const getOrderByDevice = async () => {
|
||||
try {
|
||||
if (!deviceId.value) {
|
||||
throw new Error($t('device.deviceNoRequired'))
|
||||
throw new Error(t('device.deviceNoRequired'))
|
||||
}
|
||||
|
||||
const inUseRes = await uni.request({
|
||||
url: `${URL || 'http://127.0.0.1:8080'}/app/order/inUse`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Authorization': "Bearer " + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
}
|
||||
})
|
||||
const inUseRes = await getInUseOrder()
|
||||
|
||||
console.log('通过设备号查询订单结果:', JSON.stringify(inUseRes))
|
||||
|
||||
if (inUseRes.statusCode === 200 && inUseRes.data.code === 200 && inUseRes.data.data) {
|
||||
const inUseOrder = inUseRes.data.data
|
||||
if (inUseRes && inUseRes.code === 200 && inUseRes.data) {
|
||||
const inUseOrder = inUseRes.data
|
||||
console.log('使用中的订单:', inUseOrder)
|
||||
|
||||
orderInfo.value.orderId = inUseOrder.orderId
|
||||
@@ -859,12 +902,12 @@
|
||||
|
||||
getOrderDetails()
|
||||
} else {
|
||||
throw new Error($t('order.noOrderInUse'))
|
||||
throw new Error(t('order.noOrderInUse'))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('通过设备号查询订单失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || $t('order.getOrderFailed'),
|
||||
title: error.message || t('order.getOrderFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -885,13 +928,13 @@
|
||||
// 取消订单
|
||||
const handleCancelOrder = () => {
|
||||
uni.showModal({
|
||||
title: $t('order.confirmCancel'),
|
||||
content: $t('order.confirmCancelContent'),
|
||||
title: t('order.confirmCancel'),
|
||||
content: t('order.confirmCancelContent'),
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: $t('common.processing')
|
||||
title: t('common.processing')
|
||||
})
|
||||
const result = await cancelOrder({
|
||||
orderId: orderInfo.value.orderId
|
||||
@@ -899,17 +942,17 @@
|
||||
if (result.code === 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: $t('order.cancelSuccess'),
|
||||
title: t('order.cancelSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
await getOrderDetails()
|
||||
} else {
|
||||
throw new Error(result.msg || $t('order.cancelFailed'))
|
||||
throw new Error(result.msg || t('order.cancelFailed'))
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: error.message || $t('order.cancelFailed'),
|
||||
title: error.message || t('order.cancelFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -929,22 +972,14 @@
|
||||
const handleWithdraw = async () => {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: $t('common.processing')
|
||||
title: t('common.processing')
|
||||
})
|
||||
|
||||
const res = await uni.request({
|
||||
url: `${URL || 'http://127.0.0.1:8080'}/app/withdraw/add/${orderInfo.value.orderNo}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
}
|
||||
})
|
||||
const res = await withdrawDeposit(orderInfo.value.orderNo)
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
if (res && res.code === 200) {
|
||||
uni.showToast({
|
||||
title: $t('order.refundSuccess'),
|
||||
title: t('order.refundSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
@@ -955,12 +990,12 @@
|
||||
getOrderDetails()
|
||||
}, 1500)
|
||||
} else {
|
||||
throw new Error(res.data.msg || $t('order.refundFailed'))
|
||||
throw new Error(res?.msg || t('order.refundFailed'))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('退款申请错误:', error)
|
||||
console.error('退款申请失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || $t('order.refundFailed'),
|
||||
title: error.message || t('order.refundFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
@@ -1002,14 +1037,14 @@
|
||||
})
|
||||
|
||||
uni.showToast({
|
||||
title: '订阅成功',
|
||||
title: t('payment.subscriptionSuccess'),
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
} catch (error) {
|
||||
console.log('订阅消息异常', error)
|
||||
uni.showToast({
|
||||
title: '订阅失败,请稍后重试',
|
||||
title: t('payment.subscriptionFailed'),
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
@@ -1040,7 +1075,7 @@
|
||||
try {
|
||||
closeConvertToOwnPopup()
|
||||
uni.showLoading({
|
||||
title: $t('common.processing')
|
||||
title: t('common.processing')
|
||||
})
|
||||
|
||||
const result = await closeWithMaxFee(orderInfo.value.orderNo)
|
||||
@@ -1048,7 +1083,7 @@
|
||||
if (result.code === 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: $t('order.convertToOwnWithMaxFeeSuccess'),
|
||||
title: t('order.convertToOwnWithMaxFeeSuccess'),
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
@@ -1058,12 +1093,12 @@
|
||||
getOrderDetails()
|
||||
}, 2000)
|
||||
} else {
|
||||
throw new Error(result.msg || $t('order.convertToOwnWithMaxFeeFailed'))
|
||||
throw new Error(result.msg || t('order.convertToOwnWithMaxFeeFailed'))
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: error.message || $t('order.convertToOwnWithMaxFeeFailed'),
|
||||
title: error.message || t('order.convertToOwnWithMaxFeeFailed'),
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
@@ -1076,7 +1111,7 @@
|
||||
|
||||
// 设置页面标题
|
||||
uni.setNavigationBarTitle({
|
||||
title: $t('order.orderDetail')
|
||||
title: t('order.orderDetail')
|
||||
})
|
||||
|
||||
isPageActive.value = true
|
||||
@@ -1101,7 +1136,7 @@
|
||||
getOrderDetails()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: $t('order.orderInfoMissing'),
|
||||
title: t('order.orderInfoMissing'),
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -1161,12 +1196,18 @@
|
||||
.header-left {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.header-desc {
|
||||
@@ -1210,6 +1251,18 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.promotion-tag {
|
||||
padding: 6rpx 16rpx;
|
||||
background: linear-gradient(135deg, #FFF4E6 0%, #FFE9CC 100%);
|
||||
border-radius: 10rpx;
|
||||
border: 1rpx solid #FFB84D;
|
||||
font-size: 22rpx;
|
||||
color: #FF8C00;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// 订单信息卡片
|
||||
.info-card {
|
||||
@@ -1355,6 +1408,20 @@
|
||||
color: #333;
|
||||
text-align: right;
|
||||
max-width: 400rpx;
|
||||
|
||||
&.promotion-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
color: #FF8C00;
|
||||
font-weight: 500;
|
||||
|
||||
.promotion-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user