Commit 3dff4007 authored by 肖健's avatar 肖健

适配扫二维码打开绑定挪车码或者通知车主

parent fbbf8b59
......@@ -105,32 +105,36 @@
uni.scanCode({
success: (res) => {
this.scanClick = true
let path = res.path
if (path) {
let paths = path.split('?')[1]
let scene = paths.split("=")[1]
// this.$http.request({
// url:'/app/user/c/m/c',
// method:'post',
// data:{
// code: scene
// },
// }).then(res => {
// console.log(res, "扫码通知车主")
// if (res.bindFlag) {
// that.gotoMoveCar(scene)
// } else {
// that.gotoBindMoveCar(scene)
// }
// })
this.goScene(scene)
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
if(res.errMsg === 'scanCode:ok') {
let scanType = res.scanType
let path = ''
//扫的小程序码
if(scanType === 'WX_CODE') {
path = res.path
}
//扫的二维码
if(scanType === 'QR_CODE') {
path = res.result
}
if (path) {
let paths = path.split('?')[1]
let scene = paths.split("=")[1]
this.goScene(scene)
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
},
fail: () => {
this.scanClick = true
......@@ -255,6 +259,18 @@
}
},
onLoad(option) {
//扫码二维码进入小程序
if(option.q) {
let q = decodeURIComponent(option.q)
let paths = q.split('?')[1]
let sceneParam = paths.split("=")[1]
//设置option里面的scene参数,以供接下来流程使用
option.scene = sceneParam
//清空二维码的q参数值
option.q = null
}
// 静默授权获取openid
let openid = uni.getStorageSync('openid');
if (!openid) {
......@@ -331,27 +347,6 @@
//获取二维码携带的参数
//扫码后得到的参数
this.goScene(that.scene)
// that.http.httpTokenRequest({
// url: '/app/user/c/m/c',
// method: 'post'
// }, {
// code: that.scene
// }).then(res => {
// if (res.data.code == 200) {
// if (res.data.data.bindFlag) {
// that.gotoMoveCar(that.scene);
// } else {
// that.gotoBindMoveCar(that.scene);
// }
// uni.removeStorageSync('scene')
// } else {
// uni.showToast({
// title: res.data.msg,
// icon: 'none',
// duration: 2000
// });
// }
// })
} else{
let routerLogin = uni.getStorageSync('routerLogin')
let tabbar = uni.getStorageSync('tabbar')
......
......@@ -124,31 +124,48 @@
uni.scanCode({
success: (res) => {
this.scanClick = true
let path = res.path
if (path) {
let paths = path.split('?')[1]
let scene = paths.split("=")[1]
this.$http.request({
url:'/app/user/c/m/c',
method:'post',
data:{
code: scene
},
}).then(res => {
console.log(res, "扫码通知车主")
if (res.bindFlag) {
that.gotoMoveCar(scene)
} else {
that.gotoBindMoveCar(scene)
}
})
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
if(res.errMsg === 'scanCode:ok') {
let scanType = res.scanType
let path = ''
//扫的小程序码
if(scanType === 'WX_CODE') {
path = res.path
}
//扫的二维码
if(scanType === 'QR_CODE') {
path = res.result
}
if (path) {
let paths = path.split('?')[1]
let scene = paths.split("=")[1]
this.$http.request({
url:'/app/user/c/m/c',
method:'post',
data:{
code: scene
},
}).then(res => {
console.log(res, "扫码通知车主")
if (res.bindFlag) {
that.gotoMoveCar(scene)
} else {
that.gotoBindMoveCar(scene)
}
})
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
},
fail: () => {
this.scanClick = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment