# scanCode ^4.4.0
打开扫码
# 调用方式
scanCode(params)
1
返回 Promise,使用 then/catch 或 await 处理结果。
# 请求参数
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
| desc | String | N | 扫描提示语 | |
| params | Object | N | 配置项 | |
| -codeType | String | N | 类型 | |
| -navTitle | String | N | 标题 | |
| -maunallyTitle | String | N | 手动选择标题 |
# 接口调用示例
this.$bridge.getLanguageString()
1
# 返回参数
| Prop | Type | Default | Description |
|---|---|---|---|
| code | Number | 状态标志位(逻辑详见示例) |
# 接口返回示例
this.$bridge.scanCode({
desc: this.TEXT.service_request_productInfo_scan_desc,
params: {
codeType: '2',
navTitle: this.TEXT.service_request_productInfo_scan_navTitle,
maunallyTitle: this.TEXT.service_request_productInfo_scan_maunallyTitle
},
}).then(res => {
// res为空时代表iOS触发返回,不做操作
if (res) {
const { code, data } = res;
// code不为0: 安卓触发返回,不做操作; iOS扫码异常,弹窗重扫
if (code == 0) {
// data为空代表双端触发手动选择产品,跳转产品页
if (!data) {
router.push({ name: 'RegistrationProduct' });
} else {
partSerial(data, true);
}
} else {
if (isAndroid()) return
scanError.value = true;
}
}
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25