调用wx.scanCode扫码解析出path中的参数
var that = this
// 只允许从相机扫码
wx.scanCode({
onlyFromCamera: true,
scanType: ['qrCode'],
success(res) {
console.log(res)
if (res.path) {//合法本小程序路径
var str = res.path
var index = str.indexOf("=");//截取=符号后面的字符串
var scene = str.substr(index + 1, str.length); //获得=符号后面所有字符
var type = parseInt(scene[0])
// console.log(type)
//console.log(scene[2])
if (type == 3) {
that.setData({
oil_station_id: scene[2]
})
//执行获得参数后的操作
}
}
}
})
网友评论