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 {
+42 -32
View File
@@ -10,12 +10,12 @@
<!-- 订单列表 -->
<view class="order-list">
<view class="empty-state" v-if="orderList.length === 0">
<view class="empty-icon">
<image src="/static/orderList.png" mode="aspectFill" class="empty-icon"></image>
</view>
<text class="empty-text">暂无订单记录</text>
<view class="empty-state" v-if="orderList.length === 0">
<view class="empty-icon">
<image src="/static/orderList.png" mode="aspectFill" class="empty-icon"></image>
</view>
<text class="empty-text">{{ $t('order.noOrderRecord') }}</text>
</view>
<OrderItemCard
v-for="(order, index) in orderList"
@@ -56,6 +56,16 @@
import {
URL
} from '../../config/url.js';
import { useI18n } from '@/utils/i18n.js'
const { t: $t } = useI18n()
// 设置页面标题
onMounted(() => {
uni.setNavigationBarTitle({
title: $t('order.myOrders')
})
})
// 初始化状态
const currentTab = ref(0);
@@ -64,62 +74,62 @@
// 订单状态映射
const orderStatusMap = reactive({
'0': {
text: '待支付',
get text() { return $t('order.waitingForPayment') },
class: 'status-waiting'
},
'1': {
text: '使用中',
get text() { return $t('order.inUse') },
class: 'status-using'
},
'2': {
text: '已完成',
get text() { return $t('order.finished') },
class: 'status-finished'
},
'3': {
text: '已取消',
get text() { return $t('order.cancelled') },
class: 'status-cancelled'
},
'waiting_for_payment': {
text: '待支付',
get text() { return $t('order.waitingForPayment') },
class: 'status-waiting'
},
'in_used': {
text: '使用中',
get text() { return $t('order.inUse') },
class: 'status-using'
},
'used_done': {
text: '已完成',
get text() { return $t('order.finished') },
class: 'status-finished'
},
'order_cancelled': {
text: '已取消',
get text() { return $t('order.cancelled') },
class: 'status-cancelled'
},
'express_return': {
text: '快递归还',
get text() { return $t('express.title') },
class: 'status-express-return'
}
});
// 订单状态标签
const orderStatusTabs = reactive([{
text: '全部',
get text() { return $t('common.all') },
status: []
},
{
text: '待付款',
get text() { return $t('order.waitingForPayment') },
status: ['waiting_for_payment']
},
{
text: '使用中',
get text() { return $t('order.inUse') },
status: ['in_used']
},
{
text: '已完成',
get text() { return $t('order.finished') },
status: ['used_done']
},
{
text: '已取消',
get text() { return $t('order.cancelled') },
status: ['order_cancelled']
}
]);
@@ -212,7 +222,7 @@
} catch (error) {
console.error('获取订单列表失败:', error);
uni.showToast({
title: '获取订单列表失败',
title: $t('order.getOrderListFailed'),
icon: 'none'
});
}
@@ -224,14 +234,14 @@
const res = await getOrderByOrderNoScorePayStatus(order.orderNo);
if (res.code === 200) {
uni.showToast({
title: '状态同步成功',
title: $t('order.syncSuccess'),
icon: 'success'
});
await loadOrderList(orderStatusTabs[currentTab.value].status);
}
} catch (error) {
uni.showToast({
title: '同步状态失败',
title: $t('order.syncFailed'),
icon: 'none'
});
}
@@ -258,7 +268,7 @@
const handlePayment = async (order) => {
try {
uni.showLoading({
title: '处理中'
title: $t('common.processing')
});
// 调用后端创建微信支付订单接口
@@ -279,7 +289,7 @@
...payParams,
success: async () => {
uni.showToast({
title: '支付成功',
title: $t('payment.paymentSuccess'),
icon: 'success'
});
@@ -295,7 +305,7 @@
},
fail: (err) => {
console.error('支付失败:', err);
throw new Error('支付失败,请重试');
throw new Error($t('payment.paymentFailedRetry'));
}
});
} else {
@@ -306,7 +316,7 @@
} catch (error) {
uni.hideLoading();
uni.showToast({
title: error.message || '支付失败',
title: error.message || $t('payment.paymentFailed'),
icon: 'none'
});
}
@@ -316,12 +326,12 @@
const handleCancelOrder = async (order) => {
try {
uni.showModal({
title: '确认取消',
content: '确定要取消此订单吗?',
title: $t('order.confirmCancel'),
content: $t('order.confirmCancelContent'),
success: async (res) => {
if (res.confirm) {
uni.showLoading({
title: '处理中'
title: $t('common.processing')
});
const result = await cancelOrder({
@@ -331,14 +341,14 @@
if (result) {
uni.hideLoading();
uni.showToast({
title: '订单已取消',
title: $t('order.cancelSuccess'),
icon: 'success'
});
// 刷新订单列表
await loadOrderList();
} else {
throw new Error(result.msg || '取消订单失败');
throw new Error(result.msg || $t('order.cancelFailed'));
}
}
}
@@ -346,7 +356,7 @@
} catch (error) {
uni.hideLoading();
uni.showToast({
title: error.message || '取消订单失败',
title: error.message || $t('order.cancelFailed'),
icon: 'none'
});
}
+29 -24
View File
@@ -9,38 +9,38 @@
<!-- 订单信息 -->
<view class="order-card">
<view class="card-title">订单信息</view>
<view class="card-title">{{ $t('payment.orderInfo') }}</view>
<view class="info-item">
<text class="label">订单号</text>
<text class="label">{{ $t('order.orderNo') }}</text>
<text class="value">{{ orderInfo.orderNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">设备号</text>
<text class="label">{{ $t('order.deviceNo') }}</text>
<text class="value">{{ orderInfo.deviceNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">创建时间</text>
<text class="label">{{ $t('payment.createTime') }}</text>
<text class="value">{{ orderInfo.createTime || '-' }}</text>
</view>
<view class="info-item">
<text class="label">联系电话</text>
<text class="label">{{ $t('payment.contactPhone') }}</text>
<text class="value">{{ orderInfo.phone || '-' }}</text>
</view>
</view>
<!-- 费用信息 -->
<view class="price-card">
<view class="card-title">费用信息</view>
<view class="card-title">{{ $t('payment.feeInfo') }}</view>
<view class="price-item">
<text class="label">押金</text>
<text class="label">{{ $t('payment.deposit') }}</text>
<text class="value">{{ orderInfo.deposit || '99.00' }}</text>
</view>
<view class="price-item">
<text class="label">套餐</text>
<text class="value">{{ packageInfo.price }}/{{ packageInfo.time }}小时</text>
<text class="label">{{ $t('payment.package') }}</text>
<text class="value">{{ packageInfo.price }}{{ $t('unit.yuan') }}/{{ packageInfo.time }}{{ $t('time.hour') }}</text>
</view>
<view class="price-item total">
<text class="label">合计</text>
<text class="label">{{ $t('payment.total') }}</text>
<text class="value">{{ totalAmount }}</text>
</view>
</view>
@@ -51,10 +51,10 @@
<!-- 底部操作栏 -->
<view class="bottom-bar">
<view class="total-amount">
<text>合计</text>
<text>{{ $t('payment.total') }}</text>
<text class="amount">{{ totalAmount }}</text>
</view>
<view class="pay-btn" @click="handlePayment">立即支付</view>
<view class="pay-btn" @click="handlePayment">{{ $t('payment.payNow') }}</view>
</view>
</view>
</template>
@@ -81,8 +81,8 @@ export default {
passedTotalAmount: null,
passedDepositAmount: null,
orderStatus: {
text: '等待支付',
desc: '请在15分钟内完成支付',
get text() { return this.$t('payment.waitingForPayment') },
get desc() { return this.$t('payment.pleasePayIn15Min') },
class: 'waiting'
}
}
@@ -117,6 +117,11 @@ export default {
}
},
onLoad(options) {
// 设置页面标题
uni.setNavigationBarTitle({
title: this.$t('payment.orderPayment')
})
if (options && options.orderId) {
this.orderId = options.orderId
@@ -141,9 +146,9 @@ export default {
}
this.loadOrderInfo()
} else {
} else {
uni.showToast({
title: '订单信息不存在',
title: this.$t('order.orderNotExist'),
icon: 'none'
})
setTimeout(() => {
@@ -158,7 +163,7 @@ export default {
async loadOrderInfo() {
try {
uni.showLoading({
title: '加载中'
title: this.$t('common.loading')
})
const res = await queryById(this.orderId)
@@ -238,7 +243,7 @@ export default {
async handlePayment() {
try {
uni.showLoading({
title: '处理中'
title: this.$t('common.processing')
})
// 调用后端创建微信支付订单接口
@@ -259,7 +264,7 @@ export default {
...payParams,
success: async () => {
uni.showToast({
title: '支付成功',
title: this.$t('payment.paymentSuccess'),
icon: 'success'
});
@@ -279,7 +284,7 @@ export default {
},
fail: (err) => {
console.error('支付失败:', err)
throw new Error('支付失败,请重试')
throw new Error(this.$t('payment.paymentFailedRetry'))
}
})
} else {
@@ -298,7 +303,7 @@ export default {
async sendRentCommand() {
try {
uni.showLoading({
title: '处理中'
title: this.$t('common.processing')
})
// 调用发送租借指令的接口
@@ -307,7 +312,7 @@ export default {
if (res.code === 200) {
uni.hideLoading()
uni.showToast({
title: '租借成功',
title: this.$t('device.rentSuccess'),
icon: 'success'
})
@@ -318,12 +323,12 @@ export default {
})
}, 1500)
} else {
throw new Error(res.msg || '租借失败')
throw new Error(res.msg || this.$t('device.rentFailed'))
}
} catch (error) {
uni.hideLoading()
uni.showToast({
title: error.message || '租借失败',
title: error.message || this.$t('device.rentFailed'),
icon: 'none'
})
}
+41 -36
View File
@@ -3,82 +3,82 @@
<!-- 支付成功状态 -->
<view class="status-card">
<view class="status-icon success"></view>
<view class="status-text">归还成功</view>
<view class="status-desc">您的风扇已归还费用已从押金中扣除</view>
<view class="status-text">{{ $t('success.returnSuccess') }}</view>
<view class="status-desc">{{ $t('success.returnSuccessDesc') }}</view>
</view>
<!-- 订单信息 -->
<view class="order-card">
<view class="card-title">订单信息</view>
<view class="card-title">{{ $t('success.orderInfo') }}</view>
<view class="info-item">
<text class="label">订单号</text>
<text class="label">{{ $t('order.orderNo') }}</text>
<text class="value">{{ orderInfo.orderNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">设备号</text>
<text class="label">{{ $t('order.deviceNo') }}</text>
<text class="value">{{ orderInfo.deviceNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">使用时长</text>
<text class="label">{{ $t('success.usedTime') }}</text>
<text class="value">{{ orderInfo.usedTime || '-' }}</text>
</view>
<view class="info-item">
<text class="label">套餐时长</text>
<text class="value">{{ orderInfo.packageTime || '1小时' }}</text>
<text class="label">{{ $t('success.packageTime') }}</text>
<text class="value">{{ orderInfo.packageTime || '1' + $t('time.hour') }}</text>
</view>
<view class="info-item">
<text class="label">超出时长</text>
<text class="value">{{ orderInfo.extraTime || '0分钟' }}</text>
<text class="label">{{ $t('success.extraTime') }}</text>
<text class="value">{{ orderInfo.extraTime || '0' + $t('time.minute') }}</text>
</view>
<view class="info-item">
<text class="label">归还时间</text>
<text class="label">{{ $t('success.returnTime') }}</text>
<text class="value">{{ orderInfo.endTime || '-' }}</text>
</view>
</view>
<!-- 费用信息 -->
<view class="refund-card">
<view class="card-title">费用信息</view>
<view class="card-title">{{ $t('payment.feeInfo') }}</view>
<view class="info-item">
<text class="label">套餐费用</text>
<text class="label">{{ $t('success.packageFee') }}</text>
<text class="value">{{ orderInfo.packagePrice || '0.00' }}</text>
</view>
<view class="info-item">
<text class="label">超时费用</text>
<text class="label">{{ $t('success.extraFee') }}</text>
<text class="value">{{ orderInfo.extraFee || '0.00' }}</text>
</view>
<view class="info-item">
<text class="label">总费用</text>
<text class="label">{{ $t('success.totalFee') }}</text>
<text class="value">{{ orderInfo.currentFee || '0.00' }}</text>
</view>
<view class="info-item">
<text class="label">押金</text>
<text class="label">{{ $t('success.depositAmount') }}</text>
<text class="value">{{ orderInfo.deposit || '99.00' }}</text>
</view>
<view class="info-item">
<text class="label">退还金额</text>
<text class="label">{{ $t('success.refundAmount') }}</text>
<text class="value highlight">{{ orderInfo.refundAmount || '99.00' }}</text>
</view>
<view class="info-item">
<text class="label">退还状态</text>
<text class="label">{{ $t('success.refundStatus') }}</text>
<text class="value" :class="orderInfo.withdrawStatus || 'waiting'">{{ getWithdrawStatusText() }}</text>
</view>
</view>
<!-- 退款说明卡片 -->
<view class="notice-card">
<view class="card-title">退款说明</view>
<view class="card-title">{{ $t('success.refundNotice') }}</view>
<view class="notice-content">
<view>1. 押金剩余金额需要您手动申请提现</view>
<view>2. 提现申请提交后将在1-3个工作日内退还到原支付账户</view>
<view>3. 如有疑问请联系客服</view>
<view>1. {{ $t('success.refundNotice1') }}</view>
<view>2. {{ $t('success.refundNotice2') }}</view>
<view>3. {{ $t('success.refundNotice3') }}</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="button-group">
<button class="primary-btn" @click="handleWithdraw" v-if="!orderInfo.isWithdrawn && orderInfo.refundAmount > 0">申请退款</button>
<button class="primary-btn" @click="goToHome">返回首页</button>
<button class="primary-btn" @click="handleWithdraw" v-if="!orderInfo.isWithdrawn && orderInfo.refundAmount > 0">{{ $t('success.applyRefund') }}</button>
<button class="primary-btn" @click="goToHome">{{ $t('success.backToHome') }}</button>
</view>
</view>
</template>
@@ -107,12 +107,17 @@ export default {
}
},
onLoad(options) {
// 设置页面标题
uni.setNavigationBarTitle({
title: this.$t('success.returnSuccess')
})
if (options && options.orderId) {
this.orderId = options.orderId;
this.loadOrderInfo();
} else {
uni.showToast({
title: '订单ID不能为空',
title: this.$t('order.orderIdRequired'),
icon: 'none'
});
setTimeout(() => {
@@ -124,18 +129,18 @@ export default {
// 获取退款状态文本
getWithdrawStatusText() {
const statusMap = {
'waiting': '待申请',
'processing': '处理中',
'success': '已退款',
'failed': '退款失败'
'waiting': this.$t('success.refundWaiting'),
'processing': this.$t('success.refundProcessing'),
'success': this.$t('success.refundSuccess'),
'failed': this.$t('success.refundFailed')
};
return statusMap[this.orderInfo.withdrawStatus] || '待申请';
return statusMap[this.orderInfo.withdrawStatus] || this.$t('success.refundWaiting');
},
// 加载订单信息
async loadOrderInfo() {
try {
uni.showLoading({ title: '加载中' });
uni.showLoading({ title: this.$t('common.loading') });
const result = await queryById(this.orderId);
if (result.code === 200 && result.data) {
@@ -216,7 +221,7 @@ export default {
} catch (error) {
console.error('加载订单信息错误:', error);
uni.showToast({
title: error.message || '获取订单信息失败',
title: error.message || this.$t('order.getOrderFailed'),
icon: 'none'
});
} finally {
@@ -227,7 +232,7 @@ export default {
// 申请退款
async handleWithdraw() {
try {
uni.showLoading({ title: '处理中' });
uni.showLoading({ title: this.$t('common.processing') });
const res = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/withdraw/add/${this.orderInfo.orderNo}`,
@@ -241,7 +246,7 @@ export default {
if (res.statusCode === 200 && res.data.code === 200) {
uni.showToast({
title: '退款申请成功',
title: this.$t('order.refundSuccess'),
icon: 'success'
});
@@ -254,12 +259,12 @@ export default {
this.loadOrderInfo();
}, 1500);
} else {
throw new Error(res.data.msg || '退款申请失败');
throw new Error(res.data.msg || this.$t('order.refundFailed'));
}
} catch (error) {
console.error('退款申请错误:', error);
uni.showToast({
title: error.message || '退款申请失败',
title: error.message || this.$t('order.refundFailed'),
icon: 'none'
});
} finally {
+26 -19
View File
@@ -3,27 +3,27 @@
<!-- 支付成功状态 -->
<view class="status-card">
<view class="status-icon success"></view>
<view class="status-text">支付成功</view>
<view class="status-desc">您的订单已支付成功</view>
<view class="status-text">{{ $t('success.paymentSuccess') }}</view>
<view class="status-desc">{{ $t('success.paymentSuccessDesc') }}</view>
</view>
<!-- 订单信息 -->
<view class="order-card">
<view class="card-title">订单信息</view>
<view class="card-title">{{ $t('success.orderInfo') }}</view>
<view class="info-item">
<text class="label">订单号</text>
<text class="label">{{ $t('order.orderNo') }}</text>
<text class="value">{{ orderInfo.orderNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">设备号</text>
<text class="label">{{ $t('order.deviceNo') }}</text>
<text class="value">{{ orderInfo.deviceNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">支付金额</text>
<text class="label">{{ $t('success.paymentAmount') }}</text>
<text class="value">{{ orderInfo.amount || '0.00' }}</text>
</view>
<view class="info-item">
<text class="label">支付时间</text>
<text class="label">{{ $t('success.paymentTime') }}</text>
<text class="value">{{ orderInfo.payTime || '-' }}</text>
</view>
</view>
@@ -38,8 +38,8 @@
<!-- 操作按钮 -->
<view class="button-group">
<button class="primary-btn" @click="goToHome">返回首页</button>
<button class="secondary-btn" @click="goToOrderList">查看订单</button>
<button class="primary-btn" @click="goToHome">{{ $t('success.backToHome') }}</button>
<button class="secondary-btn" @click="goToOrderList">{{ $t('success.viewOrder') }}</button>
</view>
</view>
</template>
@@ -54,11 +54,18 @@ export default {
orderId: '',
orderInfo: {},
isLoading: true,
deviceMessage: '正在准备您的设备,请稍候...',
deviceMessage: '',
hasTriggeredDevice: false
}
},
onLoad(options) {
// 设置页面标题
uni.setNavigationBarTitle({
title: this.$t('success.paymentSuccess')
})
this.deviceMessage = this.$t('success.preparingDevice')
if (options && options.orderId) {
this.orderId = options.orderId
this.loadOrderInfo()
@@ -70,7 +77,7 @@ export default {
})
} else {
uni.showToast({
title: '订单信息不存在',
title: this.$t('order.orderNotExist'),
icon: 'none'
})
setTimeout(() => {
@@ -82,7 +89,7 @@ export default {
async loadOrderInfo() {
try {
uni.showLoading({
title: '加载中'
title: this.$t('common.loading')
})
const res = await queryById(this.orderId)
@@ -118,7 +125,7 @@ export default {
} catch (error) {
uni.hideLoading()
uni.showToast({
title: error.message || '获取订单信息失败',
title: error.message || this.$t('order.getOrderFailed'),
icon: 'none'
})
}
@@ -134,7 +141,7 @@ export default {
this.hasTriggeredDevice = true
uni.$emit('orderSuccess:' + this.orderId)
this.isLoading = true
this.deviceMessage = '正在准备您的设备,请稍候...'
this.deviceMessage = this.$t('success.preparingDevice')
try {
console.log(`准备触发弹出风扇,orderId: ${this.orderId}`)
@@ -144,19 +151,19 @@ export default {
console.log('确认支付并弹出风扇结果:', JSON.stringify(result))
if (result && result.code === 200) {
this.deviceMessage = '设备已弹出,请取走您的风扇'
this.deviceMessage = this.$t('success.deviceReady')
uni.showToast({
title: '风扇已弹出',
title: this.$t('success.deviceReady'),
icon: 'success'
})
} else {
throw new Error((result && result.msg) || '弹出风扇失败')
throw new Error((result && result.msg) || this.$t('success.deviceFailed'))
}
} catch (error) {
console.error('弹出风扇错误:', error)
this.deviceMessage = '弹出设备失败,请联系客服'
this.deviceMessage = this.$t('success.deviceFailed')
uni.showToast({
title: error.message || '弹出风扇失败,请联系客服',
title: error.message || this.$t('success.deviceFailed'),
icon: 'none'
})
} finally {