赞
踩
1.问题描述
Scan Kit扫描专用底层码流接口需要鉴权,鉴权失败后功能还能用吗?
解决方案
如果已经申请过白名单,因为异常导致的鉴权失败会优先放通,保障业务成功。
2.问题描述
调用Scan Kit扫描专用底层码流接口会不会将二维码直接解出来?
解决方案
不会解析用户数据,Scan Kit接口只会检测二维码的位置,不会尝试去解码。
3.问题描述
自定义扫码界面的时候相机显示的画面变型,如何获取到一个合适的分辨率不变形?
解决方案
请参考文档:https://developer.huawei.com/consumer/cn/codelabsPortal/carddetails/tutorials_ScanKit-Codelab-Clientdemo-ArkTS。可通过监听组件onAreaChange方法获取手机屏幕宽高,您可以根据实际情况按百分比进行设计。
关键代码示例:
Column() { XComponent({ id: 'componentId', type: 'surface', controller: this.mXComponentController }) .onLoad(async () => { hilog.info(0x0001, TAG, 'onLoad is called'); // 获取XComponent组件的surfaceId this.surfaceId = this.mXComponentController.getXComponentSurfaceId(); hilog.info(0x0001, TAG, 'surfaceId: %{public}s', this.surfaceId) let viewControl: customScan.ViewControl = { width: this.cameraWidth, height: this.cameraHeight, surfaceId: this.surfaceId }; // 扫码结果放置到回调中处理 try { customScan.start(viewControl, this.callback); this.isFlashLightEnable = true; } catch (error) { hilog.error(0x0001, TAG, 'start fail, error: %{public}s', JSON.stringify(error)); } }) // XComponent宽、高、位置偏移量默认使用单位:vp .width(this.cameraWidth) .height(this.cameraHeight) .position({ x: this.cameraOffsetX, y: this.cameraOffsetY }) } .height('100%') .width('100%') .onAreaChange((oldValue: Area, newValue: Area) => { // 获取当前组件宽高,newValue返回width、height值,单位vp,计算XComponent组件大小 hilog.info(0x0001, TAG, 'newValue : %{public}s, ', JSON.stringify(newValue)); this.calcArea(newValue.width as number, newValue.height as number); })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。