|
@@ -292,7 +292,30 @@
|
|
|
let _this = this
|
|
let _this = this
|
|
|
uni.scanCode({
|
|
uni.scanCode({
|
|
|
success: function(res) {
|
|
success: function(res) {
|
|
|
- _this.scantoRouter(res.result)
|
|
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ // 获取扫描结果中的URL
|
|
|
|
|
+ const scanResult = res.result
|
|
|
|
|
+ // 检查URL是否包含traceability
|
|
|
|
|
+ if(scanResult && scanResult.includes('/traceability')) {
|
|
|
|
|
+ // 从扫描结果中提取id参数
|
|
|
|
|
+ let id = ''
|
|
|
|
|
+ if(scanResult.includes('id=')) {
|
|
|
|
|
+ // 分割URL获取id参数值
|
|
|
|
|
+ const idPart = scanResult.split('id=')[1]
|
|
|
|
|
+ // 如果id后面还有其他参数,只取到第一个&之前的部分
|
|
|
|
|
+ if(idPart.includes('&')) {
|
|
|
|
|
+ id = idPart.split('&')[0]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ id = idPart
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 跳转到溯源页面并传递id
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `pages/traceability/scanCode/index?id=${id}`
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ _this.scantoRouter(scanResult)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|