修复bug

This commit is contained in:
2026-05-04 17:49:00 +08:00
parent e1c9068ab0
commit 2f0479ea05
10 changed files with 531 additions and 101 deletions
+193 -53
View File
@@ -44,7 +44,7 @@
<view class="info-col">
<view class="info-value-wrapper">
<text class="info-value-large">{{ getOrderFee() }}</text>
<text class="info-value-unit">{{ $t('unit.yuan') }}</text>
<text class="info-value-unit">{{ getCurrencyUnitText() }}</text>
</view>
<view class="info-label">{{ $t('order.totalAmount') }}</view>
</view>
@@ -116,8 +116,8 @@
</view>
<view class="rent-paid" v-if="isOrderCompleted()">
<text class="paid-label">{{ $t('order.paid') }}</text>
<text class="paid-value">{{ orderInfo.currentFee || orderInfo.payAmount || '10' }}</text>
<text class="paid-unit">{{ $t('unit.yuan') }}</text>
<text class="paid-value">{{ formatAmountDisplay(orderInfo.currentFee || orderInfo.payAmount || '10') }}</text>
<text class="paid-unit">{{ getCurrencyUnitText() }}</text>
</view>
</view>
<view class="rent-service-tip">
@@ -152,16 +152,16 @@
<view v-if="showExpressAction" class="action-btn secondary" @click="expressRetrunOrder">
{{ $t('express.title') }}
</view>
<view v-if="showExpressAction" class="bottom-icon-btn" @click="quickReturn">
<!-- <view v-if="showExpressAction" class="bottom-icon-btn" @click="quickReturn">
<image src="/static/map.png" class="icon" mode="aspectFit" lazy-load="true"></image>
<text>{{ $t('order.quickReturn') }}</text>
</view>
</view> -->
</template>
<!-- 不支持快递归还时只显示快速归还图标+小字 -->
<view v-else class="bottom-icon-btn" @click="quickReturn">
<!-- <view v-else class="bottom-icon-btn" @click="quickReturn">
<image src="/static/map.png" class="icon" mode="aspectFit" lazy-load="true"></image>
<text>{{ $t('order.quickReturn') }}</text>
</view>
</view> -->
<view
v-if="showPauseBillingButton"
class="action-btn secondary pause-billing-btn"
@@ -264,6 +264,12 @@
import {
useI18n
} from '@/utils/i18n.js'
import {
fetchAndCacheDanaPaymentConfig,
DANA_SINGLE_STORAGE_KEY,
DANA_TOTAL_STORAGE_KEY,
parseDanaStorageNumber
} from '@/utils/danaPaymentConfig.js'
const {
t
@@ -322,6 +328,43 @@
const feeRuleText = ref('')
const convertToOwnPopup = ref(null)
const lastDeviceEjectTime = ref(0) // 上次点击"宝未弹出"的时间戳
const currencyCode = ref('CNY')
const danaPaymentTotal = ref(0)
const danaPaymentSingle = ref(6000)
const loadDanaPaymentCache = () => {
try {
const cachedTotal = parseDanaStorageNumber(uni.getStorageSync(DANA_TOTAL_STORAGE_KEY))
const cachedSingle = parseDanaStorageNumber(uni.getStorageSync(DANA_SINGLE_STORAGE_KEY))
if (cachedTotal !== null) {
danaPaymentTotal.value = cachedTotal
}
if (cachedSingle !== null && cachedSingle > 0) {
danaPaymentSingle.value = cachedSingle
}
} catch (e) {
console.warn('读取 DANA 金额缓存失败,使用默认值:', e)
}
}
const resolveCurrencyCode = (orderData = {}) => {
const explicitCurrency = String(
orderData.currency || orderData.positionCurrency || orderData.position?.currency || ''
).toUpperCase()
if (explicitCurrency) return explicitCurrency
const payWay = String(orderData.payWay || '').toLowerCase()
const phone = String(orderData.phone || '')
const depositAmount = Number(orderData.depositAmount || 0)
const unitPrice = Number(orderData.unitPrice || 0)
// 海外 H5 订单接口偶发不返回 currency,按业务特征兜底识别 IDR
if (payWay.includes('antom') || phone.startsWith('+62') || depositAmount >= 1000 || unitPrice >= 1000) {
return 'IDR'
}
return 'CNY'
}
/** 是否允许点击暂停:null 拉取中,true 可暂停,false 不可暂停(按钮仍展示为禁用) */
const pauseBillingEligible = ref(null)
const pauseBillingLoading = ref(false)
@@ -502,7 +545,15 @@
}
const orderTypeText = orderTypeMap[orderInfo.value.orderType] || orderInfo.value.orderType
return `${orderInfo.value.unitPrice}${t('unit.yuan')}/${orderTypeText}`
if (currencyCode.value === 'IDR') {
return `Rp${formatAmountDisplay(danaPaymentSingle.value)}/${orderTypeText}`
}
return `${formatAmountDisplay(orderInfo.value.unitPrice)}${getCurrencyUnitText()}/${orderTypeText}`
}
const getCurrencyUnitText = () => {
if (currencyCode.value === 'IDR') return 'Rp'
return t('unit.yuan')
}
// 格式化倒计时(显示为 HH:MM:SS 格式)
@@ -619,23 +670,25 @@
}
}
const formatAmountDisplay = (amount) => {
if (amount === null || amount === undefined || amount === '') return '0'
const normalized = String(amount).replace(/[^\d.-]/g, '')
const num = Number(normalized)
if (Number.isFinite(num)) {
return String(Math.trunc(num))
}
return String(amount).split('.')[0]
}
// 获取使用时长标签文本
const getUsedTimeLabel = () => {
// 使用中状态显示"已使用",已完成状态显示"使用时长"
return orderInfo.value.orderStatus === 'in_used' ? t('order.used') : t('order.duration')
}
// 获取订单费用(不含单位)
// 总金额展示:使用本地缓存 danaPaymentTotal(结构如 { type: 'number', data: 99000 }),由 loadDanaPaymentCache 同步到 danaPaymentTotal
const getOrderFee = () => {
let fee;
if(orderInfo.value.originalFee){
fee = orderInfo.value.originalFee || orderInfo.value.originalFee || '0'
}else{
fee = orderInfo.value.currentFee;
}
// 移除可能的"元"字符
return String(fee).replace(/[元¥]/g, '')
return formatAmountDisplay(String(danaPaymentTotal.value))
}
// 解析开始时间
@@ -969,6 +1022,7 @@
orderInfo.value.discountTypeName = orderData.discountTypeName || ''
orderInfo.value.originalFee = orderData.originalFee||''
orderInfo.value.returnMapImage = orderData.returnMapImage||''
currencyCode.value = resolveCurrencyCode(orderData)
// 保存快递归还开始时间(小时为单位)
orderInfo.value.expressReturnStart = orderData.expressReturnStart || null
@@ -1392,6 +1446,10 @@
// 生命周期钩子
onLoad((options) => {
loadDanaPaymentCache()
void fetchAndCacheDanaPaymentConfig()
.then(() => loadDanaPaymentCache())
.catch((e) => console.warn('DANA 配置刷新失败:', e))
console.log('订单详情页加载,参数:', JSON.stringify(options))
// 设置页面标题
@@ -1434,6 +1492,7 @@
})
onShow(() => {
loadDanaPaymentCache()
isPageActive.value = true
if (orderInfo.value.orderStatus === 'in_used' && orderInfo.value.isSupportExpressReturn !== 'no') {
startExpressCountdown()
@@ -1473,7 +1532,8 @@
min-height: 100vh;
background: #f7f8fa;
padding: 30rpx;
padding-bottom: 180rpx;
/* 底部操作栏为多行时,预留更大的安全滚动空间,避免遮挡详情内容 */
padding-bottom: calc(320rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
// 顶部标题
@@ -1524,6 +1584,10 @@
.header-desc {
font-size: 28rpx;
color: #999;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
line-height: 1.5;
}
.header-right {
@@ -1531,6 +1595,8 @@
align-items: center;
height: 100%;
text-align: center;
min-width: 0;
flex-shrink: 1;
}
.device-no-eject-btn {
@@ -1543,7 +1609,9 @@
// background: #E8F5E9;
// border-radius: 12rpx;
// border: 2rpx solid #07c160;
min-width: 120rpx;
min-width: 0;
max-width: 180rpx;
width: 100%;
.device-no-eject-icon {
width: 68rpx;
@@ -1555,6 +1623,13 @@
font-size: 26rpx;
color: #07c160;
font-weight: 500;
display: block;
width: 100%;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
line-height: 1.3;
text-align: center;
}
&:active {
@@ -1591,12 +1666,15 @@
.info-left {
flex: 1;
min-width: 0;
display: flex;
// justify-content: space-between;
align-items: center;
.info-col {
width: 200rpx;
width: auto;
flex: 1;
min-width: 0;
// flex: 1;
// text-align: center;
@@ -1631,7 +1709,10 @@
display: flex;
align-items: center;
justify-content: flex-end;
flex-shrink: 0;
flex-shrink: 1;
min-width: 0;
max-width: 48%;
margin-left: 12rpx;
.return-reminder-btn {
display: flex;
@@ -1641,11 +1722,25 @@
background: #3EAB64;
border-radius: 50rpx;
border: 2rpx solid #3EAB64;
width: 100%;
max-width: 100%;
flex-shrink: 1;
gap: 8rpx;
overflow: hidden;
box-sizing: border-box;
.return-reminder-text {
font-size: 24rpx;
color: #fff;
font-weight: 500;
display: block;
flex: 1;
min-width: 0;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
line-height: 1.3;
text-align: center;
}
&:active {
@@ -1662,6 +1757,9 @@
font-size: 24rpx;
color: #4CAF50;
line-height: 1.6;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
}
.fee-rule-image {
@@ -1748,6 +1846,9 @@
text-align: center;
line-height: 1.6;
padding-top: 20rpx;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
.rent-service-link {
color: #07c160;
@@ -1757,9 +1858,10 @@
.rent-item {
display: flex;
justify-content: space-between;
align-items: center;
align-items: flex-start;
padding: 16rpx 0;
border-bottom: 1rpx solid #f0f0f0;
gap: 16rpx;
&:last-of-type {
border-bottom: none;
@@ -1768,13 +1870,22 @@
.rent-label {
font-size: 28rpx;
color: #999;
flex-shrink: 0;
max-width: 42%;
line-height: 1.5;
}
.rent-value {
font-size: 28rpx;
color: #333;
text-align: right;
max-width: 400rpx;
flex: 1;
min-width: 0;
max-width: none;
line-height: 1.5;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
&.promotion-value {
display: flex;
@@ -1826,27 +1937,36 @@
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 30rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
padding: 18rpx 24rpx;
padding-bottom: calc(18rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
border-top: 1rpx solid #f0f0f0;
box-shadow: 0 -6rpx 20rpx rgba(0, 0, 0, 0.05);
z-index: 10;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: 20rpx;
align-items: stretch;
gap: 12rpx;
.bottom-bar-in-use {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
align-items: center;
justify-content: space-between;
// gap: 20rpx;
align-items: stretch;
gap: 12rpx;
box-sizing: border-box;
> .countdown-btn,
> .action-btn.secondary,
> .action-btn.pause-billing-btn {
flex: 1 1 0;
min-width: 0;
}
> .bottom-icon-btn {
flex: 0 0 122rpx;
}
}
.bottom-icon-btn {
@@ -1854,17 +1974,27 @@
flex-direction: column;
align-items: center;
justify-content: center;
min-width: 100rpx;
min-width: 108rpx;
min-height: 88rpx;
padding: 8rpx 8rpx;
box-sizing: border-box;
background: #f7f8fa;
border-radius: 20rpx;
.icon {
width: 48rpx;
height: 48rpx;
margin-bottom: 8rpx;
width: 42rpx;
height: 42rpx;
margin-bottom: 6rpx;
}
text {
font-size: 24rpx;
font-size: 22rpx;
color: #666;
line-height: 1.25;
text-align: center;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
}
&:active {
@@ -1875,26 +2005,32 @@
.countdown-btn {
flex: 1 1 auto;
min-width: 200rpx;
height: 88rpx;
min-height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-size: 26rpx;
color: #07c160;
background: #E8F5E9;
border-radius: 44rpx;
border-radius: 20rpx;
border: 2rpx solid #07c160;
padding: 0 18rpx;
box-sizing: border-box;
text-align: center;
line-height: 1.3;
}
.action-btn {
height: 88rpx;
min-height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
border-radius: 44rpx;
padding: 0 40rpx;
white-space: nowrap;
font-size: 27rpx;
border-radius: 20rpx;
padding: 12rpx 20rpx;
white-space: normal;
text-align: center;
line-height: 1.35;
&.full-width {
flex: 1;
@@ -1920,10 +2056,10 @@
}
&.is-disabled {
opacity: 0.45;
color: #999;
background: #ebebeb;
border-color: #ddd;
opacity: 1;
color: #b8b8b8;
background: #f3f3f3;
border-color: #e6e6e6;
&:active {
opacity: 0.45;
@@ -1945,8 +2081,12 @@
background: #fff;
color: #07c160;
border: 2rpx solid #07c160;
flex: 0 1 auto;
max-width: 100%;
flex: 1 1 100%;
width: 100%;
min-width: 0;
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
&:active {
opacity: 0.8;