# tap.scanCode(Object object)
以 Promise 风格调用:支持
# 功能描述
调起 TapTap 客户端扫码界面进行扫码
# 参数
# Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 | ||||||||||||
| onlyFromCamera | boolean | false | 否 | 是否只能从相机扫码,不允许从相册选择图片 安卓只支持onlyFromCamera=true | ||||||||||||
| scanType | Array.<string> | ['barCode', 'qrCode'] | 否 | 扫码类型 | ||||||||||||
| ||||||||||||||||
| success | function | 否 | 接口调用成功的回调函数 | |||||||||||||
| fail | function | 否 | 接口调用失败的回调函数 | |||||||||||||
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |||||||||||||
# object.success 回调函数
# 参数
# Object res
| 属性 | 类型 | 说明 | |||||||||||||||||||||||||||||||||||||||
| result | string | 所扫码的内容 | |||||||||||||||||||||||||||||||||||||||
| scanType | string | 所扫码的类型 | |||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| charSet | string | 所扫码的字符集 | |||||||||||||||||||||||||||||||||||||||
| path | string | 当所扫的码为当前小游戏二维码时,会返回此字段,内容为二维码携带的 path | |||||||||||||||||||||||||||||||||||||||
| rawData | string | 原始数据,base64编码 | |||||||||||||||||||||||||||||||||||||||
# 示例代码
// 允许从相机和相册扫码
tap.scanCode({
success (res) {
console.log(res)
}
})
// 只允许从相机扫码
tap.scanCode({
onlyFromCamera: true,
success (res) {
console.log(res)
}
})