syle:更新样式

This commit is contained in:
2025-10-15 14:56:34 +08:00
parent 46179c5d3f
commit 49ce29945f
17 changed files with 814 additions and 132 deletions
+134 -46
View File
@@ -10,20 +10,22 @@
<view class="info-card">
<view class="info-row">
<view class="info-col">
<view class="info-value">{{ getUsedTimeNumber() }}</view>
<view class="info-label">{{ getUsedTimeUnit() }}</view>
<view class="info-value-wrapper">
<text class="info-value-large">{{ getUsedTimeDisplay().number }}</text>
<text class="info-value-unit">{{ getUsedTimeDisplay().unit }}</text>
</view>
<view class="info-label">{{ getUsedTimeLabel() }}</view>
</view>
<view class="info-col">
<view class="info-value">{{ getOrderFee() }}</view>
<view class="info-label">{{ isOrderCompleted() ? '订单金额' : '订单金额' }}</view>
</view>
<view class="info-col">
<view class="info-value">{{ orderInfo.packagePrice || '10' }}</view>
<view class="info-label"></view>
<view class="info-value-wrapper">
<text class="info-value-large">{{ getOrderFee() }}</text>
<text class="info-value-unit"></text>
</view>
<view class="info-label">订单金额</view>
</view>
</view>
<view class="fee-rule">
计费规则5.0/60分钟 前15分钟内归还免费 不足60分钟按60分钟计费 封顶99元 持续计费至99元视为买断
{{ feeRuleText }}
</view>
</view>
@@ -88,7 +90,7 @@
<template v-if="isOrderCompleted()">
<view class="bottom-icon-btn" @click="handleWithdraw" v-if="!orderInfo.isWithdrawn && orderInfo.refundAmount > 0">
<image src="/static/suggess.png" class="icon" mode="aspectFit"></image>
<text>费用申</text>
<text>费用申</text>
</view>
<view class="bottom-icon-btn" @click="contactService">
<image src="/static/customer-service.png" class="icon" mode="aspectFit"></image>
@@ -145,7 +147,8 @@
withdrawStatus: 'waiting',
isWithdrawn: false,
positionName: '',
returnPosition: ''
returnPosition: '',
expressReturnStart: null
},
timer: null,
statusCheckTimer: null,
@@ -156,13 +159,25 @@
expressThresholdSeconds: 180,
countdownRemaining: 0,
showExpressAction: false,
countdownTimer: null
countdownTimer: null,
feeRuleText: '5.0元/60分钟 前15分钟内归还免费 不足60分钟按60分钟计费 封顶99元 持续计费至99元视为买断'
}
},
onLoad(options) {
console.log('订单详情页加载,参数:', JSON.stringify(options))
this.isPageActive = true
// 从缓存读取通知内容(计费规则)
try {
const cachedNotice = uni.getStorageSync('noticeContent')
if (cachedNotice) {
console.log('从缓存读取计费规则:', cachedNotice)
this.feeRuleText = cachedNotice
}
} catch (e) {
console.warn('读取缓存通知内容失败:', e)
}
this.orderInfo.orderId = options.orderId || ''
this.deviceId = options.deviceNo || options.deviceId || ''
@@ -185,11 +200,11 @@
uni.$on('orderCompleted', this.handleOrderCompleted)
// 获取系统配置
this.loadSystemConfig().then(() => {
if (this.orderInfo.orderStatus === 'in_used') {
this.startExpressCountdown()
}
})
// this.loadSystemConfig().then(() => {
// if (this.orderInfo.orderStatus === 'in_used') {
// this.startExpressCountdown()
// }
// })
},
onShow() {
this.isPageActive = true
@@ -313,28 +328,70 @@
})
},
// 获取使用时长的数字部分(用于显示)
getUsedTimeNumber() {
const usedTime = this.orderInfo.usedTime || '0分钟'
// 提取第一个数字(如 "1小时5分钟" -> "1"
const match = usedTime.match(/(\d+)/)
return match ? match[1] : '0'
// 获取使用时长显示信息
getUsedTimeDisplay() {
let usedTime = this.orderInfo.usedTime
// 如果 usedTime 为空,通过开始时间和结束时间计算
if (usedTime === '0分钟' && this.orderInfo.startTime && this.orderInfo.endTime) {
const startMs = this.parseStartTimeToMs(this.orderInfo.startTime)
const endMs = this.parseStartTimeToMs(this.orderInfo.endTime)
if (!isNaN(startMs) && !isNaN(endMs)) {
const diffMs = endMs - startMs
const totalMinutes = Math.floor(diffMs / (1000 * 60))
// 格式化为 "X小时X分钟" 或 "X分钟"
if (totalMinutes >= 60) {
const hours = Math.floor(totalMinutes / 60)
const minutes = totalMinutes % 60
usedTime = minutes > 0 ? `${hours}小时${minutes}分钟` : `${hours}小时`
} else {
usedTime = `${totalMinutes}分钟`
}
}
}
// 如果还是没有值,使用默认值
if (!usedTime) {
usedTime = '0分钟'
}
// 解析时长字符串,例如 "1小时5分钟" 或 "5分钟"
const hourMatch = usedTime.match(/(\d+)小时/)
const minuteMatch = usedTime.match(/(\d+)分钟/)
let displayNumber = ''
let displayUnit = ''
if (hourMatch && minuteMatch) {
// 有小时也有分钟,如 "1小时5分钟"
displayNumber = `${hourMatch[1]}`
displayUnit = `小时${minuteMatch[1]}分钟`
} else if (hourMatch) {
// 只有小时,如 "1小时"
displayNumber = hourMatch[1]
displayUnit = '小时'
} else if (minuteMatch) {
// 只有分钟,如 "5分钟"
displayNumber = minuteMatch[1]
displayUnit = '分钟'
} else {
// 默认情况
displayNumber = '0'
displayUnit = '分钟'
}
return {
number: displayNumber,
unit: displayUnit
}
},
// 获取使用时长的单位部分
getUsedTimeUnit() {
if (this.isOrderCompleted()) {
return '使用时长'
}
const usedTime = this.orderInfo.usedTime || '0分钟'
// 如果是完整的时长字符串,返回"已使用"
// 否则提取单位
if (usedTime.includes('小时')) {
return '小时'
} else if (usedTime.includes('分钟')) {
return '分钟'
}
return '已使用'
// 获取使用时长标签文本
getUsedTimeLabel() {
// 使用中状态显示"已使用",已完成状态显示"使用时长"
return this.orderInfo.orderStatus === 'in_used' ? '已使用' : '使用时长'
},
// 获取订单费用(不含单位)
@@ -347,13 +404,22 @@
// 加载系统配置
async loadSystemConfig() {
try {
const res = await getSystemConfig()
if (res && res.code === 200 && res.data && typeof res.data.expressReturnCountdownSeconds === 'number') {
const seconds = res.data.expressReturnCountdownSeconds
if (seconds > 0) {
this.expressThresholdSeconds = seconds
// 优先使用订单数据中的 expressReturnStart(小时转秒)
if (this.orderInfo.expressReturnStart && typeof this.orderInfo.expressReturnStart === 'number' && this.orderInfo.expressReturnStart > 0) {
this.expressThresholdSeconds = this.orderInfo.expressReturnStart * 3600
console.log('使用订单配置的快递归还阈值:', this.orderInfo.expressReturnStart, '小时 =>', this.expressThresholdSeconds, '秒')
} else {
// 如果订单数据中没有,则使用系统配置
const res = await getSystemConfig()
if (res && res.code === 200 && res.data && typeof res.data.expressReturnCountdownSeconds === 'number') {
const seconds = res.data.expressReturnCountdownSeconds
if (seconds > 0) {
this.expressThresholdSeconds = seconds
console.log('使用系统配置的快递归还阈值:', seconds, '秒')
}
}
}
if (this.orderInfo.orderStatus === 'in_used' && this.orderInfo.startTime) {
this.recomputeExpressCountdownFromStartTime()
}
@@ -552,6 +618,15 @@
this.orderInfo.isWithdrawn = orderData.withdrawStatus === 'success'
this.orderInfo.positionName = orderData.positionName || orderData.positionLocation || ''
this.orderInfo.returnPosition = orderData.returnPosition || orderData.positionName || orderData.positionLocation || ''
// 保存快递归还开始时间(小时为单位)
this.orderInfo.expressReturnStart = orderData.expressReturnStart || null
// 如果有有效的 expressReturnStart,立即更新倒计时阈值(小时转秒)
if (this.orderInfo.expressReturnStart && typeof this.orderInfo.expressReturnStart === 'number' && this.orderInfo.expressReturnStart > 0) {
this.expressThresholdSeconds = this.orderInfo.expressReturnStart * 3600
console.log('从订单数据更新快递归还阈值:', this.orderInfo.expressReturnStart, '小时 =>', this.expressThresholdSeconds, '秒')
}
if (orderData.deviceNo && !this.deviceId) {
this.deviceId = orderData.deviceNo
@@ -843,11 +918,24 @@
flex: 1;
text-align: center;
.info-value {
font-size: 40rpx;
font-weight: bold;
color: #333;
.info-value-wrapper {
display: flex;
align-items: baseline;
justify-content: center;
margin-bottom: 8rpx;
.info-value-large {
font-size: 48rpx;
font-weight: bold;
color: #333;
line-height: 1;
}
.info-value-unit {
font-size: 24rpx;
color: #666;
margin-left: 4rpx;
}
}
.info-label {