function callScan() {
console.log("调用扫码", wx.scanQRCode);
// 调用扫码
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
console.log("扫码结果", result);
},
fail: function (res) {
console.log("扫码失败", res);
},
});
}
在网页中使用如上方法调用微信扫码 调用失败后 页面刷新了 导致页面刷新后 点击返回页面会再刷新一下 相当于页面刷新之后向页面栈推了一个页面
onShow() {
console.log('是否登录isLogin', this.isLogin, this.url)
if (this.isLogin) {
wx.login({
success: (res) => {
if (res.code) {
console.log(
'登录成功!',
res.code,
this.loadUrl + '?authCode=' + res.code
)
this.url = this.loadUrl+'?authCode=' + res.code
uni.hideLoading()
} else {
console.log('登录失败!' + res.errMsg)
}
},
})
} else {
console.log('未登录,直接跳转', this.loadUrl + '?time=' + Date.now())
this.url = this.loadUrl
uni.hideLoading()
}
},
