From 802aee59cb72bc6d5a79e61ad4e8f67c8fa3a775 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Wed, 18 Mar 2026 16:41:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=85=BC=E5=AE=B9=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/url.js | 4 +- pages/device/detail.vue | 22 +++++++++- subPackages/other/serve/bagCheck/index.vue | 48 +++++++++++----------- 3 files changed, 48 insertions(+), 26 deletions(-) diff --git a/config/url.js b/config/url.js index 6526cb1..2b176f2 100644 --- a/config/url.js +++ b/config/url.js @@ -1,7 +1,7 @@ // export const URL = "https://my.gxfs123.com/api" //正式服务器-弃用 -// export const URL = "https://manager.fdzpower.com/api" //正式服务器 +export const URL = "https://manager.fdzpower.com/api" //正式服务器 // export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 -export const URL = "http://192.168.5.58:8080" //本地调试 +// export const URL = "http://192.168.5.58:8080" //本地调试 // export const URL = "http://127.0.0.1:8080" //本地调试 export const appid = "wx2165f0be356ae7a9" //微信小程序appid diff --git a/pages/device/detail.vue b/pages/device/detail.vue index 2186ce3..e40f5e4 100644 --- a/pages/device/detail.vue +++ b/pages/device/detail.vue @@ -181,6 +181,27 @@ // 生命周期 onLoad 钩子 onLoad(async (options) => { + console.log('options', options) + + // 普通链接二维码进入时,参数通常在 options.q(且为编码后的完整 URL) + if (!options.deviceNo && options.q) { + const fullUrl = decodeURIComponent(options.q) + const queryStr = fullUrl.includes('?') ? fullUrl.split('?')[1] : '' + if (queryStr) { + const params = queryStr.split('&').reduce((acc, pair) => { + if (!pair) return acc + const idx = pair.indexOf('=') + const rawKey = idx >= 0 ? pair.slice(0, idx) : pair + const rawVal = idx >= 0 ? pair.slice(idx + 1) : '' + const key = decodeURIComponent(rawKey || '').trim() + const val = decodeURIComponent(rawVal || '').trim() + if (key) acc[key] = val + return acc + }, {}) + if (params.deviceNo) options.deviceNo = params.deviceNo + } + } + if (options.deviceNo != uni.getStorageSync('deviceId') || !uni.getStorageSync('deviceId')) { deviceId.value = options.deviceNo uni.setStorageSync('deviceId', options.deviceNo) @@ -427,7 +448,6 @@ if (inUseRes && inUseRes.code === 200 && inUseRes.data) { const order = inUseRes.data // 如果有正在进行的订单,跳转到归还页面,带上设备ID - console.log('1111111111'); uni.redirectTo({ url: `/subPackages/service/return/index?deviceId=${deviceId.value}` }) diff --git a/subPackages/other/serve/bagCheck/index.vue b/subPackages/other/serve/bagCheck/index.vue index 54cf1cd..b557995 100644 --- a/subPackages/other/serve/bagCheck/index.vue +++ b/subPackages/other/serve/bagCheck/index.vue @@ -25,12 +25,12 @@ }, async onLoad(option) { console.log('bagCheck onLoad option:', option); - + // 设置页面标题 uni.setNavigationBarTitle({ title: this.$t('device.checking') }) - + try { uni.showLoading({ title: this.$t('common.processing'), @@ -43,7 +43,7 @@ } const deviceNo = option.deviceNo; - + // 检查用户是否有进行中(in_used)或待支付(waiting_for_payment)的订单 const statusesToCheck = ['in_used', 'waiting_for_payment']; const res = await checkOrdersByStatus(deviceNo, statusesToCheck); @@ -61,25 +61,25 @@ } else if (latestOrder.orderStatus === 'waiting_for_payment') { // 如果是待支付订单,跳转到支付页面,并传递必要信息 console.log('检测到待支付订单,跳转支付页:', latestOrder.orderId); - + // 获取套餐时间(分钟) const packageTimeMinutes = latestOrder.packageTime || 60; - + // 套餐小时数 const packageTimeHours = (packageTimeMinutes / 60).toFixed(1); - + // 套餐价格 const packagePrice = latestOrder.packagePrice || '0.00'; - + // 计算每小时费率 const hourlyRate = (parseFloat(packagePrice) / (packageTimeMinutes / 60)).toFixed(2); - + // 押金金额 const depositAmount = latestOrder.depositAmount || '99.00'; - + // 计算总金额(套餐+押金) const totalAmount = (parseFloat(depositAmount) + parseFloat(packagePrice)).toFixed(2); - + uni.redirectTo({ url: `/pages/order/payment?orderId=${latestOrder.orderId}&packageTimeHours=${packageTimeHours}&packagePrice=${packagePrice}&hourlyRate=${hourlyRate}&totalAmount=${totalAmount}&depositAmount=${depositAmount}` }); @@ -100,10 +100,10 @@ } catch (error) { // 只处理真正的错误,不是"没有订单"的情况 if (error.message && ( - error.message.includes('未识别到设备编号') || - error.message.includes('网络请求失败') || - error.message.includes('服务器错误') - ) ) { + error.message.includes('未识别到设备编号') || + error.message.includes('网络请求失败') || + error.message.includes('服务器错误') + )) { console.error('扫码检查订单失败:', error); uni.showToast({ title: error.message || this.$t('device.processFailed'), @@ -114,20 +114,22 @@ // 对于其他错误,包括"没有找到订单",直接跳转到详情页,不显示错误消息 console.log('没有找到符合条件的订单或发生其他错误,直接跳转详情页'); } - + // 无论什么情况,都跳转到一个可用页面 setTimeout(() => { - if (option && option.deviceNo) { - uni.redirectTo({ - url: `/pages/device/detail?deviceNo=${option.deviceNo}` - }); - } else { + if (option && option.deviceNo) { + uni.redirectTo({ + url: `/pages/device/detail?deviceNo=${option.deviceNo}` + }); + } else { // uni.switchTab({ // url:'/pages/index/index' // }) - // 如果连deviceNo都没有,则返回首页 - uni.reLaunch({ url: '/pages/index/index' }); - } + // 如果连deviceNo都没有,则返回首页 + uni.reLaunch({ + url: '/pages/index/index' + }); + } }, 2000); } finally { uni.hideLoading();