fix:兼容普通二维码跳转
This commit is contained in:
+21
-1
@@ -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}`
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user