fix:修复bug
This commit is contained in:
+35
-41
@@ -46,7 +46,8 @@
|
||||
getOrderList,
|
||||
queryById,
|
||||
getOrderByOrderNoScorePayStatus,
|
||||
cancelOrder
|
||||
cancelOrder,
|
||||
createWxPayment
|
||||
} from '../../config/api/order.js';
|
||||
import {
|
||||
confirmPaymentAndRent
|
||||
@@ -59,7 +60,7 @@
|
||||
} from '../../config/url.js';
|
||||
import { useI18n } from '@/utils/i18n.js'
|
||||
|
||||
const { t: $t } = useI18n()
|
||||
const { t } = useI18n()
|
||||
|
||||
// 初始化状态
|
||||
const currentTab = ref(0);
|
||||
@@ -68,62 +69,62 @@
|
||||
// 订单状态映射
|
||||
const orderStatusMap = reactive({
|
||||
'0': {
|
||||
get text() { return $t('order.waitingForPayment') },
|
||||
get text() { return t('order.waitingForPayment') },
|
||||
class: 'status-waiting'
|
||||
},
|
||||
'1': {
|
||||
get text() { return $t('order.inUse') },
|
||||
get text() { return t('order.inUse') },
|
||||
class: 'status-using'
|
||||
},
|
||||
'2': {
|
||||
get text() { return $t('order.finished') },
|
||||
get text() { return t('order.finished') },
|
||||
class: 'status-finished'
|
||||
},
|
||||
'3': {
|
||||
get text() { return $t('order.cancelled') },
|
||||
get text() { return t('order.cancelled') },
|
||||
class: 'status-cancelled'
|
||||
},
|
||||
'waiting_for_payment': {
|
||||
get text() { return $t('order.waitingForPayment') },
|
||||
get text() { return t('order.waitingForPayment') },
|
||||
class: 'status-waiting'
|
||||
},
|
||||
'in_used': {
|
||||
get text() { return $t('order.inUse') },
|
||||
get text() { return t('order.inUse') },
|
||||
class: 'status-using'
|
||||
},
|
||||
'used_done': {
|
||||
get text() { return $t('order.finished') },
|
||||
get text() { return t('order.finished') },
|
||||
class: 'status-finished'
|
||||
},
|
||||
'order_cancelled': {
|
||||
get text() { return $t('order.cancelled') },
|
||||
get text() { return t('order.cancelled') },
|
||||
class: 'status-cancelled'
|
||||
},
|
||||
'express_return': {
|
||||
get text() { return $t('express.title') },
|
||||
get text() { return t('express.title') },
|
||||
class: 'status-express-return'
|
||||
}
|
||||
});
|
||||
|
||||
// 订单状态标签
|
||||
const orderStatusTabs = reactive([{
|
||||
get text() { return $t('common.all') },
|
||||
get text() { return t('common.all') },
|
||||
status: []
|
||||
},
|
||||
{
|
||||
get text() { return $t('order.waitingForPayment') },
|
||||
get text() { return t('order.waitingForPayment') },
|
||||
status: ['waiting_for_payment']
|
||||
},
|
||||
{
|
||||
get text() { return $t('order.inUse') },
|
||||
get text() { return t('order.inUse') },
|
||||
status: ['in_used']
|
||||
},
|
||||
{
|
||||
get text() { return $t('order.finished') },
|
||||
get text() { return t('order.finished') },
|
||||
status: ['used_done']
|
||||
},
|
||||
{
|
||||
get text() { return $t('order.cancelled') },
|
||||
get text() { return t('order.cancelled') },
|
||||
status: ['order_cancelled']
|
||||
}
|
||||
]);
|
||||
@@ -216,7 +217,7 @@
|
||||
} catch (error) {
|
||||
console.error('获取订单列表失败:', error);
|
||||
uni.showToast({
|
||||
title: $t('order.getOrderListFailed'),
|
||||
title: t('order.getOrderListFailed'),
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
@@ -233,7 +234,7 @@
|
||||
// 设置页面标题并监听订单完成事件
|
||||
onMounted(() => {
|
||||
uni.setNavigationBarTitle({
|
||||
title: $t('order.myOrders')
|
||||
title: t('order.myOrders')
|
||||
})
|
||||
|
||||
// 监听订单完成事件
|
||||
@@ -251,14 +252,14 @@
|
||||
const res = await getOrderByOrderNoScorePayStatus(order.orderNo);
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: $t('order.syncSuccess'),
|
||||
title: t('order.syncSuccess'),
|
||||
icon: 'success'
|
||||
});
|
||||
await loadOrderList(orderStatusTabs[currentTab.value].status);
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: $t('order.syncFailed'),
|
||||
title: t('order.syncFailed'),
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
@@ -285,28 +286,21 @@
|
||||
const handlePayment = async (order) => {
|
||||
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/wx-payment/create/${order.orderNo}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Authorization': "Bearer " + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
}
|
||||
});
|
||||
const res = await createWxPayment(order.orderNo);
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
const payParams = res.data.data;
|
||||
if (res && res.code === 200) {
|
||||
const payParams = res.data;
|
||||
|
||||
// 调用微信支付
|
||||
await uni.requestPayment({
|
||||
...payParams,
|
||||
success: async () => {
|
||||
uni.showToast({
|
||||
title: $t('payment.paymentSuccess'),
|
||||
title: t('payment.paymentSuccess'),
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
@@ -322,18 +316,18 @@
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('支付失败:', err);
|
||||
throw new Error($t('payment.paymentFailedRetry'));
|
||||
throw new Error(t('payment.paymentFailedRetry'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new Error(res.data.msg || '创建支付订单失败');
|
||||
throw new Error(res?.msg || '创建支付订单失败');
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: error.message || $t('payment.paymentFailed'),
|
||||
title: error.message || t('payment.paymentFailed'),
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
@@ -343,12 +337,12 @@
|
||||
const handleCancelOrder = async (order) => {
|
||||
try {
|
||||
uni.showModal({
|
||||
title: $t('order.confirmCancel'),
|
||||
content: $t('order.confirmCancelContent'),
|
||||
title: t('order.confirmCancel'),
|
||||
content: t('order.confirmCancelContent'),
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: $t('common.processing')
|
||||
title: t('common.processing')
|
||||
});
|
||||
|
||||
const result = await cancelOrder({
|
||||
@@ -358,14 +352,14 @@
|
||||
if (result) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: $t('order.cancelSuccess'),
|
||||
title: t('order.cancelSuccess'),
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
// 刷新订单列表
|
||||
await loadOrderList();
|
||||
} else {
|
||||
throw new Error(result.msg || $t('order.cancelFailed'));
|
||||
throw new Error(result.msg || t('order.cancelFailed'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +367,7 @@
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: error.message || $t('order.cancelFailed'),
|
||||
title: error.message || t('order.cancelFailed'),
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user