feat:
取消了订单轮询 更新押金提现及订单查询功能 归还成功之后不会有归还成功的弹窗出现 提现的判断目前判断押金状态和订单状态 修改了提现API的参数名称,从订单ID更改为订单号,并新增了根据设备号和状态查询订单列表的功能。同时,优化了用户在提现过程中的错误提示,确保用户能够获得更清晰的反馈。更新了多个页面的逻辑,提升了整体用户体验。
This commit is contained in:
@@ -9,9 +9,15 @@
|
||||
wxLogin,
|
||||
} from '../../../util/index'
|
||||
|
||||
import {
|
||||
getMyIndexInfo
|
||||
} from "../../../config/user.js";
|
||||
import {
|
||||
queryHasOrder
|
||||
} from '@/config/user.js'
|
||||
} from "../../../config/user.js";
|
||||
import {
|
||||
checkOrdersByStatus
|
||||
} from "../../../config/user.js";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -20,46 +26,79 @@
|
||||
}
|
||||
},
|
||||
async onLoad(option) {
|
||||
console.log('bagCheck onLoad option:', option);
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
title: '处理中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
if (!uni.getStorageSync('token')) {
|
||||
await wxLogin();
|
||||
// 检查是否传入设备编号
|
||||
if (!option || !option.deviceNo) {
|
||||
throw new Error('未识别到设备编号');
|
||||
}
|
||||
|
||||
if (!option.deviceNo) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '设备编号不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
const deviceNo = option.deviceNo;
|
||||
|
||||
// 查询用户是否有使用中(in_used)的订单
|
||||
const result = await queryHasOrder(option.deviceNo);
|
||||
uni.hideLoading();
|
||||
// 检查用户是否有进行中(in_used)或待支付(waiting_for_payment)的订单
|
||||
const statusesToCheck = ['in_used', 'waiting_for_payment'];
|
||||
const res = await checkOrdersByStatus(deviceNo, statusesToCheck);
|
||||
|
||||
if (result.data && result.data.data && result.data.data.length > 0) {
|
||||
// 如果有使用中的订单,直接跳转到归还页面
|
||||
uni.redirectTo({
|
||||
url: `/pages/device/return?deviceNo=${option.deviceNo}`
|
||||
});
|
||||
if (res.code === 200 && res.data && res.data.length > 0) {
|
||||
// 找到相关订单,取最新的一条
|
||||
const latestOrder = res.data[0]; // 假设返回结果按时间倒序
|
||||
|
||||
if (latestOrder.orderStatus === 'in_used') {
|
||||
// 如果是使用中的订单,跳转到归还页面
|
||||
console.log('检测到使用中订单,跳转归还页:', latestOrder.orderId);
|
||||
uni.redirectTo({
|
||||
url: `/pages/device/return?orderId=${latestOrder.orderId}`
|
||||
});
|
||||
} else if (latestOrder.orderStatus === 'waiting_for_payment') {
|
||||
// 如果是待支付订单,跳转到支付页面,并传递必要信息
|
||||
console.log('检测到待支付订单,跳转支付页:', latestOrder.orderId);
|
||||
const packageTime = latestOrder.packageTime ? `${latestOrder.packageTime / 60}小时` : '默认套餐'; // 示例转换
|
||||
const packagePrice = latestOrder.packagePrice || '0.00';
|
||||
const depositAmount = latestOrder.depositAmount || '99.00';
|
||||
const totalAmount = (parseFloat(depositAmount) + parseFloat(packagePrice)).toFixed(2);
|
||||
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/payment?orderId=${latestOrder.orderId}&packageTime=${packageTime}&packagePrice=${packagePrice}&totalAmount=${totalAmount}&depositAmount=${depositAmount}`
|
||||
});
|
||||
} else {
|
||||
// 其他状态(理论上不应该到这里,除非statusesToCheck配置错误),默认到详情页
|
||||
console.log('检测到其他状态订单,跳转详情页:', latestOrder.orderId);
|
||||
uni.redirectTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 如果没有使用中的订单,跳转到设备详情页面进行租借
|
||||
// 没有找到相关状态的订单,跳转到设备详情页进行租借
|
||||
console.log('未检测到相关订单,跳转详情页');
|
||||
uni.redirectTo({
|
||||
url: `/pages/device/detail?deviceNo=${option.deviceNo}`
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('扫码检查订单失败:', error);
|
||||
uni.showToast({
|
||||
title: '页面加载失败,请重试',
|
||||
icon: 'none'
|
||||
title: error.message || '处理失败,请稍后重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
console.error('bagCheck onLoad error:', error);
|
||||
// 错误时也尝试跳转到详情页,给用户一个操作入口
|
||||
setTimeout(() => {
|
||||
if (option && option.deviceNo) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/device/detail?deviceNo=${option.deviceNo}`
|
||||
});
|
||||
} else {
|
||||
// 如果连deviceNo都没有,则返回首页
|
||||
uni.switchTab({ url: '/pages/index/index' });
|
||||
}
|
||||
}, 2000);
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user