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

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

parent fbbf8b59
...@@ -105,32 +105,36 @@ ...@@ -105,32 +105,36 @@
uni.scanCode({ uni.scanCode({
success: (res) => { success: (res) => {
this.scanClick = true this.scanClick = true
let path = res.path
if (path) { if(res.errMsg === 'scanCode:ok') {
let paths = path.split('?')[1] let scanType = res.scanType
let scene = paths.split("=")[1] let path = ''
// this.$http.request({ //扫的小程序码
// url:'/app/user/c/m/c', if(scanType === 'WX_CODE') {
// method:'post', path = res.path
// data:{ }
// code: scene //扫的二维码
// }, if(scanType === 'QR_CODE') {
// }).then(res => { path = res.result
// console.log(res, "扫码通知车主") }
// if (res.bindFlag) {
// that.gotoMoveCar(scene) if (path) {
// } else { let paths = path.split('?')[1]
// that.gotoBindMoveCar(scene) let scene = paths.split("=")[1]
// } this.goScene(scene)
// }) } else {
this.goScene(scene) uni.showToast({
} else { title: "扫码失败!",
uni.showToast({ icon: 'error',
title: "扫码失败!", })
icon: 'error', }
}) } else {
} uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
}, },
fail: () => { fail: () => {
this.scanClick = true this.scanClick = true
...@@ -255,6 +259,18 @@ ...@@ -255,6 +259,18 @@
} }
}, },
onLoad(option) { 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 // 静默授权获取openid
let openid = uni.getStorageSync('openid'); let openid = uni.getStorageSync('openid');
if (!openid) { if (!openid) {
...@@ -331,27 +347,6 @@ ...@@ -331,27 +347,6 @@
//获取二维码携带的参数 //获取二维码携带的参数
//扫码后得到的参数 //扫码后得到的参数
this.goScene(that.scene) 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{ } else{
let routerLogin = uni.getStorageSync('routerLogin') let routerLogin = uni.getStorageSync('routerLogin')
let tabbar = uni.getStorageSync('tabbar') let tabbar = uni.getStorageSync('tabbar')
......
...@@ -124,31 +124,48 @@ ...@@ -124,31 +124,48 @@
uni.scanCode({ uni.scanCode({
success: (res) => { success: (res) => {
this.scanClick = true this.scanClick = true
if(res.errMsg === 'scanCode:ok') {
let path = res.path let scanType = res.scanType
if (path) { let path = ''
let paths = path.split('?')[1] //扫的小程序码
let scene = paths.split("=")[1] if(scanType === 'WX_CODE') {
this.$http.request({ path = res.path
url:'/app/user/c/m/c', }
method:'post', //扫的二维码
data:{ if(scanType === 'QR_CODE') {
code: scene path = res.result
}, }
}).then(res => { if (path) {
console.log(res, "扫码通知车主") let paths = path.split('?')[1]
if (res.bindFlag) { let scene = paths.split("=")[1]
that.gotoMoveCar(scene) this.$http.request({
} else { url:'/app/user/c/m/c',
that.gotoBindMoveCar(scene) method:'post',
} data:{
}) code: scene
} else { },
uni.showToast({ }).then(res => {
title: "扫码失败!", console.log(res, "扫码通知车主")
icon: 'error', if (res.bindFlag) {
}) that.gotoMoveCar(scene)
} } else {
that.gotoBindMoveCar(scene)
}
})
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
} else {
uni.showToast({
title: "扫码失败!",
icon: 'error',
})
}
}, },
fail: () => { fail: () => {
this.scanClick = true 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