feat: 添加订单支付和成功页面,更新订单状态逻辑
新增了订单支付页面和支付成功页面,分别用于处理用户的支付流程和展示支付结果。同时,更新了订单状态的逻辑,确保在订单列表中正确显示各个状态。调整了设备租借逻辑,优化了扫码处理流程,提升用户体验。
This commit is contained in:
+56
-12
@@ -51,22 +51,66 @@
|
||||
import {getQueryString }from '@/util/index.js'
|
||||
export default {
|
||||
methods: {
|
||||
handleScan() {
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
let deviceNo = getQueryString(res.path,'deviceNo')
|
||||
console.log(res.path);
|
||||
async handleScan() {
|
||||
try {
|
||||
const scanResult = await new Promise((resolve, reject) => {
|
||||
uni.scanCode({
|
||||
success: resolve,
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
|
||||
let deviceNo = getQueryString(scanResult.path, 'deviceNo')
|
||||
console.log('扫码路径:', scanResult.path)
|
||||
|
||||
// 检查是否有使用中的订单
|
||||
const inUseRes = await uni.request({
|
||||
url: `${uni.getStorageSync('baseUrl') || 'http://127.0.0.1:8080'}/app/order/inUse`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Authorization': "Bearer " + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
}
|
||||
})
|
||||
|
||||
if (inUseRes.statusCode === 200 && inUseRes.data.code === 200 && inUseRes.data.data) {
|
||||
// 存在使用中的订单,跳转到归还页面
|
||||
const inUseOrder = inUseRes.data.data
|
||||
uni.navigateTo({
|
||||
url: `/pages/return/index?orderId=${inUseOrder.orderId}&deviceId=${deviceNo}`
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否有待支付订单
|
||||
const orderRes = await uni.request({
|
||||
url: `${uni.getStorageSync('baseUrl') || 'http://127.0.0.1:8080'}/app/order/unpaid`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Authorization': "Bearer " + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
}
|
||||
})
|
||||
|
||||
if (orderRes.statusCode === 200 && orderRes.data.code === 200 && orderRes.data.data) {
|
||||
// 存在待支付订单,跳转到支付页面
|
||||
const unpaidOrder = orderRes.data.data
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
|
||||
})
|
||||
} else {
|
||||
// 无待支付订单,正常跳转到设备检查页面
|
||||
uni.navigateTo({
|
||||
url: `/pages/serve/bagCheck/index?deviceNo=${deviceNo}`
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: '扫码失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('扫码处理失败:', error)
|
||||
uni.showToast({
|
||||
title: '扫码失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user