uniApp微信小程序与钉钉h5页面的扫码功能避坑
今天在做小程序扫码功能的时候,遇到了钉钉h5应用扫码报错的bug,微信开发者工具却没有复现,当时很是头疼,后来耗费2根头发才解决了问题,具体内容及解决方法如下:
经过查阅官方文档,发现钉钉应用开发平台和uniApp的返回值不一样!!(头大,为什么还没有统一),扫码的方法如下:
uni:
let that = this;
uni.scanCode({
// onlyFromCamera: true,
success: function (res) {
uni.showToast({
title: ‘扫码成功’,
duration: 1000
});
that.inputClearValue = JSON.parse(JSON.stringify(res)).result;
},
fail: (err) => {
// 扫码失败的逻辑处理
uni.showToast({
title: ‘扫码失败’,
duration: 1500
});
}
});
钉钉:
let that = this;
dingtalk.biz.util.scan({
type: ‘all’, // type 为 all、qrC