feat:国际化多语言适配

This commit is contained in:
2025-10-29 15:48:40 +08:00
parent 985d739324
commit 3d67dc928d
41 changed files with 2636 additions and 2801 deletions
+58 -53
View File
@@ -19,9 +19,9 @@
<view class="info-col">
<view class="info-value-wrapper">
<text class="info-value-large">{{ getOrderFee() }}</text>
<text class="info-value-unit"></text>
<text class="info-value-unit">{{ $t('unit.yuan') }}</text>
</view>
<view class="info-label">订单金额</view>
<view class="info-label">{{ $t('order.totalAmount') }}</view>
</view>
</view>
<view class="fee-rule">
@@ -31,39 +31,39 @@
<!-- 租借信息卡片 -->
<view class="rent-card">
<view class="rent-title">租借信息</view>
<view class="rent-title">{{ $t('order.rentInfo') }}</view>
<view class="rent-item">
<view class="rent-label">订单编号</view>
<view class="rent-label">{{ $t('order.orderNo') }}</view>
<view class="rent-value">{{ orderInfo.orderNo || '-' }}</view>
</view>
<view class="rent-item">
<view class="rent-label">风扇编号</view>
<view class="rent-label">{{ $t('order.fanNo') }}</view>
<view class="rent-value">{{ deviceId || '-' }}</view>
</view>
<view class="rent-item">
<view class="rent-label">租借时间</view>
<view class="rent-label">{{ $t('order.rentTime') }}</view>
<view class="rent-value">{{ orderInfo.startTime || '-' }}</view>
</view>
<view class="rent-item">
<view class="rent-label">租借地点</view>
<view class="rent-value">{{ orderInfo.positionName || '新佳宜(九天银河店)' }}</view>
<view class="rent-label">{{ $t('order.rentLocation') }}</view>
<view class="rent-value">{{ orderInfo.positionName || '-' }}</view>
</view>
<view class="rent-item">
<view class="rent-label">租借方式</view>
<view class="rent-label">{{ $t('order.rentMethod') }}</view>
<view class="rent-value">{{ getPayWayText() }}</view>
</view>
<view class="rent-item" v-if="isOrderCompleted() && orderInfo.endTime">
<view class="rent-label">归还时间</view>
<view class="rent-label">{{ $t('order.returnTime') }}</view>
<view class="rent-value">{{ orderInfo.endTime }}</view>
</view>
<view class="rent-item" v-if="isOrderCompleted() && orderInfo.returnPosition">
<view class="rent-label">归还地点</view>
<view class="rent-value">{{ orderInfo.returnPosition || '新佳宜(九天银河店)' }}</view>
<view class="rent-label">{{ $t('order.returnLocation') }}</view>
<view class="rent-value">{{ orderInfo.returnPosition || '-' }}</view>
</view>
<view class="rent-paid" v-if="isOrderCompleted()">
<text class="paid-label">已支付</text>
<text class="paid-label">{{ $t('order.paid') }}</text>
<text class="paid-value">{{ orderInfo.currentFee || orderInfo.payAmount || '10' }}</text>
<text class="paid-unit"></text>
<text class="paid-unit">{{ $t('unit.yuan') }}</text>
</view>
</view>
@@ -73,16 +73,16 @@
<template v-if="orderInfo.orderStatus === 'in_used'">
<view class="bottom-icon-btn" @click="contactService">
<image src="/static/customer-service.png" class="icon" mode="aspectFit"></image>
<text>客服中心</text>
<text>{{ $t('user.customerService') }}</text>
</view>
<view v-if="!showExpressAction" class="countdown-btn">
{{ formatCountdown(countdownRemaining) }}后可快递归还
{{ formatCountdown(countdownRemaining) }}{{ $t('order.canExpressReturn') }}
</view>
<view v-if="showExpressAction" class="action-btn secondary" @click="expressRetrunOrder">
暂停计费
{{ $t('order.pauseBilling') }}
</view>
<view v-if="showExpressAction" class="action-btn primary" @click="quickReturn">
快速归还
{{ $t('order.quickReturn') }}
</view>
</template>
@@ -90,26 +90,26 @@
<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>{{ $t('order.feeAppeal') }}</text>
</view>
<view class="bottom-icon-btn" @click="contactService">
<image src="/static/customer-service.png" class="icon" mode="aspectFit"></image>
<text>客服中心</text>
<text>{{ $t('user.customerService') }}</text>
</view>
<view class="action-btn primary" @click="rentAgain">
再次租借
{{ $t('order.rentAgain') }}
</view>
</template>
<!-- 待支付状态 -->
<template v-if="orderInfo.orderStatus === 'waiting_for_payment'">
<view class="action-btn secondary" @click="handleCancelOrder">取消订单</view>
<view class="action-btn primary" @click="handlePayment">立即支付</view>
<view class="action-btn secondary" @click="handleCancelOrder">{{ $t('order.cancelOrder') }}</view>
<view class="action-btn primary" @click="handlePayment">{{ $t('order.payNow') }}</view>
</template>
<!-- 已取消状态 -->
<template v-if="orderInfo.orderStatus === 'order_cancelled'">
<view class="action-btn primary full-width" @click="goToHome">返回首页</view>
<view class="action-btn primary full-width" @click="goToHome">{{ $t('order.backToHome') }}</view>
</template>
</view>
</view>
@@ -168,6 +168,11 @@
onLoad(options) {
console.log('订单详情页加载,参数:', JSON.stringify(options))
// 设置页面标题
uni.setNavigationBarTitle({
title: this.$t('order.orderDetail')
})
this.isPageActive = true
// 从缓存读取通知内容(计费规则)
@@ -241,27 +246,27 @@
// 获取订单状态文字
getOrderStatusText() {
const statusMap = {
'waiting_for_payment': '待支付',
'payment_in_progress': '支付中',
'payment_successful': '支付成功',
'in_used': '使用中',
'payment_failed': '支付失败',
'order_cancelled': '已取消',
'used_done': '已完成',
'used_down': '已完成'
'waiting_for_payment': this.$t('order.waitingForPayment'),
'payment_in_progress': this.$t('order.paymentInProgress'),
'payment_successful': this.$t('order.paymentSuccess'),
'in_used': this.$t('order.inUse'),
'payment_failed': this.$t('order.paymentFailed'),
'order_cancelled': this.$t('order.cancelled'),
'used_done': this.$t('order.finished'),
'used_down': this.$t('order.finished')
}
return statusMap[this.orderInfo.orderStatus] || '订单详情'
return statusMap[this.orderInfo.orderStatus] || this.$t('order.orderDetail')
},
// 获取状态描述
getStatusDesc() {
const descMap = {
'waiting_for_payment': '请尽快完成支付',
'in_used': '请妥善保管设备,使用完毕后及时归还',
'used_done': '您的风扇已归还,感谢使用',
'used_down': '您的风扇已归还,感谢使用',
'order_cancelled': '订单已取消',
'payment_failed': '支付失败,请重新支付'
'waiting_for_payment': this.$t('order.pleasePaySoon'),
'in_used': this.$t('order.pleaseReturnInTime'),
'used_done': this.$t('order.returnedThankYou'),
'used_down': this.$t('order.returnedThankYou'),
'order_cancelled': this.$t('order.orderCancelled'),
'payment_failed': this.$t('order.paymentFailedRetry')
}
return descMap[this.orderInfo.orderStatus] || ''
},
@@ -293,11 +298,11 @@
// 获取支付方式文本
getPayWayText() {
const payWayMap = {
'wx_score_pay': '免押租借',
'wx_member_pay': '会员订单',
'wx_pay': '押金租借'
'wx_score_pay': this.$t('order.depositFree'),
'wx_member_pay': this.$t('order.memberOrder'),
'wx_pay': this.$t('order.depositPay')
}
return payWayMap[this.orderInfo.payWay] || '免押租借'
return payWayMap[this.orderInfo.payWay] || this.$t('order.depositFree')
},
// 格式化倒计时(显示为 HH:MM:SS 格式)
@@ -393,7 +398,7 @@
// 获取使用时长标签文本
getUsedTimeLabel() {
// 使用中状态显示"已使用",已完成状态显示"使用时长"
return this.orderInfo.orderStatus === 'in_used' ? '已使用' : '使用时长'
return this.orderInfo.orderStatus === 'in_used' ? this.$t('order.used') : this.$t('order.duration')
},
// 获取订单费用(不含单位)
@@ -549,7 +554,7 @@
try {
if (!this.orderInfo.orderId) {
throw new Error('订单ID不能为空')
throw new Error(this.$t('order.orderIdRequired'))
}
const result = await queryById(this.orderInfo.orderId)
@@ -762,13 +767,13 @@
// 取消订单
handleCancelOrder() {
uni.showModal({
title: '确认取消',
content: '确定要取消此订单吗?',
title: this.$t('order.confirmCancel'),
content: this.$t('order.confirmCancelContent'),
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({
title: '处理中'
title: this.$t('common.processing')
})
const result = await cancelOrder({
orderId: this.orderInfo.orderId
@@ -776,17 +781,17 @@
if (result.code === 200) {
uni.hideLoading()
uni.showToast({
title: '订单已取消',
title: this.$t('order.cancelSuccess'),
icon: 'success'
})
await this.getOrderDetails()
} else {
throw new Error(result.msg || '取消订单失败')
throw new Error(result.msg || this.$t('order.cancelFailed'))
}
} catch (error) {
uni.hideLoading()
uni.showToast({
title: error.message || '取消订单失败',
title: error.message || this.$t('order.cancelFailed'),
icon: 'none'
})
}
@@ -821,7 +826,7 @@
if (res.statusCode === 200 && res.data.code === 200) {
uni.showToast({
title: '退款申请成功',
title: this.$t('order.refundSuccess'),
icon: 'success'
})
@@ -837,7 +842,7 @@
} catch (error) {
console.error('退款申请错误:', error)
uni.showToast({
title: error.message || '退款申请失败',
title: error.message || this.$t('order.refundFailed'),
icon: 'none'
})
} finally {