Files
scan-code-jssdk/dist/index.d.ts
2026-04-30 10:16:43 +08:00

85 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 扫码初始化选项
*/
interface ScanConfigOptions {
/**
* 网页扫码canvas样式
*/
webCanvasStyle?: string,
/**
* 微信JSSDK配置配置后会自动初始化微信JSSDK
*/
initWechatJssdk: {
/**
* 微信JSSDK配置API地址调用接口会带上当前页面url作为参数
*/
apiUrl: string,
/**
* 微信JSSDK配置SDK地址默认为https://res.wx.qq.com/open/js/jweixin-1.6.0.js
*/
sdkUrl?: string,
/**
* 微信JSSDK配置JS-API列表默认追加["scanQRCode"]
*/
jsApiList?: string[]
}
}
/**
* 扫码选项
*/
interface ScanResult {
result: string,
key: string
}
/** IScan */
interface IScan {
/**
* 配置SDK
* @param options 配置选项
*/
config(options?: ScanConfigOptions): Promise<any>;
/**
* 监听扫码状态
* @param callback 监听回调
*/
setStatusListener(callback: (status: "scanning" | "closed") => any): void;
/**
* 监听扫码结果
* @param callback 监听回调
* @param key 监听key
* @param match 监听匹配
* @param level 监听级别
*/
onScanListener(callback: (result: ScanResult) => any, key: string, match: string, level: number): void;
/**
* 取消监听扫码结果
* @param callback 监听回调
*/
offScanListener(callback: (result: ScanResult) => any): void;
/**
* 获取扫码状态
* @returns "scanning" | "closed"
*/
getStatus(): "scanning" | "closed";
/**
* 关闭扫码
*/
stopScan(): void;
/**
* 开启扫码
*/
startScan(): void;
/**
* 清除全部监听
*/
clear(): void;
}
declare var IScan: IScan;
declare interface Window {
IScan: IScan;
}