export type CodeScanSuccess = { content : string format : string fromAlbum ?: boolean } export type CodeScanErrorCode = 9021001 | 9021002 | 9021003 | 9021004 | 9021005 | 9021006 | 9021007 | 9021008 | 9021009 | 9021010 | 9021011 export type CodeScanTorchMode = 'off' | 'on' | 'auto' export type CodeScanResultMode = 'immediate' | 'confirm' | 'pause' export type CodeScanCornerStyle = 'corner' | 'full' | 'rounded' | 'rounded-corner' export type CodeScanStyle = { /** 是否显示扫描框外遮罩,默认 true */ showMask ?: boolean /** 是否显示扫描线,默认 true */ showBeam ?: boolean /** 扫描框边框颜色,支持 #RRGGBB / #AARRGGBB */ borderColor ?: string /** 遮罩颜色,支持 #RRGGBB / #AARRGGBB 或 rgba() */ maskColor ?: string /** 扫描线颜色,支持 #RRGGBB / #AARRGGBB */ beamColor ?: string /** 扫描线移动周期,单位毫秒,默认 1800 */ beamDuration ?: number /** 扫描框样式:corner 四角边框,full 完整边框,rounded 完整圆角边框,rounded-corner 四角圆角边框,默认 corner */ cornerStyle ?: CodeScanCornerStyle /** 圆角半径,单位 dp,rounded 和 rounded-corner 样式生效,默认 20,范围 0 ~ 160 */ cornerRadius ?: number } export interface CodeScanFail extends IUniError { errCode : CodeScanErrorCode } /** * 实时相机扫描区域。宽度和高度均以预览宽度为参考比例,因此可稳定锁定宽高比。 * 不传时保持原有整画面识别;相册识图不受该配置限制。 */ export type ScanRegion = { /** 全屏识别:不绘制扫描框、不进行区域过滤 */ fullScreen ?: boolean /** 扫描框宽度比例,建议 0.1 ~ 1 */ width ?: number /** 扫描框高度比例,建议 0.1 ~ 1 */ height ?: number /** 扫描框中心横坐标比例,0 为最左、1 为最右 */ centerX ?: number /** 扫描框中心纵坐标比例,0 为顶部、1 为底部 */ centerY ?: number } export type CodeScanOptions = { /** 扫码页标题,默认“扫一扫” */ title ?: string /** 扫描框下方引导语,默认“请将条码放入扫描框内” */ hint ?: string /** 识别成功提示语,默认“扫码成功” */ successHint ?: string /** 未识别到条码时的提示语,默认“未识别到有效条码” */ emptyHint ?: string /** 条码偏小时自动放大,默认 true */ smartZoom ?: boolean /** 手电筒策略:off 关闭、on 默认开启、auto 根据环境亮度自动补光,默认 off */ torch ?: CodeScanTorchMode /** 单次扫码结果策略:immediate 立即返回、confirm 确认后返回、pause 暂停后可继续扫描,默认 immediate */ resultMode ?: CodeScanResultMode /** 连续扫码页是否显示暂停/继续按钮,默认 false */ showPauseButton ?: boolean /** 限定码制,如 ['QR_CODE','CODE_128'];空/缺省为全格式 */ formats ?: string[] /** 识别成功是否震动,默认 true */ vibrate ?: boolean /** 连续扫码:页内不关闭,多次 success;点关闭结束;可通过 showPauseButton 显示暂停按钮 */ continuous ?: boolean /** 连续扫码成功提示停留时长,单位毫秒,默认 1000,范围 0 ~ 600000 */ continuousSuccessDuration ?: number /** 打开后直接进入相册选图 */ fromAlbum ?: boolean /** 实时相机有效识别区域;fullScreen 为 true 时整画面均可识别 */ scanRegion ?: ScanRegion /** 扫描框视觉样式 */ scanStyle ?: CodeScanStyle /** 扫描会话超时毫秒数;不传或小于 1000 时不启用,最大 600000 */ scanTimeout ?: number success ?: (res : CodeScanSuccess) => void fail ?: (res : CodeScanFail) => void complete ?: (res : any) => void } export type OpenCodeScan = (options ?: CodeScanOptions | null) => void