收藏
回答

wx.scanCode 扫描自定义二维码成功后直接跳转到小程序首页

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.scanCode 客户端 6.7.2 2.3.2

- 当前 Bug 的表现(可附上截图)

扫码成功之后自动跳转到小程序首页,仅在苹果手机上出现,IOS版本12.1,

扫描二维码:

- 预期表现

停留在打开扫码框打开页面并对数据进行赋值


- 复现路径

微信登陆-》添加设备-》点击“扫描二维码添加设备”-》扫描上面提供的二维码


- 提供一个最简复现 Demo

AddScan: function () {

var that = this;

wx.scanCode({

scanType: ['qrCode'],

success: (res) => {

var str = res.result.split('=');

if (str.length < 2) {

wx.showModal({

title: '错误提示',

content: '二维码格式不正确!',

confirmColor: '#9ca9e9'

});

return;

} else if (str[0] != 'mac') {

wx.showModal({

title: '错误提示',

content: '二维码格式不正确!',

confirmColor: '#9ca9e9'

});

return;

}


var strs = str[1]

if (res.errMsg == 'scanCode:ok') {

var params = new Object();

params.userId = wx.getStorageSync('userId');

wx.request({

url: getApp().data.appserver + getApp().data.scan + strs,

method: 'POST',

header: {

'content-type': 'application/x-www-form-urlencoded',

'token': wx.getStorageSync('token'),

'signCode': wx.getStorageSync('signCode')

},

data: {

params: JSON.stringify(params)

},

success: function (res) {

console.log(res)

if (res.data.code == "200") {

console.log('come to here 11')

that.setData({

deviceId: res.data.data.id,

options: true

})

console.log('come to here 22')

}

},

fail: function (err) {

console.log(err)

}

})

}

},

fail: (res) => {

wx.showModal({

title: '错误提示',

content: '绑定设备失败'

})

},

})

},


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容