● 调起客户端扫码界面进行扫码scanCode
分类:扫码
是否支持H5:支持
参数
Object object
| 参数名 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| onlyFromCamera | boolean | false | 否 | 是否只能从相机扫码,不允许从相册选择图片 |
| scanType | Array | ['barCode', 'qrCode'] | 否 | 扫码类型 |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(接口调用成功、失败都会执行) |
参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| errMsg | string | 错误信息 |
| result | string | 所扫码的内容 |
| scanType | string | 所扫码的类型 |
| charSet | string | 所扫码的字符集 |
调用示例
原生
wx.scanCode({
onlyFromCamera: true ,
scanType: ['barCode', 'qrCode'],
success: function (res) {
// wx.showToast({
// title: res,
// })
this.setData({
result: JSON.stringify(res)
})
this.onMina();
},
fail: function (res) { }
})
H5
const _data = {
onlyFromCamera: true ,
scanType: ['barCode', 'qrCode'],
}
PAMINA.call('scanCode', _data, res => {
console.log(res)
}, e => {
console.log(e)
})