interface.uts 1.7 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/**
 * uni.scanCode成功回调参数
 */
export type ScanCodeSuccess = {
    result: string,
    scanType: ScanCodeSupportedTypes
}

export type ScanCodeFail = {}
/**
 * uni.scanCode成功回调函数定义
 */
export type ScanCodeSuccessCallback = (res: ScanCodeSuccess) => void
/**
 * uni.scanCode失败回调函数定义
 */
export type ScanCodeFailCallback = (res: ScanCodeFail) => void
/**
 * uni.scanCode完成回调函数定义
 */
export type ScanCodeCompleteCallback = (res: any) => void

export type ScanCodeSupportedTypes = 'barCode' | 'qrCode' | 'datamatrix' | 'pdf417'

/**
 * uni.scanCode参数定义
 */
export type ScanCodeOptions = {
    /**
     * 是否只能从相机扫码,不允许从相册选择图片
     */
    onlyFromCamera?: boolean | null,
    /**
     * 扫码类型
     */
    scanType?: ScanCodeSupportedTypes[] | null,
    /**
     * 接口调用成功的回调函数
     */
    success?: ScanCodeSuccessCallback | null,
    /**
     * 接口调用失败的回调函数
     */
    fail?: ScanCodeFailCallback | null,
    /**
     * 接口调用结束的回调函数(调用成功、失败都会执行)
     */
    complete?: ScanCodeCompleteCallback | null
}


export interface Uni {
    /**
     * 扫码
     * @uniPlatform {
     *    "app": {
     *      "harmony": {
     *        "osVer": "3.0",
     *        "uniVer": "4.23",
     *        "unixVer": "x"
     *      }
     *  },
     *  "web": {
     *    "uniVer": "x",
     *    "unixVer": "x"
     *  }
     * }
     * @uniVueVersion 2,3  //支持的vue版本
     */
    scanCode(options?: ScanCodeOptions | null): void;
}

export type ScanCode = (options?: ScanCodeOptions | null) => void;