export type IEmptyObject = {};
|
export type IAnyObject = Record<string, any>;
|
export type APIParams<TParams = IEmptyObject, TSucc = IEmptyObject, TFail = IEmptyObject> = TParams & CommonParams<TSucc, TFail>;
|
export type APICallback<TEvent = void> = (event: TEvent) => void;
|
export interface CommonParams<TSucc = IEmptyObject, TFail = IEmptyObject> {
|
/**
|
* 成功回调
|
*/
|
success?: (res: CommonResult & TSucc) => void;
|
/**
|
* 失败回调
|
*/
|
fail?: (res: CommonResult & TFail) => void;
|
/**
|
* 取消回调
|
*/
|
cancel?: (res: CommonResult & TFail) => void;
|
/**
|
* 完成回调
|
*/
|
complete?: (res: CommonResult & (TSucc | TFail)) => void;
|
}
|
export interface CommonResult {
|
/**
|
* 通用错误信息
|
*/
|
errMsg: string;
|
/**
|
* 通用错误码
|
*/
|
errCode: number;
|
}
|
export interface AgentConfigParams {
|
/**
|
* 当前用户所属企业 ID
|
*/
|
corpid: string;
|
/**
|
* 当前应用 AgentID
|
*/
|
agentid: string;
|
/**
|
* 生成签名的时间戳
|
*/
|
timestamp: string;
|
/**
|
* 生成签名的随机串
|
*/
|
nonceStr: string;
|
/**
|
* 签名
|
*/
|
signature: string;
|
/**
|
* 需要使用的JS接口列表
|
*/
|
jsApiList: string[];
|
}
|
export interface AgentConfigResult extends CommonResult {
|
/**
|
* jsApiList 权限检查结果
|
*/
|
checkResult: Record<string, boolean>;
|
}
|
export interface AgentConfigInfo {
|
params: AgentConfigParams;
|
result: AgentConfigResult;
|
}
|
/**
|
* 触发或等待 agentConfig 返回
|
*/
|
export declare function ensureAgentConfigReady(): Promise<AgentConfigInfo>;
|
export interface CorpConfigParams {
|
/**
|
* 当前用户所属企业 ID
|
*/
|
appId: string;
|
/**
|
* 生成签名的时间戳
|
*/
|
timestamp: string;
|
/**
|
* 生成签名的随机串
|
*/
|
nonceStr: string;
|
/**
|
* 签名
|
*/
|
signature: string;
|
/**
|
* 需要使用的JS接口列表
|
*/
|
jsApiList: string[];
|
/**
|
* 需要使用的开放标签列表,例如['wx-open-launch-app']
|
*/
|
openTagList: string[];
|
}
|
export interface CorpConfigResult extends CommonResult {
|
/**
|
* jsApiList 权限检查结果
|
*/
|
checkResult: Record<string, boolean>;
|
}
|
export interface CorpConfigInfo {
|
params: CorpConfigParams;
|
result: CorpConfigResult;
|
}
|
/**
|
* 触发或等待 config 返回
|
*/
|
export declare function ensureCorpConfigReady(): Promise<CorpConfigInfo>;
|
export interface SignatureData {
|
/**
|
* 生成签名的时间戳
|
*/
|
timestamp: string | number;
|
/**
|
* 生成签名的随机串
|
*/
|
nonceStr: string;
|
/**
|
* 签名
|
*/
|
signature: string;
|
}
|
export interface SignatureFactory {
|
/**
|
* @param url 用于生成签名的 URL
|
*/
|
(url: string): SignatureData | Promise<SignatureData>;
|
}
|
export interface ConfigCallback<T> {
|
(res: T): void;
|
}
|
export interface RegisterOptions {
|
/**
|
* 当前用户所属企业 ID
|
*/
|
corpId: string;
|
/**
|
* 当前应用 AgentID
|
*/
|
agentId?: string | number;
|
/**
|
* 应用套件 ID
|
*/
|
suiteId?: string;
|
/**
|
* 需要使用的JS接口列表
|
*/
|
jsApiList?: string[];
|
/**
|
* 需要使用的开放标签列表,例如['wx-open-launch-app']
|
*/
|
openTagList?: string[];
|
/**
|
* config 签名生成函数
|
*/
|
getConfigSignature?: SignatureFactory;
|
/**
|
* config 成功回调
|
*/
|
onConfigSuccess?: ConfigCallback<CorpConfigResult>;
|
/**
|
* config 失败回调
|
*/
|
onConfigFail?: ConfigCallback<CommonResult | Error>;
|
/**
|
* config 完成回调
|
*/
|
onConfigComplete?: ConfigCallback<CorpConfigResult | CommonResult | Error>;
|
/**
|
* agentConfig 签名生成函数
|
*/
|
getAgentConfigSignature?: SignatureFactory;
|
/**
|
* agentConfig 成功回调
|
*/
|
onAgentConfigSuccess?: ConfigCallback<AgentConfigResult>;
|
/**
|
* agentConfig 失败回调
|
*/
|
onAgentConfigFail?: ConfigCallback<CommonResult | Error>;
|
/**
|
* agentConfig 完成回调
|
*/
|
onAgentConfigComplete?: ConfigCallback<AgentConfigResult | CommonResult | Error>;
|
/**
|
* suiteConfig 签名生成函数
|
*/
|
getSuiteConfigSignature?: SignatureFactory;
|
}
|
/**
|
* 注册应用信息。
|
*
|
* @example
|
* ```ts
|
* ww.register({
|
* corpId: 'ww7ca4776b2a70000',
|
* jsApiList: ['getExternalContact'],
|
* getConfigSignature
|
* })
|
* ```
|
*/
|
export declare function register(options: RegisterOptions): void;
|
export declare enum Proximity {
|
/**
|
* CLProximityUnknown
|
*/
|
CLProximityUnknown = "0",
|
/**
|
* CLProximityImmediate
|
*/
|
CLProximityImmediate = "1",
|
/**
|
* CLProximityNear
|
*/
|
CLProximityNear = "2",
|
/**
|
* CLProximityFar
|
*/
|
CLProximityFar = "3"
|
}
|
/**
|
* 开启查找周边 iBeacon 设备。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
|
* @compat WeChat
|
*/
|
export declare function startSearchBeacons(params?: APIParams<{
|
/**
|
* 摇周边的业务ticket,系统自动添加在摇出来的页面链接后面
|
*/
|
ticket?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 关闭查找周边 iBeacon 设备。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
|
* @compat WeChat
|
*/
|
export declare function stopSearchBeacons(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 监听周边 iBeacon 设备接口。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
|
* @compat WeChat
|
*/
|
export declare function onSearchBeacons(callback: APICallback<{
|
beacons: Array<{
|
/** */
|
major: number;
|
/** */
|
minor: number;
|
/** */
|
uuid: string;
|
/**
|
* 距离
|
*
|
* 单位为米
|
*/
|
accuracy: string;
|
/**
|
* 精度
|
*/
|
proximity: Proximity;
|
/**
|
* 接收信号的强度指示
|
*/
|
rssi: string;
|
/**
|
* 接收信号时设备的方向
|
*
|
* @note
|
* - 仅 Android 设备返回此字段
|
* - 若 iOS 设备需要获取方向,可以利用 HTML5 标准 API 获取
|
*/
|
heading?: string;
|
}>;
|
}>): void;
|
/**
|
* 连接低功耗蓝牙设备。
|
*
|
* @note
|
* - 安卓手机上如果多次调用 createBLEConnection 创建连接,有可能导致系统持有同一设备多个连接的实例,导致调用 closeBLEConnection 的时候并不能真正的断开与设备的连接。因此请保证尽量成对的调用 create 和 close 接口
|
* - 蓝牙链接随时可能断开,建议监听 onBLEConnectionStateChange 回调事件,当蓝牙设备断开时按需执行重连操作
|
* - 若对未连接的设备或已断开连接的设备调用数据读写操作的接口,会返回 10006 错误,建议进行重连操作
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.createBLEConnection({
|
* deviceId: deviceId
|
* })
|
* ```
|
*/
|
export declare function createBLEConnection(params: APIParams<{
|
/**
|
* 蓝牙设备 ID
|
*/
|
deviceId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 断开与低功耗蓝牙设备的连接。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.closeBLEConnection({
|
* deviceId: deviceId
|
* })
|
* ```
|
*/
|
export declare function closeBLEConnection(params: APIParams<{
|
/**
|
* 蓝牙设备 ID
|
*/
|
deviceId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 监听低功耗蓝牙连接状态的改变事件,包括开发者主动连接或断开连接,设备丢失,连接异常断开等等。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onBLEConnectionStateChange(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onBLEConnectionStateChange(callback: APICallback<{
|
/**
|
* 蓝牙设备 ID
|
*/
|
deviceId: string;
|
/**
|
* 连接目前的状态
|
*/
|
connected: boolean;
|
}>): void;
|
/**
|
* 获取蓝牙设备所有 service(服务)。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.getBLEDeviceServices({
|
* deviceId: deviceId
|
* })
|
* ```
|
*/
|
export declare function getBLEDeviceServices(params: APIParams<{
|
/**
|
* 蓝牙设备 ID,需要已经通过 createBLEConnection 与对应设备建立链接
|
*/
|
deviceId: string;
|
}, {
|
/**
|
* 设备服务列表
|
*/
|
services: Array<{
|
/**
|
* 蓝牙设备服务的 uuid
|
*/
|
uuid: string;
|
/**
|
* 该服务是否为主服务
|
*/
|
isPrimary: boolean;
|
}>;
|
}>): Promise<CommonResult & {
|
/**
|
* 设备服务列表
|
*/
|
services: Array<{
|
/**
|
* 蓝牙设备服务的 uuid
|
*/
|
uuid: string;
|
/**
|
* 该服务是否为主服务
|
*/
|
isPrimary: boolean;
|
}>;
|
}>;
|
/**
|
* 获取蓝牙设备某个服务中的所有 characteristic(特征值)。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.getBLEDeviceCharacteristics({
|
* deviceId: deviceId,
|
* serviceId: serviceId
|
* })
|
* ```
|
*/
|
export declare function getBLEDeviceCharacteristics(params: APIParams<{
|
/**
|
* 蓝牙设备 ID,需要已经通过 createBLEConnection 与对应设备建立链接
|
*/
|
deviceId: string;
|
/**
|
* 蓝牙服务 uuid,需要通过 getBLEDeviceServices 接口获取
|
*/
|
serviceId: string;
|
}, {
|
/**
|
* 设备特征值列表
|
*/
|
characteristics: Array<{
|
/**
|
* 蓝牙设备特征值的 uuid
|
*/
|
uuid: string;
|
/**
|
* 该特征值支持的操作类型
|
*/
|
properties: {
|
/**
|
* 该特征值是否支持 read 操作
|
*/
|
read: boolean;
|
/**
|
* 该特征值是否支持 write 操作
|
*/
|
write: boolean;
|
/**
|
* 该特征值是否支持 notify 操作
|
*/
|
notify: boolean;
|
/**
|
* 该特征值是否支持 indicate 操作
|
*/
|
indicate: boolean;
|
};
|
}>;
|
}>): Promise<CommonResult & {
|
/**
|
* 设备特征值列表
|
*/
|
characteristics: Array<{
|
/**
|
* 蓝牙设备特征值的 uuid
|
*/
|
uuid: string;
|
/**
|
* 该特征值支持的操作类型
|
*/
|
properties: {
|
/**
|
* 该特征值是否支持 read 操作
|
*/
|
read: boolean;
|
/**
|
* 该特征值是否支持 write 操作
|
*/
|
write: boolean;
|
/**
|
* 该特征值是否支持 notify 操作
|
*/
|
notify: boolean;
|
/**
|
* 该特征值是否支持 indicate 操作
|
*/
|
indicate: boolean;
|
};
|
}>;
|
}>;
|
/**
|
* 读取低功耗蓝牙设备的特征值的二进制数据值。
|
*
|
* @note
|
* - 设备的特征值必须支持 read 才可以成功调用,具体参照 characteristic 的 properties 属性
|
* - 并行调用多次读写接口存在读写失败的可能性
|
* - 接口读取到的信息需要在 onBLECharacteristicValueChange 的回调中获取
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.readBLECharacteristicValue({
|
* deviceId: deviceId,
|
* serviceId: serviceId,
|
* characteristicId: characteristicId
|
* })
|
* ```
|
*/
|
export declare function readBLECharacteristicValue(params: APIParams<{
|
/**
|
* 蓝牙设备 ID
|
*
|
* 需要已经通过 createBLEConnection 与对应设备建立链接
|
*/
|
deviceId: string;
|
/**
|
* 蓝牙特征值对应服务的 uuid
|
*
|
* 需要通过 getBLEDeviceServices 接口获取
|
*/
|
serviceId: string;
|
/**
|
* 蓝牙特征值的 uuid
|
*
|
* 需要通过 getBLEDeviceCharacteristics 接口获取
|
*/
|
characteristicId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 向低功耗蓝牙设备特征值中写入二进制数据。
|
*
|
* @note
|
* - 设备的特征值必须支持 write 才可以成功调用,具体参照 characteristic 的 properties 属性
|
* - 并行调用多次读写接口存在读写失败的可能性
|
* - 接口不会对写入数据包大小做限制,但系统与蓝牙设备会确定蓝牙 4.0 单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过 20 字节
|
* - 安卓平台上,在调用 notify 成功后立即调用 write 接口,在部分机型上会发生 10008 系统错误
|
* - 若单次写入数据过长,iOS 平台上存在系统不会有任何回调的情况(包括错误回调)
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.writeBLECharacteristicValue({
|
* deviceId: deviceId,
|
* serviceId: serviceId,
|
* characteristicId: characteristicId,
|
* value: arrayBufferValue
|
* })
|
* ```
|
*/
|
export declare function writeBLECharacteristicValue(params: APIParams<{
|
/**
|
* 蓝牙设备 ID
|
*
|
* 需要已经通过 createBLEConnection 与对应设备建立链接
|
*/
|
deviceId: string;
|
/**
|
* 蓝牙特征值对应服务的 uuid
|
*
|
* 需要通过 getBLEDeviceServices 接口获取
|
*/
|
serviceId: string;
|
/**
|
* 蓝牙特征值的 uuid
|
*
|
* 需要通过 getBLEDeviceCharacteristics 接口获取
|
*/
|
characteristicId: string;
|
/**
|
* 需要写入的二进制数据
|
*/
|
value: ArrayBuffer;
|
}>): Promise<CommonResult>;
|
/**
|
* 启用低功耗蓝牙设备特征值变化时的 notify 功能,订阅特征值。
|
*
|
* @note
|
* - 设备的特征值必须支持 notify 或者 indicate 才可以成功调用,具体参照 characteristic 的 properties 属性
|
* - 订阅操作成功后需要设备主动更新特征值的 value 才会触发 onBLECharacteristicValueChange 回调
|
* - 安卓平台上,在调用 notify 成功后立即调用 write 接口,在部分机型上会发生 10008 系统错误
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.notifyBLECharacteristicValueChange({
|
* deviceId: deviceId,
|
* serviceId: serviceId,
|
* characteristicId: characteristicId,
|
* state: true
|
* })
|
* ```
|
*/
|
export declare function notifyBLECharacteristicValueChange(params: APIParams<{
|
/**
|
* 蓝牙设备 ID
|
*
|
* 需要已经通过 createBLEConnection 与对应设备建立链接
|
*/
|
deviceId: string;
|
/**
|
* 蓝牙特征值对应服务的 uuid
|
*
|
* 需要通过 getBLEDeviceServices 接口获取
|
*/
|
serviceId: string;
|
/**
|
* 蓝牙特征值的 uuid
|
*
|
* 需要通过 getBLEDeviceCharacteristics 接口获取
|
*/
|
characteristicId: string;
|
/**
|
* 是否启用 notify
|
*/
|
state: boolean;
|
}>): Promise<CommonResult>;
|
/**
|
* 监听低功耗蓝牙设备的特征值变化。
|
*
|
* 必须先启用 notify 才能接收到设备推送的 notification。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onBLECharacteristicValueChange(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onBLECharacteristicValueChange(callback: APICallback<{
|
/**
|
* 蓝牙设备 ID
|
*/
|
deviceId: string;
|
/**
|
* 特征值所属服务 uuid
|
*/
|
serviceId: string;
|
/**
|
* 特征值 uuid
|
*/
|
characteristicId: string;
|
/**
|
* 特征值最新的值
|
*
|
* @note
|
* VConsole 无法打印出 ArrayBuffer 类型数据
|
*/
|
value: ArrayBuffer;
|
}>): void;
|
/**
|
* 初始化蓝牙模块。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.openBluetoothAdapter()
|
* ```
|
*/
|
export declare function openBluetoothAdapter(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 关闭蓝牙模块。
|
*
|
* @note
|
* - 调用该方法将断开所有已建立的链接并释放系统资源
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.closeBluetoothAdapter()
|
* ```
|
*/
|
export declare function closeBluetoothAdapter(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 获取本机蓝牙适配器状态。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.getBluetoothAdapterState()
|
* ```
|
*/
|
export declare function getBluetoothAdapterState(params?: APIParams<IEmptyObject, {
|
/**
|
* 是否正在搜索设备
|
*/
|
discovering: boolean;
|
/**
|
* 蓝牙适配器是否可用
|
*/
|
available: boolean;
|
}>): Promise<CommonResult & {
|
/**
|
* 是否正在搜索设备
|
*/
|
discovering: boolean;
|
/**
|
* 蓝牙适配器是否可用
|
*/
|
available: boolean;
|
}>;
|
/**
|
* 监听蓝牙适配器状态变化。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onBluetoothAdapterStateChange(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onBluetoothAdapterStateChange(callback: APICallback<{
|
/**
|
* 是否正在搜索设备
|
*/
|
discovering: boolean;
|
/**
|
* 蓝牙适配器是否可用
|
*/
|
available: boolean;
|
}>): void;
|
/**
|
* 开始搜寻附近的蓝牙外围设备。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.startBluetoothDevicesDiscovery({
|
* services: ['FEE7']
|
* })
|
* ```
|
*/
|
export declare function startBluetoothDevicesDiscovery(params?: APIParams<{
|
/**
|
* 蓝牙设备主 service 的 uuid 列表
|
*
|
* 某些蓝牙设备会广播自己主 service 的 uuid。如传入列表非空则只会搜索发出广播包有这个主服务的蓝牙设备,建议主要通过该参数过滤掉周边
|
* 不需要处理的其他蓝牙设备
|
*/
|
services?: string[];
|
/**
|
* 是否允许重复上报同一设备
|
*
|
* 若允许重复上报,则 onDeviceFound 方法会多次上报同一设备,但是 RSSI 值会有不同
|
*/
|
allowDuplicatesKey?: boolean;
|
/**
|
* 上报设备的间隔
|
*
|
* 若为 0 表示找到新设备立刻上报,否则根据传入的间隔上报
|
*
|
* @default 0
|
*/
|
interval?: number;
|
}>): Promise<CommonResult>;
|
/**
|
* 停止搜寻附近的蓝牙外围设备。
|
*
|
* 若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.stopBluetoothDevicesDiscovery()
|
* ```
|
*/
|
export declare function stopBluetoothDevicesDiscovery(params?: APIParams): Promise<CommonResult>;
|
export interface BluetoothDevice {
|
/**
|
* 蓝牙设备名称,某些设备可能没有
|
*/
|
name: string;
|
/**
|
* 用于区分设备的 ID
|
*
|
* @note
|
* 开发者工具和 Android 上获取到的 deviceId 为设备 MAC 地址,iOS 上为设备 uuid。因此 deviceId 不能硬编码到代码中
|
*/
|
deviceId: string;
|
/**
|
* 当前蓝牙设备的信号强度
|
*
|
* @note
|
* Mac 系统可能无法获取 advertisData 及 RSSI,建议使用真机调试
|
*/
|
RSSI: number;
|
/**
|
* 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段
|
*
|
* @note
|
* - 注意 VConsole 无法打印出 ArrayBuffer 类型数据
|
* - Mac 系统可能无法获取 advertisData 及 RSSI,建议使用真机调试
|
*/
|
advertisData: ArrayBuffer;
|
/**
|
* 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段
|
*/
|
advertisServiceUUIDs: string[];
|
/**
|
* 当前蓝牙设备的广播数据段中的 LocalName 数据段
|
*/
|
localName: string;
|
/**
|
* 当前蓝牙设备的广播数据段中的 ServiceData 数据段
|
*/
|
serviceData: Record<string, ArrayBuffer>;
|
}
|
/**
|
* 获取在蓝牙模块生效期间所有已发现的蓝牙设备。
|
*
|
* @note
|
* - 该接口获取到的设备列表为蓝牙模块生效期间所有搜索到的蓝牙设备,若在蓝牙模块使用流程结束后未及时调用 closeBluetoothAdapter 释放资源,调用该接口可能会返回之前蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接
|
* - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 GattName。若需要动态改变设备名称并展示,建议使用 localName 字段
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.getBluetoothDevices()
|
* ```
|
*/
|
export declare function getBluetoothDevices(params?: APIParams<IEmptyObject, {
|
/**
|
* 已发现的蓝牙设备列表
|
*/
|
devices: BluetoothDevice[];
|
}>): Promise<CommonResult & {
|
/**
|
* 已发现的蓝牙设备列表
|
*/
|
devices: BluetoothDevice[];
|
}>;
|
/**
|
* 监听寻找到新设备。
|
*
|
* @note
|
* - 若在该接口中回调了某个设备,则此设备会添加到 getBluetoothDevices 接口返回的设备列表中
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onBluetoothDeviceFound(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onBluetoothDeviceFound(callback: APICallback<{
|
/**
|
* 新搜索到的设备列表
|
*/
|
devices: BluetoothDevice[];
|
}>): void;
|
/**
|
* 根据 uuid 获取处于已连接状态的设备。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.getConnectedBluetoothDevices({
|
* services: ['FEE7']
|
* })
|
* ```
|
*/
|
export declare function getConnectedBluetoothDevices(params: APIParams<{
|
/**
|
* 蓝牙设备主 service 的 uuid 列表
|
*/
|
services: string[];
|
}, {
|
/**
|
* 搜索到的设备列表
|
*/
|
devices: Array<{
|
/**
|
* 蓝牙设备名称,某些设备可能没有
|
*/
|
name: string;
|
/**
|
* 用于区分设备的 ID
|
*/
|
deviceId: string;
|
}>;
|
}>): Promise<CommonResult & {
|
/**
|
* 搜索到的设备列表
|
*/
|
devices: Array<{
|
/**
|
* 蓝牙设备名称,某些设备可能没有
|
*/
|
name: string;
|
/**
|
* 用于区分设备的 ID
|
*/
|
deviceId: string;
|
}>;
|
}>;
|
/**
|
* 设置系统剪贴板的内容。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16; WeCom PC, Mac >= 3.1.2
|
*
|
* @example
|
* ```ts
|
* ww.setClipboardData({
|
* data: 'data'
|
* })
|
* ```
|
*/
|
export declare function setClipboardData(params: APIParams<{
|
/**
|
* 剪贴板的内容
|
*/
|
data: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 获取系统剪贴板内容。
|
*
|
* @compat WeCom >= 3.1.2
|
*
|
* @example
|
* ```ts
|
* ww.getClipboardData()
|
* ```
|
*/
|
export declare function getClipboardData(params?: APIParams<IEmptyObject, {
|
/**
|
* 剪贴板的内容
|
*/
|
data: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 剪贴板的内容
|
*/
|
data: string;
|
}>;
|
export interface IBeacon {
|
/**
|
* iBeacon 设备广播的 uuid
|
*/
|
uuid: string;
|
/**
|
* iBeacon 设备的主 id
|
*/
|
major: string;
|
/**
|
* iBeacon 设备的次 id
|
*/
|
minor: string;
|
/**
|
* 表示设备距离的枚举值
|
*/
|
proximity: number;
|
/**
|
* iBeacon 设备的距离
|
*/
|
accuracy: number;
|
/**
|
* 表示设备的信号强度
|
*/
|
rssi: number;
|
}
|
/**
|
* 开始搜索附近的 iBeacon 设备。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.startBeaconDiscovery({
|
* uuids: ['uuid']
|
* })
|
* ```
|
*/
|
export declare function startBeaconDiscovery(params: APIParams<{
|
/**
|
* iBeacon设备广播的 uuids
|
*/
|
uuids: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 停止搜索附近的 iBeacon 设备。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.stopBeaconDiscovery()
|
* ```
|
*/
|
export declare function stopBeaconDiscovery(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 获取所有已搜索到的 iBeacon 设备。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.getBeacons()
|
* ```
|
*/
|
export declare function getBeacons(params?: APIParams<IEmptyObject, {
|
/**
|
* iBeacon 设备列表
|
*/
|
beacons: IBeacon[];
|
}>): Promise<CommonResult & {
|
/**
|
* iBeacon 设备列表
|
*/
|
beacons: IBeacon[];
|
}>;
|
/**
|
* 监听 iBeacon 设备的更新事件。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onBeaconUpdate(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onBeaconUpdate(callback: APICallback<{
|
/**
|
* 当前搜寻到的所有 iBeacon 设备列表
|
*/
|
beacons: IBeacon[];
|
}>): void;
|
/**
|
* 监听 iBeacon 服务的状态变化。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onBeaconServiceChange(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onBeaconServiceChange(callback: APICallback<{
|
/**
|
* 服务目前是否可用
|
*/
|
available: boolean;
|
/**
|
* 目前是否处于搜索状态
|
*/
|
discovering: boolean;
|
}>): void;
|
export declare enum LocationType {
|
/**
|
* gps 坐标
|
*/
|
wgs84 = "wgs84",
|
/**
|
* 火星坐标
|
*/
|
gcj02 = "gcj02"
|
}
|
/**
|
* 使用企业微信内置地图查看位置。
|
*
|
* @example
|
* ```ts
|
* ww.openLocation({
|
* latitude: 0,
|
* longitude: 0,
|
* name: 'name',
|
* address: 'address',
|
* scale: 1
|
* })
|
* ```
|
*/
|
export declare function openLocation(params: APIParams<{
|
/**
|
* 纬度
|
*
|
* 范围为 90 ~ -90
|
*/
|
latitude: number;
|
/**
|
* 经度
|
*
|
* 范围为 180 ~ -180
|
*/
|
longitude: number;
|
/**
|
* 位置名
|
*/
|
name?: string;
|
/**
|
* 地址详情说明
|
*/
|
address?: string;
|
/**
|
* 地图缩放级别
|
*
|
* 范围为 1 ~ 28
|
*
|
* @default 16
|
*/
|
scale?: number;
|
/** */
|
infoUrl?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 获取地理位置。
|
*
|
* @example
|
* ```ts
|
* ww.getLocation({
|
* type: 'wgs84'
|
* })
|
* ```
|
*/
|
export declare function getLocation(params?: APIParams<{
|
/**
|
* 坐标类型
|
*
|
* 如果要返回直接给 openLocation 用的火星坐标,可传入 gcj02
|
*
|
* @default wgs84
|
*/
|
type?: LocationType;
|
}, {
|
/**
|
* 纬度,浮点数,范围为 90 ~ -90
|
*/
|
latitude: number;
|
/**
|
* 经度,浮点数,范围为 180 ~ -180
|
*/
|
longitude: number;
|
/**
|
* 速度,以米/每秒计,企业微信不支持speed参数,输出固定为0
|
*
|
* @compat WeChat
|
*/
|
speed: number;
|
/**
|
* 位置精度
|
*/
|
accuracy: number;
|
}>): Promise<CommonResult & {
|
/**
|
* 纬度,浮点数,范围为 90 ~ -90
|
*/
|
latitude: number;
|
/**
|
* 经度,浮点数,范围为 180 ~ -180
|
*/
|
longitude: number;
|
/**
|
* 速度,以米/每秒计,企业微信不支持speed参数,输出固定为0
|
*
|
* @compat WeChat
|
*/
|
speed: number;
|
/**
|
* 位置精度
|
*/
|
accuracy: number;
|
}>;
|
/**
|
* 打开持续定位。
|
*
|
* @compat WeCom >= 2.4.20
|
*
|
* @example
|
* ```ts
|
* ww.startAutoLBS({
|
* type: 'gcj02'
|
* })
|
* ```
|
*/
|
export declare function startAutoLBS(params: APIParams<{
|
/** */
|
type: LocationType;
|
}>): Promise<CommonResult>;
|
/**
|
* 停止持续定位。
|
*
|
* @compat WeCom >= 2.4.20
|
*
|
* @example
|
* ```ts
|
* ww.stopAutoLBS()
|
* ```
|
*/
|
export declare function stopAutoLBS(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 监听地理位置的变化。
|
*
|
* @limit
|
* - 需要提前调用 startAutoLBS
|
* - 需要用户停留在当前页面
|
*
|
* @compat WeCom >= 2.4.20
|
*
|
* @example
|
* ```ts
|
* ww.onLocationChange(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 | 兼容性 |
|
* | --- | --- | --- |
|
* | auto:location:report:ok | 执行成功 | |
|
* | auto:location:report:fail, gps closed. | 用户关闭了 GPS | 企业微信 3.0.26 |
|
*/
|
export declare function onLocationChange(callback: APICallback<{
|
/**
|
* 纬度
|
*
|
* 范围为 90 ~ -90
|
*/
|
latitude: number;
|
/**
|
* 经度
|
*
|
* 范围为 180 ~ -180
|
*/
|
longitude: number;
|
/**
|
* 速度
|
*
|
* 单位为米/每秒
|
*/
|
speed: number;
|
/**
|
* 位置精度
|
*/
|
accuracy: number;
|
}>): void;
|
export declare enum NetworkType {
|
/**
|
* wifi
|
*/
|
wifi = "wifi",
|
/**
|
* 2g
|
*/
|
network2g = "2g",
|
/**
|
* 3g
|
*/
|
network3g = "3g",
|
/**
|
* 4g
|
*/
|
network4g = "4g",
|
/**
|
* 无网络
|
*/
|
none = "none",
|
/**
|
* Android下不常见的网络类型
|
*/
|
unknown = "unknown"
|
}
|
/**
|
* 获取网络状态。
|
*
|
* @compat WeCom iOS, Android; WeChat
|
*
|
* @example
|
* ```ts
|
* ww.getNetworkType()
|
* ```
|
*/
|
export declare function getNetworkType(params?: APIParams<IEmptyObject, {
|
/**
|
* 网络类型
|
*/
|
networkType: NetworkType;
|
}>): Promise<CommonResult & {
|
/**
|
* 网络类型
|
*/
|
networkType: NetworkType;
|
}>;
|
/**
|
* 监听网络状态变化。
|
*
|
* @compat WeCom iOS, Android
|
*
|
* @example
|
* ```ts
|
* ww.onNetworkStatusChange(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onNetworkStatusChange(callback: APICallback<{
|
/**
|
* 当前是否有网络连接
|
*/
|
isConnected: boolean;
|
/**
|
* 网络类型
|
*/
|
networkType: NetworkType;
|
}>): void;
|
export interface WifiInfo {
|
/**
|
* Wi-Fi 的 SSID
|
*/
|
SSID: string;
|
/**
|
* Wi-Fi 的 BSSID
|
*/
|
BSSID: string;
|
/**
|
* Wi-Fi 是否安全
|
*/
|
secure: boolean;
|
/**
|
* Wi-Fi 信号强度
|
*/
|
signalStrength: number;
|
}
|
/**
|
* 初始化 Wi-Fi 模块。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.startWifi()
|
* ```
|
*/
|
export declare function startWifi(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 关闭 Wi-Fi 模块。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.stopWifi()
|
* ```
|
*/
|
export declare function stopWifi(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 连接 Wi-Fi。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.connectWifi({
|
* SSID: 'vincenthome',
|
* BSSID: '8c:a6:df:c8:f7:4b',
|
* password: 'test1234',
|
* })
|
* ```
|
*/
|
export declare function connectWifi(params: APIParams<{
|
/**
|
* Wi-Fi 设备 SSID
|
*/
|
SSID: string;
|
/**
|
* Wi-Fi 设备 BSSID
|
*/
|
BSSID: string;
|
/**
|
* Wi-Fi 设备密码
|
*/
|
password?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 获取 Wi-Fi 列表。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.getWifiList()
|
* ```
|
*/
|
export declare function getWifiList(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 监听 Wi-Fi 列表更新。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.onGetWifiList(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onGetWifiList(callback: APICallback<{
|
/**
|
* Wi-Fi 列表数据
|
*/
|
wifiList: WifiInfo[];
|
}>): void;
|
/**
|
* 监听 Wi-Fi 连接成功。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.onWifiConnected(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onWifiConnected(callback: APICallback<{
|
/**
|
* Wi-Fi 信息
|
*/
|
wifi: WifiInfo;
|
}>): void;
|
/**
|
* 获取已连接中的 Wi-Fi 信息。
|
*
|
* @compat WeCom iOS, Android >= 2.4.16
|
*
|
* @example
|
* ```ts
|
* ww.getConnectedWifi()
|
* ```
|
*/
|
export declare function getConnectedWifi(params?: APIParams<IEmptyObject, {
|
/**
|
* Wi-Fi 信息
|
*/
|
wifi: WifiInfo;
|
}>): Promise<CommonResult & {
|
/**
|
* Wi-Fi 信息
|
*/
|
wifi: WifiInfo;
|
}>;
|
/**
|
* 预览文件
|
*
|
* @compat WeCom iOS, Android
|
*
|
* @note
|
* 本接口将 URL 对应的文件下载后,在内置浏览器中预览。目前支持图片、音频、视频、文档等格式的文件。
|
* 从 2.4.6 版本开始,iOS 版企业微信浏览器升级为 WkWebView,企业微信原生层面的网络请求读取不到WKWebview中设置的cookie,即使域名是相同的。
|
* **问题说明:**
|
* 如果页面的资源或图片存储的服务器依赖校验Cookie来返回数据的情况,在切换到WKWebview后,在企业微信内长按保存,或者点击预览文件时,原生层面发起的网络请求将不会完整地带上所设置的Cookie,会导致图片保存失败或预览失败。
|
* **适配建议:**
|
* 建议静态资源cookie free。如果确实有信息需要传递,可通过业务后台存储需要传递的信息,然后给页面一个存储信息相对应的access_token加密码,再通过Url中加入自己业务的access_token进行页面间信息传递。
|
*
|
* @example
|
* ```ts
|
* ww.previewFile({
|
* url: 'http://open.work.weixin.qq.com/wwopen/downloadfile/wwapi.zip',
|
* name: 'Android开发工具包集合',
|
* size: 22189
|
* })
|
* ```
|
*/
|
export declare function previewFile(params: APIParams<{
|
/**
|
* 需要预览文件的地址
|
*
|
* 可以使用相对路径
|
*/
|
url: string;
|
/**
|
* 需要预览文件的字节大小
|
*/
|
size: number;
|
/**
|
* 需要预览文件的文件名
|
*
|
* 默认为 URL 的最后部分
|
*/
|
name?: string;
|
}>): Promise<CommonResult>;
|
export declare enum ChooseMessageFileType {
|
/**
|
* 仅选择视频文件
|
*/
|
video = "video",
|
/**
|
* 仅选择图片文件
|
*/
|
image = "image",
|
/**
|
* 可选择除了图片和视频之外的其它的文件
|
*/
|
file = "file",
|
/**
|
* 可同时选择视频与图片
|
*/
|
video_and_image = "video_and_image"
|
}
|
export declare enum TempFileType {
|
/**
|
* 视频文件
|
*/
|
video = "video",
|
/**
|
* 图片文件
|
*/
|
image = "image",
|
/**
|
* 除图片和视频的文件
|
*/
|
file = "file"
|
}
|
/**
|
* 从企业微信会话中选择文件,用户选择文件之后,返回临时文件 localId,可再调用 [getLocalFileData](#56784) 获取文件内容。
|
*
|
* @compat WeCom iOS, Android >= 4.0.20
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 当前成员必须在应用的可见范围之中
|
*
|
* @example
|
* ```ts
|
* ww.chooseMessageFile({
|
* count: 10,
|
* type: 'image',
|
* })
|
* ```
|
*/
|
export declare function chooseMessageFile(params: APIParams<{
|
/**
|
* 最多可以选择的文件个数,取值范围: 1~100
|
*/
|
count: number;
|
/**
|
* 所选的文件的类型
|
* @default 'video_and_image'
|
*/
|
type?: ChooseMessageFileType;
|
}, {
|
/**
|
* 返回选择的文件的本地临时文件对象数组
|
*/
|
tempFiles: {
|
/**
|
* 本地临时文件 ID
|
*
|
* 仅在当前页面生命周期内可用,页面关闭后将会被清除
|
*/
|
localId: string;
|
/**
|
* 本地临时文件大小,单位 Byte
|
*/
|
size: number;
|
/**
|
* 选择的文件名称
|
*/
|
name: string;
|
/**
|
* 选择的文件类型
|
*/
|
type: TempFileType;
|
/**
|
* 选择的文件的会话发送时间,Unix时间戳
|
*/
|
time: number;
|
}[];
|
}>): Promise<CommonResult & {
|
/**
|
* 返回选择的文件的本地临时文件对象数组
|
*/
|
tempFiles: {
|
/**
|
* 本地临时文件 ID
|
*
|
* 仅在当前页面生命周期内可用,页面关闭后将会被清除
|
*/
|
localId: string;
|
/**
|
* 本地临时文件大小,单位 Byte
|
*/
|
size: number;
|
/**
|
* 选择的文件名称
|
*/
|
name: string;
|
/**
|
* 选择的文件类型
|
*/
|
type: TempFileType;
|
/**
|
* 选择的文件的会话发送时间,Unix时间戳
|
*/
|
time: number;
|
}[];
|
}>;
|
/**
|
* 获取 chooseMessageFile 返回的 localId 对应的文件内容。
|
*
|
* @compat WeCom iOS, Android >= 4.0.20
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 当前成员必须在应用的可见范围之中
|
*
|
* @example
|
* ```ts
|
* ww.getLocalFileData({
|
* localId: '',
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | getLocalFileData:ok | 执行成功 |
|
* | no permission | 应用签名校验失败,或成员不在应用的可见范围内 |
|
* | no such file | localId不存在或者文件已删除 |
|
* | file exceed size limit | 不支持超过20M的文件 |
|
*/
|
export declare function getLocalFileData(params: APIParams<{
|
/**
|
* 本地临时文件 ID
|
*/
|
localId: string;
|
}, {
|
/**
|
* 文件内容的base64编码
|
*/
|
localData: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 文件内容的base64编码
|
*/
|
localData: string;
|
}>;
|
export declare enum SizeType {
|
/**
|
* 原图
|
*/
|
original = "original",
|
/**
|
* 压缩后的图片
|
*/
|
compressed = "compressed"
|
}
|
export declare enum SourceType {
|
/**
|
* 相册
|
*/
|
album = "album",
|
/**
|
* 相机,企业微信 2.3 及以后版本支持相机连拍
|
*/
|
camera = "camera"
|
}
|
export declare enum CameraMode {
|
/**
|
* 单拍
|
*/
|
normal = "normal",
|
/**
|
* 连拍
|
*
|
* @compat WeCom >= 2.3.0
|
*/
|
batch = "batch",
|
/**
|
* 前置摄像头单拍
|
*
|
* @compat WeCom >= 3.0.26
|
*/
|
front = "front",
|
/**
|
* 前置摄像头连拍
|
*
|
* @compat WeCom >= 3.0.26
|
*/
|
batch_front = "batch_front"
|
}
|
/**
|
* 拍照或从手机相册中选图。
|
*
|
* @example
|
* ```ts
|
* ww.chooseImage({
|
* count: 1,
|
* sizeType: ['original', 'compressed'],
|
* sourceType: ['album', 'camera'],
|
* defaultCameraMode: 'batch',
|
* isSaveToAlbum: true
|
* })
|
* ```
|
*/
|
export declare function chooseImage(params?: APIParams<{
|
/**
|
* 选择图片数量
|
*
|
* @default 9
|
*/
|
count?: number;
|
/**
|
* 选择原图还是压缩后的图片
|
*/
|
sizeType?: SizeType[];
|
/**
|
* 选择图片来源
|
*/
|
sourceType?: SourceType[];
|
/**
|
* 进入拍照界面的默认模式,用户进入拍照界面仍然可自由切换模式
|
*
|
* @compat WeCom >= 2.4.20
|
*/
|
defaultCameraMode?: CameraMode;
|
/**
|
* 拍照时是否保存到系统相册
|
*
|
* @default true
|
*
|
* @compat WeCom >= 2.7.5
|
*/
|
isSaveToAlbum?: boolean;
|
}, {
|
/**
|
* 选定照片的本地 ID 列表
|
*
|
* @note
|
* - 在 Android 中 localId 可以作为 img 标签的 src 属性
|
* - 在 iOS 中需要通过 getLocalImgData 获取图片 base64 数据再用于显示
|
*/
|
localIds: string[];
|
}>): Promise<CommonResult & {
|
/**
|
* 选定照片的本地 ID 列表
|
*
|
* @note
|
* - 在 Android 中 localId 可以作为 img 标签的 src 属性
|
* - 在 iOS 中需要通过 getLocalImgData 获取图片 base64 数据再用于显示
|
*/
|
localIds: string[];
|
}>;
|
/**
|
* 预览图片
|
*
|
* @note
|
* 从2.4.6版本开始,IOS版企业微信浏览器升级为WkWebView,企业微信原生层面的网络请求读取不到WKWebview中设置的cookie,即使域名是相同的。
|
* **问题说明:**
|
* 如果页面的资源或图片存储的服务器依赖校验Cookie来返回数据的情况,在切换到WKWebview后,在企业微信内长按保存,或者点击预览大图时,原生层面发起的网络请求将不会完整地带上所设置的Cookie,会导致图片保存失败或预览失败。
|
* **适配建议**
|
* 建议静态资源cookie free。如果确实有信息需要传递,可通过业务后台存储需要传递的信息,然后给页面一个存储信息相对应的access_token加密码,再通过Url中加入自己业务的access_token进行页面间信息传递。
|
*
|
* @example
|
* ```ts
|
* ww.previewImage({
|
* current: imgURL,
|
* urls: [imgURL]
|
* });
|
* ```
|
*/
|
export declare function previewImage(params: APIParams<{
|
/**
|
* 当前显示图片的链接
|
*/
|
current: string;
|
/**
|
* 需要预览的图片链接列表
|
*/
|
urls: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 上传图片。
|
*
|
* @note
|
* 上传的图片有效期 3 天,可用[素材管理](#90253)接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。
|
*
|
* @example
|
* ```ts
|
* ww.uploadImage({
|
* localId: localId,
|
* isShowProgressTips: true
|
* })
|
* ```
|
*/
|
export declare function uploadImage(params: APIParams<{
|
/**
|
* 需要上传的图片的本地 ID
|
*
|
* 可通过 chooseImage 接口获得
|
*/
|
localId: string;
|
/**
|
* 是否显示进度提示
|
*
|
* @default true
|
*/
|
isShowProgressTips?: boolean;
|
}, {
|
/**
|
* 返回图片的服务器端 ID
|
*/
|
serverId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 返回图片的服务器端 ID
|
*/
|
serverId: string;
|
}>;
|
/**
|
* 下载图片。
|
*
|
* @example
|
* ```ts
|
* ww.downloadImage({
|
* serverId: serverId,
|
* isShowProgressTips: true
|
* })
|
* ```
|
*/
|
export declare function downloadImage(params: APIParams<{
|
/**
|
* 需要下载的图片的服务器端 ID
|
*
|
* 由 uploadImage 接口获得
|
*/
|
serverId: string;
|
/**
|
* 显示进度提示
|
*
|
* @default true
|
*/
|
isShowProgressTips?: boolean;
|
}, {
|
/**
|
* 返回图片下载后的本地 ID
|
*/
|
localId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 返回图片下载后的本地 ID
|
*/
|
localId: string;
|
}>;
|
/**
|
* 获取本地图片内容。
|
*
|
* @limit
|
* 仅在 iOS WKWebView 下支持。
|
*
|
* @compat WeCom iOS >= 2.4.6
|
*
|
* @example
|
* ```ts
|
* ww.getLocalImgData({
|
* localId: localId
|
* })
|
* ```
|
*/
|
export declare function getLocalImgData(params: APIParams<{
|
/**
|
* 图片的local ID
|
*/
|
localId: string;
|
}, {
|
/**
|
* 图片的 base64 数据
|
*/
|
localData: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 图片的 base64 数据
|
*/
|
localData: string;
|
}>;
|
/**
|
* 开始录音。
|
*
|
* @example
|
* ```ts
|
* ww.startRecord()
|
* ```
|
*/
|
export declare function startRecord(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 停止录音。
|
*
|
* @example
|
* ```ts
|
* ww.stopRecord()
|
* ```
|
*/
|
export declare function stopRecord(params?: APIParams<IEmptyObject, {
|
/**
|
* 音频的本地 ID
|
*/
|
localId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 音频的本地 ID
|
*/
|
localId: string;
|
}>;
|
/**
|
* 监听录音自动停止。
|
*
|
* @note
|
* 录音时间超过一分钟没有停止的时候会执行 complete 回调
|
*
|
* @example
|
* ```ts
|
* ww.onVoiceRecordEnd(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onVoiceRecordEnd(callback: APICallback<{
|
/**
|
* 音频的本地 ID
|
*/
|
localId: string;
|
}>): void;
|
/**
|
* 播放语音。
|
*
|
* @example
|
* ```ts
|
* ww.playVoice({
|
* localId: localId
|
* })
|
* ```
|
*/
|
export declare function playVoice(params: APIParams<{
|
/**
|
* 需要播放的音频的本地 ID
|
*
|
* 通过 stopRecord 接口获得
|
*/
|
localId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 暂停播放。
|
*
|
* @example
|
* ```ts
|
* ww.pauseVoice({
|
* localId: localId
|
* })
|
* ```
|
*/
|
export declare function pauseVoice(params: APIParams<{
|
/**
|
* 需要暂停的音频的本地 ID
|
*
|
* 通过 stopRecord 接口获得
|
*/
|
localId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 停止播放。
|
*
|
* @example
|
* ```ts
|
* ww.stopVoice({
|
* localId: localId
|
* })
|
* ```
|
*/
|
export declare function stopVoice(params: APIParams<{
|
/**
|
* 需要停止的音频的本地 ID
|
*
|
* 通过 stopRecord 接口获得
|
*/
|
localId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 监听语音播放完毕。
|
*
|
* @example
|
* ```ts
|
* ww.onVoicePlayEnd(function(event) {
|
* console.log(event)
|
* })
|
* ```
|
*/
|
export declare function onVoicePlayEnd(callback: APICallback<{
|
/**
|
* 音频的本地 ID
|
*/
|
localId: string;
|
}>): void;
|
/**
|
* 上传语音。
|
*
|
* @note
|
* 上传语音有效期 3 天,可以通过[素材管理](https://developer.work.weixin.qq.com/document/path/91054)接口下载语音到自己的服务器,接口返回的的 `serverId` 即 `media_id`。
|
*
|
* @example
|
* ```ts
|
* ww.uploadVoice({
|
* localId: localId,
|
* isShowProgressTips: true
|
* })
|
* ```
|
*/
|
export declare function uploadVoice(params: APIParams<{
|
/**
|
* 需要上传的音频的本地 ID
|
*
|
* 通过 stopRecord 接口获得
|
*/
|
localId: string;
|
/**
|
* 是否显示进度提示
|
*
|
* @default true
|
*/
|
isShowProgressTips?: boolean;
|
}, {
|
/**
|
* 音频的服务器端 ID
|
*/
|
serverId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 音频的服务器端 ID
|
*/
|
serverId: string;
|
}>;
|
/**
|
* 下载语音。
|
*
|
* @example
|
* ```ts
|
* ww.downloadVoice({
|
* serverId: serverId,
|
* isShowProgressTips: true
|
* })
|
* ```
|
*/
|
export declare function downloadVoice(params: APIParams<{
|
/**
|
* 需要下载的音频的服务器端 ID
|
*
|
* 通过 uploadVoice 接口获得
|
*/
|
serverId: string;
|
/**
|
* 是否显示进度提示
|
*
|
* @default true
|
*/
|
isShowProgressTips?: boolean;
|
}, {
|
/**
|
* 音频的本地 ID
|
*/
|
localId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 音频的本地 ID
|
*/
|
localId: string;
|
}>;
|
/**
|
* 语音转文字。
|
*
|
* @compat WeCom iOS, Android >= 2.7.5
|
*
|
* @example
|
* ```ts
|
* ww.translateVoice({
|
* localId: localId,
|
* isShowProgressTips: true
|
* })
|
* ```
|
*/
|
export declare function translateVoice(params: APIParams<{
|
/**
|
* 需要识别的音频的本地 ID
|
*
|
* 通过 stopRecord 接口获得,音频时长不能超过 60 秒
|
*/
|
localId: string;
|
/**
|
* 是否显示进度提示
|
*
|
* @default true
|
*/
|
isShowProgressTips?: boolean;
|
}, {
|
/**
|
* 识别结果
|
*/
|
translateResult: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 识别结果
|
*/
|
translateResult: string;
|
}>;
|
export declare enum LiveType {
|
/**
|
* 通用直播
|
*/
|
common = 0,
|
/**
|
* 企业培训
|
*/
|
corp_training = 1,
|
/**
|
* 大班课
|
*/
|
edu_normal_class = 2,
|
/**
|
* 小班课
|
*/
|
edu_small_class = 3
|
}
|
export interface StartLivingResult {
|
/**
|
* 直播 ID
|
*/
|
livingId: string;
|
}
|
/**
|
* 创建直播并调起直播页面
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需具有直播使用权限,见[配置可使用直播的应用](#25967/配置可使用直播的应用)
|
* - 创建直播的场景下,用户必须在应用可见范围内
|
*
|
* @compat WeCom >= 3.1.0
|
*
|
* @example
|
* ```ts
|
* ww.startLiving({
|
* liveType: 1,
|
* theme: '新同学培训',
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | startLiving:ok | 执行成功 |
|
* | startLiving:fail no permission | 应用签名失败,或应用无直播权限 |
|
* | startLiving:fail user not in allow list | 直播发起人必须在应用可见范围内 |
|
* | startLiving:fail invalid parameter | 参数不合法 |
|
* | startLiving:fail unsupported liveType | 不支持的直播类型。部分类型仅对特殊行业放开 |
|
* | startLiving:fail api freq out of limit | 创建直播超过频率限制。单应用每天不可创建超过1w个直播 |
|
*/
|
export declare function startLiving(params?: APIParams<{
|
/**
|
* 直播类型
|
*
|
* Mac 端只支持通用直播
|
*/
|
liveType?: LiveType;
|
/**
|
* 直播主题
|
*
|
* @limit
|
* 最多支持 20 个 UTF-8 字符
|
*/
|
theme?: string;
|
}, StartLivingResult>): Promise<StartLivingResult>;
|
/**
|
* 调起直播预约详情或进行中的直播间页面。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需具有直播使用权限,见[配置可使用直播的应用](#25967/配置可使用直播的应用)
|
*
|
* @compat WeCom >= 3.1.0
|
*
|
* @example
|
* ```ts
|
* ww.startLiving({
|
* livingId: 'LIVINGID'
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | startLiving:ok | 执行成功 |
|
* | startLiving:fail no permission | 应用签名失败,或应用无直播权限 |
|
* | startLiving:fail invalid living id | 不合法的直播ID |
|
* | startLiving:fail not allow to cross corp | 不可跨企业使用直播ID |
|
* | startLiving:fail not allow to cross app | 不可跨应用使用直播ID |
|
* | startLiving:fail invalid parameter | 参数不合法 |
|
* | startLiving:fail invalid department id | 不合法的班级ID |
|
* | startLiving:fail exceed department id list size | 超过最大的班级个数 |
|
*
|
*/
|
export declare function startLiving(params: APIParams<{
|
/**
|
* 直播 ID
|
*/
|
livingId: string;
|
}, StartLivingResult>): Promise<StartLivingResult>;
|
/**
|
* 调起直播间回放页面。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需具有直播使用权限,参考[配置可使用直播的应用](#25967/配置可使用直播的应用)
|
*
|
* @compat WeCom >= 3.1.0
|
*
|
* @example
|
* ```ts
|
* ww.replayLiving({
|
* livingId: 'LIVINGID'
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | replayLiving:ok | 执行成功 |
|
* | replayLiving:fail no permission | 应用签名校验失败,或应用不具备直播权限 |
|
* | replayLiving:fail invalid living id | 不合法的直播ID |
|
* | replayLiving:fail not allow to cross corp | 不可跨企业使用直播ID |
|
* | replayLiving:fail not allow to cross app | 不可跨应用使用直播ID |
|
* | replayLiving:fail living has no replay | 不存在直播回放 |
|
* | replayLiving:fail replay is beging creating | 正在直播中,或回放正在生成中,稍后观看回放 |
|
* | replayLiving:fail create replay failed | 回放创建失败 |
|
* | replayLiving:fail invalid parameter | 参数不合法 |
|
*/
|
export declare function replayLiving(params: APIParams<{
|
/**
|
* 直播 ID
|
*/
|
livingId: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 调起直播回放下载页面。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需具有直播使用权限,参考[配置可使用直播的应用](#25967/配置可使用直播的应用)
|
* - 只允许直播的发起人下载直播回放
|
*
|
* @compat WeCom PC >= 3.1.0
|
*
|
* @example
|
* ```ts
|
* ww.downloadLivingReplay({
|
* livingId: 'LIVINGID'
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | downloadLivingReplay:ok | 执行成功 |
|
* | downloadLivingReplay:fail no permission | 应用签名校验失败,或应用不具备直播权限 |
|
* | downloadLivingReplay:fail invalid living id | 不合法的直播ID |
|
* | downloadLivingReplay:fail not allow to cross corp | 不可跨企业使用直播ID |
|
* | downloadLivingReplay:fail not allow to cross app | 不可跨应用使用直播ID |
|
* | downloadLivingReplay:fail invalid parameter | 参数不合法 |
|
* | downloadLivingReplay:fail living has no replay | 不存在直播回放 |
|
* | downloadLivingReplay:fail replay is beging creating | 正在直播中,或回放正在生成中,稍后观看回放 |
|
* | downloadLivingReplay:fail create replay failed | 回放创建失败 |
|
* | downloadLivingReplay:fail invalid operator | 只允许直播的发起人下载直播回放 |
|
*/
|
export declare function downloadLivingReplay(params: APIParams<{
|
/**
|
* 直播 ID
|
*/
|
livingId: string;
|
}>): Promise<CommonResult>;
|
export interface StartMeetingResult {
|
/**
|
* 会议 ID
|
*/
|
meetingId: string;
|
}
|
/**
|
* 创建会议
|
*
|
* 创建临时会议并调起进行中的会议室页面.
|
*
|
* @compat WeCom >= 4.0
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有会议使用权限,参考[配置可使用会议的应用](#25775/配置可使用会议的应用)
|
* - 用户需要在应用可见范围内
|
*
|
* @example
|
* ```ts
|
* // 创建会议
|
* ww.startMeeting()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | startMeeting:ok | 执行成功 |
|
* | startMeeting:fail no permission | 应用签名校验失败,或成员不在应用的可见范围内,或应用未开启会议使用权限 |
|
* | startMeeting:fail user not in allow list | 会议发起人必须在应用可见范围 |
|
* | startMeeting:fail invalid parameter | 参数不合法 |
|
* | startMeeting:fail api freq out of limit | 创建会议超过频率限制。单应用每天不可创建超过1w个会议 |
|
*/
|
export declare function startMeeting(params?: APIParams<IEmptyObject, StartMeetingResult>): Promise<StartMeetingResult>;
|
/**
|
* 进入会议
|
*
|
* 通过传入 meetingId 进入已有会议。
|
*
|
* @compat WeCom >= 3.1.0
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有会议使用权限,参考[配置可使用会议的应用](#25775/配置可使用会议的应用)
|
* - 用户需要在应用可见范围内
|
*
|
* @example
|
* ```ts
|
* ww.startMeeting({
|
* meetingId: 'MEETINGID'
|
* })
|
* ```
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | startMeeting:ok | 执行成功 |
|
* | startMeeting:fail no permission | 应用签名校验失败,或成员不在应用的可见范围内,或应用未开启会议使用权限 |
|
* | startMeeting:fail user not in allow list | 会议发起人必须在应用可见范围 |
|
* | startMeeting:fail not allow to cross corp | 不可跨企业使用会议ID |
|
* | startMeeting:fail invalid meeting id | 不合法的会议ID |
|
* | startMeeting:fail not allow to cross app | 不可跨应用使用会议ID |
|
* | startMeeting:fail invalid parameter | 参数不合法 |
|
*/
|
export declare function startMeeting(params: APIParams<{
|
/**
|
* 会议 ID,可通过[创建预约会议](#25245)或通过调用ww.startMeeting()获取
|
* 为空的情况下创建快速会议
|
*/
|
meetingId?: string;
|
}, StartMeetingResult>): Promise<StartMeetingResult>;
|
/**
|
* 新建文档、表格或者收集表。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 签名应用必须具有文档使用权限
|
* - 当前用户必须在应用的可见范围之内
|
* - 在 Mac 端使用时,macOS 版本需 > 10.12
|
*
|
* @compat WeCom >= 4.1.0
|
*
|
* @example
|
* ```
|
* ww.createDoc({
|
* docType: 3
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | createDoc:ok | 执行成功 |
|
* | createDoc:fail no permission | 应用签名校验失败,或成员不在应用的可见范围内,或应用未开启文档使用权限 |
|
* | createDoc:fail doc app closed. | 基础应用“文档”如果未启用 |
|
* | createDoc:fail form app closed. | 基础应用“收集表”如果没有启用 |
|
*/
|
export declare function createDoc(params: APIParams<{
|
/**
|
* 文档类型
|
* 3: 文档,4: 表格, 5: 收集表, 6: PPT, 10: 智能表格,其他类型暂不支持
|
*/
|
docType: number;
|
}, {
|
result: {
|
/**
|
* 选择的在线文档的URL列表
|
*/
|
selectedFileUrls: string;
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 选择的在线文档的URL列表
|
*/
|
selectedFileUrls: string;
|
};
|
}>;
|
export declare enum WedocSelectedFileType {
|
/**
|
* 其他
|
*/
|
other = 0,
|
/**
|
* 文档
|
*/
|
doc = 3,
|
/**
|
* 表格
|
*/
|
sheet = 4,
|
/**
|
* 收集表
|
*/
|
form = 5,
|
/**
|
* 幻灯片
|
*/
|
slide = 6,
|
/**
|
* 思维导图
|
*/
|
mindmap = 7,
|
/**
|
* 流程图
|
*/
|
flowchart = 8,
|
/**
|
* 智能表格
|
*/
|
smartsheet = 10
|
}
|
/**
|
* 选择一个或多个文档,返回对应文档的 URL。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册,签名应用必须具有文档使用权限
|
* - 当前用户必须在应用的可见范围之内
|
* - Mac 端使用时,macOS 版本需 > 10.12
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```
|
* ww.wedocSelectDoc({
|
* selectedFileNum: 1
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | wedocSelectDoc:ok | 执行成功 |
|
* | wedocSelectDoc:cancel | 取消选择 |
|
* | wedocSelectDoc:fail no permission | 应用签名失败,或应用无文档使用权限,或用户不在应用可见范围内 |
|
* | wedocSelectDoc:fail param error | 参数错误 |
|
* | wedocSelectDoc:fail context error | 选择器异常 |
|
* | wedocSelectDoc:fail not supported system version| 低系统版本不支持 |
|
*/
|
export declare function wedocSelectDoc(params: APIParams<{
|
/**
|
* 选择文件的数量
|
*
|
* 1 表示单选,大于 1 表示多选,上限为 50
|
*/
|
selectedFileNum: number;
|
}, {
|
result: {
|
/**
|
* 选择的在线文档的 URL 列表
|
*
|
* @deprecated 该字段即将废弃,请使用 selectedFileInfos 代替
|
*/
|
selectedFileUrls: string;
|
/**
|
* 选择的文档信息列表
|
*
|
* @compat WeCom >= 4.1.8
|
*/
|
selectedFileInfos: {
|
/**
|
* 选择的文档url
|
*/
|
url: string;
|
/**
|
* 选择的文档类型
|
*/
|
type: WedocSelectedFileType;
|
}[];
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 选择的在线文档的 URL 列表
|
*
|
* @deprecated 该字段即将废弃,请使用 selectedFileInfos 代替
|
*/
|
selectedFileUrls: string;
|
/**
|
* 选择的文档信息列表
|
*
|
* @compat WeCom >= 4.1.8
|
*/
|
selectedFileInfos: {
|
/**
|
* 选择的文档url
|
*/
|
url: string;
|
/**
|
* 选择的文档类型
|
*/
|
type: WedocSelectedFileType;
|
}[];
|
};
|
}>;
|
/**
|
* 在微盘中选择一个具有可上传权限的目录/空间,返回选中目录/空间对应的 selectedTicket。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 所使用的应用必须具有微盘权限
|
* - 当前成员必须在应用的可见范围之内
|
* - 若用户在某一目录位置不具备「上传」权限(微盘权限值为“可下载”/“仅预览”或自定义权限取消勾选“上传”权限),则无法选择该目录
|
* - 在 Mac 端使用时,macOS 版本需 > 10.12
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```
|
* ww.wedriveSelectDir()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | wedriveSelectDir:ok | 执行成功 |
|
* | wedriveSelectDir:cancel | 取消选择 |
|
* | wedriveSelectDir:fail no permission | 无权限 |
|
* | wedriveSelectDir:fail param error | 参数错误 |
|
* | wedriveSelectDir:fail context error | 选择器异常 |
|
* | wedriveSelectDir:fail not supported system version | 低系统版本不支持 |
|
*/
|
export declare function wedriveSelectDir(params?: APIParams<IEmptyObject, {
|
result: {
|
/**
|
* 选择的目录/空间所生成的临时 ticket
|
*
|
* 可调用文件上传和文件分块上传接口。有效期 30 分钟,最多可以使用 500 次
|
*/
|
selectedTicket: string;
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 选择的目录/空间所生成的临时 ticket
|
*
|
* 可调用文件上传和文件分块上传接口。有效期 30 分钟,最多可以使用 500 次
|
*/
|
selectedTicket: string;
|
};
|
}>;
|
/**
|
* 唤起微盘选择器,选择微盘中的文件
|
*
|
* 在微盘中选择一个或多个具有可分享权限的微盘文件或在线文档,返回选中文件的 url。
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 所使用的应用必须具有微盘和文档使用权限
|
* - 当前成员必须在应用的可见范围之内
|
* - 若用户对某文件不具备「分享」权限(微盘自定义权限取消勾选“分享”权限),则无法选择该文件。
|
* - 在 Mac 端使用时,macOS 版本需 > 10.12
|
*
|
* @example
|
* ```
|
* ww.wedriveSelectFile({
|
* selectedFileNum: 1,
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | wedriveSelectFile:ok | 执行成功 |
|
* | wedriveSelectFile:cancel | 取消选择 |
|
* | wedriveSelectFile:fail no permission | 无权限 |
|
* | wedriveSelectFile:fail param error | 参数错误 |
|
* | wedriveSelectFile:fail context error | 选择器异常 |
|
* | wedriveSelectFile:fail not supported system version | 低系统版本不支持 |
|
*/
|
export declare function wedriveSelectFile(params: APIParams<{
|
/**
|
* 选择文件的数量
|
*
|
* 1 表示单选,大于 1 表示多选,上限为 50
|
*/
|
selectedFileNum: number;
|
}, {
|
result: {
|
/**
|
* 选择的文件的 URL 列表
|
* @deprecated 后续废弃,请使用selectedFileInfos
|
*/
|
selectedFileUrls: string[];
|
/**
|
* 选择的文件信息列表
|
* @compat WeCom >= 4.1.8
|
*/
|
selectedFileInfos: {
|
/**
|
* 选择的文件url
|
*/
|
url: string;
|
/**
|
* 选择的文件类型。0: 其他,2: 文件,3: 文档,4: 表格,5: 收集表,6: 幻灯片,7: 思维导图,8: 流程图,10: 智能表格
|
*/
|
type: number;
|
}[];
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 选择的文件的 URL 列表
|
* @deprecated 后续废弃,请使用selectedFileInfos
|
*/
|
selectedFileUrls: string[];
|
/**
|
* 选择的文件信息列表
|
* @compat WeCom >= 4.1.8
|
*/
|
selectedFileInfos: {
|
/**
|
* 选择的文件url
|
*/
|
url: string;
|
/**
|
* 选择的文件类型。0: 其他,2: 文件,3: 文档,4: 表格,5: 收集表,6: 幻灯片,7: 思维导图,8: 流程图,10: 智能表格
|
*/
|
type: number;
|
}[];
|
};
|
}>;
|
/**
|
* 选择可分享的文件
|
*
|
* 在微盘中选择一个或多个具有可分享权限的微盘文件或在线文档,返回选中文件的 url。
|
*
|
* @deprecated 该接口即将废弃,请使用 wedriveSelectFile 代替
|
*
|
* @compat WeCom >= 4.0.12
|
*/
|
export declare function wedriveSelectFileForShare(params: APIParams<{
|
/**
|
* 选择文件的数量
|
*
|
* 1 表示单选,大于 1 表示多选,上限为 50
|
*/
|
selectedFileNum: number;
|
}, {
|
result: {
|
/**
|
* 选择的文件的 URL 列表
|
*/
|
selectedFileUrls: string[];
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 选择的文件的 URL 列表
|
*/
|
selectedFileUrls: string[];
|
};
|
}>;
|
/**
|
* 在微盘中选择一个或多个具有下载权限的文件(只能是微盘文件,不支持在线文档),返回选中文件对应的 selectedTickets 列表。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有微盘使用权限
|
* - 当前成员必须在应用的可见范围之中
|
* - 自建应用不支持调用
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```
|
* ww.wedriveSelectFileForDownload({
|
* selectedFileNum: 1
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | wedriveSelectFileForDownload:ok | 执行成功 |
|
* | wedriveSelectFileForDownload:cancel | 取消选择 |
|
* | wedriveSelectFileForDownload:fail no permission | 无权限 |
|
* | wedriveSelectFileForDownload:fail param error | 参数错误 |
|
* | wedriveSelectFileForDownload:fail context error | 选择器异常 |
|
* | wedriveSelectFileForDownload:fail not supported system version | 低系统版本不支持 |
|
*/
|
export declare function wedriveSelectFileForDownload(params: APIParams<{
|
/**
|
* 选择文件的数量
|
*
|
* 1 表示单选,大于 1 表示多选,上限为 50
|
*/
|
selectedFileNum: number;
|
}, {
|
result: {
|
/**
|
* 选择的文件所生成的临时 ticket 列表
|
*
|
* 每个文件对应一个ticket,可调用文件[下载接口](#93657)。有效期 30 分钟,不限制使用次数
|
*/
|
selectedTickets: string[];
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 选择的文件所生成的临时 ticket 列表
|
*
|
* 每个文件对应一个ticket,可调用文件[下载接口](#93657)。有效期 30 分钟,不限制使用次数
|
*/
|
selectedTickets: string[];
|
};
|
}>;
|
export interface HistoryBackCallback {
|
/**
|
* @returns 是否取消返回操作
|
*/
|
(): boolean;
|
}
|
/**
|
* 监听页面返回事件。
|
*
|
* @param callback 回调函数,返回 false 则表示中断此次返回操作
|
*
|
* @limit
|
* - 当页面左上角没有关闭按钮,不产生该事件
|
* - iOS 系统下使用手势返回时,不产生该事件
|
*
|
* @compat WeCom iOS, Android >= 2.2.0; WeCom PC, Mac >= 2.4.5
|
*
|
* @example
|
* ```ts
|
* ww.onHistoryBack(function() {
|
* return confirm('确定放弃当前页面的修改?')
|
* })
|
* ```
|
*/
|
export declare function onHistoryBack(callback: HistoryBackCallback): void;
|
/**
|
* 隐藏右上角菜单。
|
*
|
* @example
|
* ```ts
|
* ww.hideOptionMenu()
|
* ```
|
*/
|
export declare function hideOptionMenu(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 显示右上角菜单。
|
*
|
* @example
|
* ```ts
|
* ww.showOptionMenu()
|
* ```
|
*/
|
export declare function showOptionMenu(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 关闭当前网页窗口。
|
*
|
* @example
|
* ```ts
|
* ww.closeWindow()
|
* ```
|
*/
|
export declare function closeWindow(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 批量隐藏功能按钮。
|
*
|
* @note
|
* 完整功能按钮列表请参考[所有菜单项列表](#14926)。
|
*
|
* @example
|
* ```ts
|
* ww.hideMenuItems({
|
* menuList: ['menuItem:setFont']
|
* })
|
* ```
|
*/
|
export declare function hideMenuItems(params: APIParams<{
|
/**
|
* 要隐藏的菜单项
|
*/
|
menuList: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 批量显示功能按钮。
|
*
|
* @note
|
* 完整功能按钮列表请参考[所有菜单项列表](#14926)。
|
*
|
* @example
|
* ```ts
|
* ww.showMenuItems({
|
* menuList: ['menuItem:setFont']
|
* })
|
* ```
|
*/
|
export declare function showMenuItems(params: APIParams<{
|
/**
|
* 要显示的菜单项
|
*/
|
menuList: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 隐藏所有非基础按钮。
|
*
|
* @example
|
* ```ts
|
* ww.hideAllNonBaseMenuItem()
|
* ```
|
*/
|
export declare function hideAllNonBaseMenuItem(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 显示所有功能按钮。
|
*
|
* @example
|
* ```ts
|
* ww.showAllNonBaseMenuItem()
|
* ```
|
*/
|
export declare function showAllNonBaseMenuItem(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 使用系统浏览器打开指定 URL,支持传入 oauth2 链接,从而实现在系统浏览器内免登录的效果。
|
*
|
* @compat WeCom PC >= 2.3.0
|
*
|
* @example
|
* ```ts
|
* ww.openDefaultBrowser({
|
* url: 'https://work.weixin.qq.com/'
|
* })
|
* ```
|
*/
|
export declare function openDefaultBrowser(params: APIParams<{
|
/**
|
* 在默认浏览器打开的 URL
|
*
|
* 若 URL 为 oauth2 链接,跳转时将附带上 code 参数
|
*/
|
url: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 监听用户截屏事件。
|
*
|
* @compat WeCom iOS, Android >= 2.5.0
|
*
|
* @example
|
* ```ts
|
* ww.onUserCaptureScreen(function() {
|
* console.log('用户截屏了')
|
* })
|
* ```
|
*/
|
export declare function onUserCaptureScreen(callback: APICallback): void;
|
/**
|
* 获取「转发」按钮点击状态并自定义分享内容。
|
*
|
* @note
|
* 微信客户端即将废弃该接口。
|
*
|
* @limit
|
* - 仅激活成员数超过 200 人且已经认证的企业才可在微信上调用
|
*
|
* @example
|
* ```ts
|
* ww.onMenuShareAppMessage({
|
* title: '企业微信',
|
* desc: '让每个企业都有自己的微信',
|
* link: 'https://work.weixin.qq.com/',
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
|
* success() {
|
* // 用户确认分享后回调
|
* },
|
* cancel() {
|
* // 用户取消分享后回调
|
* }
|
* })
|
* ```
|
*/
|
export declare function onMenuShareAppMessage(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享描述
|
*/
|
desc?: string;
|
/**
|
* 分享链接
|
*
|
* 在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
/**
|
* @compat WeCom >= 4.0.20
|
* 是否开启id转译, 1 为开启,0 为关闭,默认为0
|
* 仅供第三方应用使用
|
* 必须使用应用身份进行注册
|
*/
|
enableIdTrans?: number;
|
}>): void;
|
/**
|
* 获取「分享到朋友圈」按钮点击状态并自定义分享内容。
|
*
|
* @note
|
* 微信客户端即将废弃该接口。
|
*
|
* @example
|
* ```ts
|
* ww.onMenuShareTimeline({
|
* title: '企业微信',
|
* link: 'https://work.weixin.qq.com/',
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
|
* success() {
|
* // 用户确认分享后回调
|
* },
|
* cancel() {
|
* // 用户取消分享后回调
|
* }
|
* })
|
* ```
|
*/
|
export declare function onMenuShareTimeline(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享链接
|
*
|
* 在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
/**
|
* @compat WeCom >= 4.0.20
|
* 是否开启id转译, 1 为开启,0 为关闭,默认为0
|
* 仅供第三方应用使用
|
* 必须使用应用身份进行注册
|
*/
|
enableIdTrans?: number;
|
/** */
|
type?: string;
|
/** */
|
dataUrl?: string;
|
}>): void;
|
/**
|
* 获取「微信」按钮点击状态并自定义分享内容。
|
*
|
* @compat WeCom
|
*
|
* @example
|
* ```ts
|
* ww.onMenuShareWechat({
|
* title: '企业微信',
|
* desc: '让每个企业都有自己的微信',
|
* link: 'https://work.weixin.qq.com/',
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
|
* success() {
|
* // 用户确认分享后回调
|
* },
|
* cancel() {
|
* // 用户取消分享后回调
|
* }
|
* })
|
* ```
|
*/
|
export declare function onMenuShareWechat(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享描述
|
*/
|
desc?: string;
|
/**
|
* 分享链接
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
/**
|
* @compat WeCom >= 4.0.20
|
* 是否开启id转译, 1 为开启,0 为关闭,默认为0
|
* 仅供第三方应用使用
|
* 必须使用应用身份进行注册
|
*/
|
enableIdTrans?: number;
|
/** */
|
type?: string;
|
/** */
|
dataUrl?: string;
|
}>): void;
|
/**
|
* 获取「分享到QQ」按钮点击状态并自定义分享内容。
|
*
|
* @note
|
* 微信客户端即将废弃该接口。
|
*
|
* @compat WeChat
|
*/
|
export declare function onMenuShareQQ(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享描述
|
*/
|
desc?: string;
|
/**
|
* 分享链接
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
}>): void;
|
/**
|
* 获取「分享到微博」按钮点击状态并自定义分享内容。
|
*
|
* @compat WeChat
|
*/
|
export declare function onMenuShareWeibo(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享描述
|
*/
|
desc?: string;
|
/**
|
* 分享链接
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
}>): void;
|
/**
|
* 获取「分享到QQ空间」按钮点击状态并自定义分享内容。
|
*
|
* @note
|
* 微信客户端即将废弃该接口。
|
*
|
* @compat WeChat
|
*/
|
export declare function onMenuShareQZone(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享描述
|
*/
|
desc?: string;
|
/**
|
* 分享链接
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
}>): void;
|
/**
|
* 自定义转发到会话。
|
*
|
* @compat WeCom >= 2.4.5
|
*
|
* @example
|
* ```ts
|
* ww.shareAppMessage({
|
* title: '企业微信',
|
* desc: '让每个企业都有自己的微信',
|
* link: 'https://work.weixin.qq.com/',
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
|
* })
|
* ```
|
*/
|
export declare function shareAppMessage(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title: string;
|
/**
|
* 分享描述
|
*/
|
desc: string;
|
/**
|
* 分享链接
|
*/
|
link: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl: string;
|
/**
|
* @compat WeCom >= 4.0.20
|
* 是否开启id转译, 1 为开启,0 为关闭,默认为0
|
* 仅供第三方应用使用
|
* 必须使用应用身份进行注册
|
*/
|
enableIdTrans?: number;
|
}>): Promise<CommonResult>;
|
/**
|
* 自定义转发到微信。
|
*
|
* @compat WeCom >= 2.4.5
|
*
|
* @example
|
* ```ts
|
* ww.shareWechatMessage({
|
* title: '企业微信',
|
* desc: '让每个企业都有自己的微信',
|
* link: 'https://work.weixin.qq.com/',
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
|
* })
|
* ```
|
*/
|
export declare function shareWechatMessage(params: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title: string;
|
/**
|
* 分享描述
|
*/
|
desc: string;
|
/**
|
* 分享链接
|
*/
|
link: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl: string;
|
/**
|
* @compat WeCom >= 4.0.20
|
* 是否开启id转译, 1 为开启,0 为关闭,默认为0
|
* 仅供第三方应用使用
|
* 必须使用应用身份进行注册
|
*/
|
enableIdTrans?: number;
|
}>): Promise<CommonResult>;
|
/**
|
* 自定义「分享到朋友圈」及「分享到QQ空间」按钮的分享内容。
|
*
|
* @compat WeChat
|
*/
|
export declare function updateTimelineShareData(params?: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享链接
|
*
|
* 该链接的域名必须与企业某个应用的可信域名一致
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 自定义「分享给朋友」及「分享到QQ」按钮的分享内容。
|
*
|
* @compat WeChat
|
*/
|
export declare function updateAppMessageShareData(params?: APIParams<{
|
/**
|
* 分享标题
|
*/
|
title?: string;
|
/**
|
* 分享描述
|
*/
|
desc?: string;
|
/**
|
* 分享链接
|
*
|
* 该链接的域名必须与企业某个应用的可信域名一致
|
*/
|
link?: string;
|
/**
|
* 分享图标
|
*/
|
imgUrl?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 批量添加卡券。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#批量添加卡券接口
|
*/
|
export declare function addCard(params: APIParams<{
|
/**
|
* 需要添加的卡券列表
|
*/
|
cardList: Array<{
|
cardId: string;
|
cardExt: string;
|
}>;
|
}, {
|
/**
|
* 添加的卡券列表信息
|
*/
|
cardList: Array<{
|
cardId: string;
|
cardExt: string;
|
isSuccess: boolean;
|
}>;
|
}>): Promise<CommonResult & {
|
/**
|
* 添加的卡券列表信息
|
*/
|
cardList: Array<{
|
cardId: string;
|
cardExt: string;
|
isSuccess: boolean;
|
}>;
|
}>;
|
/**
|
* 拉取适用卡券列表并获取用户选择信息。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#拉取适用卡券列表并获取用户选择信息
|
*/
|
export declare function chooseCard(params: APIParams<{
|
/**
|
* 门店Id
|
*/
|
shopId: string;
|
/**
|
* 卡券类型
|
*/
|
cardType: string;
|
/**
|
* 卡券Id
|
*/
|
cardId: string;
|
/**
|
* 卡券签名时间戳
|
*/
|
timestamp: number | string;
|
/**
|
* 卡券签名随机串
|
*/
|
nonceStr: string;
|
/**
|
* 签名方式
|
*
|
* @default 'SHA1'
|
*/
|
signType: string;
|
/**
|
* 卡券签名
|
*/
|
cardSign: string;
|
}, {
|
cardList: Array<IAnyObject>;
|
}>): Promise<CommonResult & {
|
cardList: Array<IAnyObject>;
|
}>;
|
/**
|
* 查看微信卡包中的卡券。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#查看微信卡包中的卡券接口
|
*/
|
export declare function openCard(params: APIParams<{
|
/**
|
* 需要打开的卡券列表
|
*/
|
cardList: Array<{
|
cardId: string;
|
code: string;
|
}>;
|
}, IAnyObject>): Promise<CommonResult & IAnyObject>;
|
/**
|
* 核销并分享卡券。
|
*
|
* @deprecated
|
*/
|
export declare function consumeAndShareCard(params: APIParams<{
|
cardId: string;
|
code: string;
|
}, IAnyObject>): Promise<CommonResult & IAnyObject>;
|
export declare enum ProductViewType {
|
normal = 0,// 默认值,普通商品详情页
|
scan = 1
|
}
|
/**
|
* 跳转微信商品页。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#跳转微信商品页接口
|
*/
|
export declare function openProductSpecificView(params: APIParams<{
|
/**
|
* 商品id
|
*/
|
productId: string;
|
/**
|
* 商品页类型
|
*
|
* @default 0
|
*/
|
viewType?: ProductViewType;
|
/** */
|
extInfo?: any;
|
}, IAnyObject>): Promise<CommonResult & IAnyObject>;
|
export interface WxPayParams {
|
/**
|
* 支付签名时间戳
|
*
|
* 注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
|
*/
|
timestamp: number | string;
|
/**
|
* 支付签名随机串
|
*
|
* 不长于 32 位
|
*/
|
nonceStr: string;
|
/**
|
* 统一支付接口返回的 prepay_id 参数值
|
*
|
* 提交格式如:prepay_id=\*\*\*)
|
*/
|
package: string;
|
/**
|
* 签名方式
|
*
|
* 使用新版支付需传入'MD5'
|
*
|
* @default 'SHA1'
|
*/
|
signType: string;
|
/**
|
* 支付签名
|
*/
|
paySign: string;
|
}
|
/**
|
* 发起一个微信支付请求。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#发起一个微信支付请求
|
*/
|
export declare function chooseWXPay(params: APIParams<WxPayParams, IAnyObject>): Promise<CommonResult & IAnyObject>;
|
/**
|
* 领取企业红包。
|
*/
|
export declare function openEnterpriseRedPacket(params: APIParams<WxPayParams, IAnyObject>): Promise<CommonResult & IAnyObject>;
|
declare enum DiscoverDeviceType {
|
/**
|
* 识别传递的 qrcode_url
|
*
|
* 如果是正确的链接,则直接进入到设备详情
|
*/
|
qrcode = "qrcode",
|
/**
|
* 进入蓝牙发现的列表页,进行搜索识别
|
*/
|
bluetooth = "bluetooth",
|
/**
|
* 进入输入 sn 流程
|
*
|
* 若传入 sn,则直接进入设备详情
|
*/
|
input = "input",
|
/**
|
* 进入选择添加设备方式列表
|
*/
|
choose = "choose"
|
}
|
/**
|
* 添加设备。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 发起用户需要有设备添加权限(超级管理员/设备管理员)
|
*
|
* @compat WeCom iOS, Android >= 4.0.18
|
*
|
* @example
|
* ```ts
|
* ww.addDevice({
|
* type: 'qrcode',
|
* qrcode_url: 'https://open.work.weixin.qq.com/connect?xxx',
|
* })
|
* ```
|
*/
|
export declare function addDevice(params: APIParams<{
|
/**
|
* 设备发现方式
|
*/
|
type: DiscoverDeviceType;
|
/**
|
* 设备静态 / 动态二维码链接
|
*
|
* 当 type 为 qrcode 时必填
|
*/
|
qrcode_url?: string;
|
/**
|
* 设备 SN 码
|
*
|
* 当 type 为 sn 时选填
|
*/
|
sn?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 判断当前客户端版本是否支持指定 JS 接口。
|
*
|
* @example
|
* ```ts
|
* ww.checkJsApi({
|
* jsApiList: ['chooseImage']
|
* })
|
* ```
|
*/
|
export declare function checkJsApi(params: APIParams<{
|
/**
|
* JS 接口列表
|
*/
|
jsApiList: string[];
|
}, {
|
/**
|
* 检查结果
|
*
|
* 以键值对的形式返回,接口可用时为 true,不可用为 false
|
*/
|
checkResult: Record<string, boolean>;
|
}>): Promise<CommonResult & {
|
/**
|
* 检查结果
|
*
|
* 以键值对的形式返回,接口可用时为 true,不可用为 false
|
*/
|
checkResult: Record<string, boolean>;
|
}>;
|
/**
|
* 查看其他成员某段时间内日程中的闲忙状态。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 当前成员必须在应用可见范围内
|
* - 应用需具有日程使用权限
|
*
|
* @compat WeCom >= 4.0.20
|
*
|
* @example
|
* ```ts
|
* ww.checkSchedule({
|
* start_time: 1667232000,
|
* end_time: 1667318400,
|
* users: ['jack', 'jason']
|
* })
|
* ```
|
*/
|
export declare function checkSchedule(params: APIParams<{
|
/**
|
* 开始时间,unix 时间戳
|
*/
|
start_time: number;
|
/**
|
* 结束时间,unix 时间戳
|
*/
|
end_time: number;
|
/**
|
* 成员 userid 列表
|
*
|
* 第三方应用与代开发应用须传入 open_userid 列表,不填或列表为空则仅查看用户本人的日程闲忙状态
|
*/
|
users?: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 拉起电子发票列表。
|
*
|
* @compat WeCom iOS, Android >= 2.1.0
|
*
|
* @example
|
* ```ts
|
* ww.chooseInvoice({
|
* timestamp: timestamp,
|
* nonceStr: nonceStr,
|
* signType: signType,
|
* cardSign: cardSign
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | choose_invoice:ok | 执行成功 |
|
* | choose_invoice: fail | 选取发票失败 |
|
* | choose_invoice: cancel | 选取发票取消 |
|
*/
|
export declare function chooseInvoice(params: APIParams<{
|
/**
|
* 签名时间戳
|
*/
|
timestamp: number;
|
/**
|
* 签名随机串
|
*/
|
nonceStr: string;
|
/**
|
* 签名
|
*/
|
cardSign: string;
|
/**
|
* 签名类型
|
*
|
* @default 'SHA1'
|
*/
|
signType?: string;
|
}, {
|
/**
|
* 用户选中的发票列表
|
*/
|
choose_invoice_info: Array<{
|
card_id: string;
|
encrypt_code: string;
|
app_id: string;
|
}>;
|
}>): Promise<CommonResult & {
|
/**
|
* 用户选中的发票列表
|
*/
|
choose_invoice_info: Array<{
|
card_id: string;
|
encrypt_code: string;
|
app_id: string;
|
}>;
|
}>;
|
/**
|
* 跳转到认领班级的界面。
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @limit 本接口必须使用应用身份进行注册
|
*
|
* @example
|
* ```ts
|
* ww.claimClassAdmin()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | claimClassAdmin:ok | 执行成功 |
|
* | claimClassAdmin:fail no permission | 应用身份鉴权失败 |
|
* | claimClassAdmin:fail user not in allow list | 当前成员不在应用可见范围 |
|
*/
|
export declare function claimClassAdmin(params?: APIParams<IEmptyObject, {
|
/**
|
* 认领的班级部门 ID 列表
|
*/
|
departmentIds: string[];
|
}>): Promise<CommonResult & {
|
/**
|
* 认领的班级部门 ID 列表
|
*/
|
departmentIds: string[];
|
}>;
|
export interface TextMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "text";
|
text: {
|
/**
|
* 文本内容
|
*/
|
content: string;
|
};
|
}
|
export interface ImageMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "image";
|
image: {
|
/**
|
* 图片的素材 ID
|
*
|
* 可以通过[素材管理](#90253)接口获得,暂不支持公众平台的 mediaid
|
*/
|
mediaid?: string;
|
/**
|
* 图片的 url,跟图片素材 ID 填其中一个即可
|
*/
|
imgUrl?: string;
|
};
|
}
|
export interface LinkMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "link";
|
link: {
|
/**
|
* H5消息标题
|
*/
|
title?: string;
|
/**
|
* H5消息封面图片URL
|
*/
|
imgUrl?: string;
|
/**
|
* H5消息摘要
|
*/
|
desc?: string;
|
/**
|
* H5消息页面url
|
*/
|
url: string;
|
};
|
}
|
export interface MiniprogramMessage {
|
/**
|
* 消息类型
|
*
|
* @compat WeCom iOS, Android, PC >= 3.1.0; WeCom Mac >= 4.1.26
|
*/
|
msgtype: "miniprogram";
|
miniprogram: {
|
/**
|
* 小程序的appid
|
*/
|
appid: string;
|
/**
|
* 小程序消息的title
|
*/
|
title: string;
|
/**
|
* 小程序消息的封面图,必须带 http 或 https 协议头
|
*/
|
imgUrl: string;
|
/**
|
* 小程序消息打开后的路径,注意要以 `.html` 作为后缀
|
*/
|
page: string;
|
};
|
}
|
export interface VideoMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "video";
|
video: {
|
/**
|
* 视频的素材 ID
|
*
|
* 可以通过[素材管理](#90253)接口获得,暂不支持公众平台的 mediaid
|
*/
|
mediaid: string;
|
};
|
}
|
export interface FileMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "file";
|
file: {
|
/**
|
* 文件素材 ID
|
*
|
* 可以通过[素材管理](#90253)接口获得,暂不支持公众平台的 mediaid
|
*/
|
mediaid: string;
|
};
|
}
|
export interface NewsMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "news";
|
news: {
|
/**
|
* 页面 URL
|
*/
|
link: string;
|
/**
|
* 卡片标题
|
*/
|
title: string;
|
/**
|
* 卡片摘要
|
*/
|
desc: string;
|
/**
|
* 封面图片URL
|
*/
|
imgUrl: string;
|
};
|
}
|
export interface MenuMessage {
|
/**
|
* 消息类型
|
*
|
* @compat WeCom iOS, Android >= 3.1.12; WeCom PC >= 3.1.20
|
*
|
* @limit
|
* 仅支持从客服工具栏进入的页面调用, 即`entry`值必须为`single_kf_tools`
|
*/
|
msgtype: "msgmenu";
|
msgmenu: {
|
/**
|
* 起始文本
|
*/
|
head_content: string;
|
/**
|
* 菜单项配置列表
|
*/
|
list: MenuMessageItem[];
|
};
|
}
|
export interface ShopMessage {
|
/**
|
* 消息类型
|
*
|
* @compat WeCom >= 4.1.6
|
*
|
* @limit
|
* 仅支持从客服工具栏进入的页面调用, 即`entry`值必须为`single_kf_tools`
|
*
|
*/
|
msgtype: "channels_shop_product";
|
/**
|
* 商品及店铺信息
|
* 参数可通过[获取商品接口](https://developers.weixin.qq.com/doc/channels/API/product/get)和[获取店铺基本信息接口](https://developers.weixin.qq.com/doc/channels/API/basics/getbasicinfo)获取
|
*/
|
channelsShopProduct: {
|
/**
|
* 商品ID
|
*/
|
productId: string;
|
/**
|
* 小店ID
|
*/
|
shopAppId: string;
|
/**
|
* 商品图像
|
*/
|
imgUrl: string;
|
/**
|
* 商品名
|
*/
|
title: string;
|
/**
|
* 价格区间最小值(单位分) (销售价)
|
*/
|
sellingPrice: string;
|
/**
|
* 视频号店铺头像URL
|
*/
|
shopImgUrl: string;
|
/**
|
* 视频号店铺名称
|
*/
|
shopNickname: string;
|
};
|
}
|
export type MenuMessageItem = ClickMenuItem | ViewMenuItem | MiniprogramMenuItem;
|
export interface ClickMenuItem {
|
/**
|
* 菜单类型
|
*/
|
type: "click";
|
click: {
|
/**
|
* 菜单 ID
|
*/
|
id: string;
|
/**
|
* 菜单显示内容
|
*/
|
content: string;
|
};
|
}
|
export interface ViewMenuItem {
|
/**
|
* 菜单类型
|
*/
|
type: "view";
|
view: {
|
/**
|
* 点击后跳转的链接
|
*/
|
url: string;
|
/**
|
* 菜单显示内容
|
*/
|
content: string;
|
};
|
}
|
export interface MiniprogramMenuItem {
|
/**
|
* 菜单类型
|
*/
|
type: "miniprogram";
|
miniprogram: {
|
/**
|
* 小程序的 appid
|
*/
|
appid: string;
|
/**
|
* 小程序消息打开后的路径
|
*/
|
page: string;
|
/**
|
* 小程序消息的 title
|
*/
|
content: string;
|
};
|
}
|
/**
|
* 向用户申请给指定范围发送消息。
|
*
|
* 调用接口后,用户可在选人界面对群聊范围进行修改,当创建群聊成功时会返回新建的群聊 ID。
|
*
|
* @limit
|
* - 仅第三方应用(非通讯录应用)与代开发应用可调用
|
* - 本接口必须使用应用身份进行注册
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @example
|
* ```ts
|
* ww.createChatWithMsg({
|
* selectedOpenUserIds: ['zhangsan','lisi'],
|
* selectedTickets: ['tick1','token2'],
|
* chatName: 'discussName',
|
* msg: {
|
* msgtype: 'link',
|
* link: {
|
* title: 'title1',
|
* desc: 'desc1',
|
* url: 'link1',
|
* imgUrl: 'imgurl1'
|
* }
|
* }
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | createChatWithMsg:ok | 执行成功 |
|
* | createChatWithMsg:fail_unsupported_msgtype | msgtype不合法 |
|
* | createChatWithMsg:fail_msg_link_missing_url | msg.link.url未传入 |
|
*/
|
export declare function createChatWithMsg(params: APIParams<{
|
/**
|
* 群聊指定的用户 OpenUserID 列表
|
*/
|
selectedOpenUserIds?: string;
|
/**
|
* 群聊指定的 selectedTicket 列表
|
*
|
* 可通过 selectPrivilegedContact 接口获取
|
*/
|
selectedTickets?: string[];
|
/**
|
* 新建群聊指定的群名
|
*/
|
chatName: string;
|
/**
|
* 发送的链接消息
|
*/
|
msg?: LinkMessage;
|
}, {
|
/**
|
* 新建群聊时返回对应的群聊 ID
|
*
|
* 当发送的范围只有 1 人时,不会新建群聊,此时不返回 chatId
|
*/
|
chatId?: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 新建群聊时返回对应的群聊 ID
|
*
|
* 当发送的范围只有 1 人时,不会新建群聊,此时不返回 chatId
|
*/
|
chatId?: string;
|
}>;
|
/**
|
* 创建企业互联/上下游会话。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 企业必须开启互联群功能
|
* - 仅局校互联和上下游企业可调用
|
* - 当前成员必须在应用的可见范围
|
* - 群成员人数不能超过 2000 人
|
* - 如果创建的会话有外部联系人,群成员人数不能超过 40 人
|
* - 当前成员为下游企业成员时,需要打开上下游空间中的“允许外部单位之间互相查看”配置,群成员中才可以包含其他下游企业成员
|
*
|
* @compat WeCom iOS, Android, PC >= 3.1.8
|
*
|
* @example
|
* ```ts
|
* ww.createCorpGroupChat({
|
* groupName: '讨论组',
|
* userIds: ['lisi', 'lisi2'],
|
* openUserIds: ['wabc3', 'wbcde'],
|
* externalUserIds: ['exid1', 'exid2'],
|
* corpGroupUserIds: [
|
* {
|
* corpId: 'ww3333',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* },
|
* {
|
* corpId: 'ww4444',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* }
|
* ]
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | createCorpGroupChat:ok | 执行成功 |
|
* | createCorpGroupChat:fail no permission | 应用签名校验失败 |
|
* | createCorpGroupChat:fail exceed user id list size | 超过人数上限 |
|
* | createCorpGroupChat:fail invalid parameter | 参数不合法 |
|
* | createCorpGroupChat:fail need open corp group chat | 企业未开启企业互联群功能 |
|
* | createCorpGroupChat:fail exceed external user id list size | 超过包含外部联系人群人数上限 |
|
*/
|
export declare function createCorpGroupChat(params: APIParams<{
|
/**
|
* 会话名称
|
*
|
* 创建单聊时可以忽略
|
*/
|
groupName?: string;
|
/**
|
* 参与会话的企业成员列表
|
*
|
* @limit
|
* 仅自建应用使用
|
*/
|
userIds?: string[];
|
/**
|
* 参与会话的企业成员列表
|
*
|
* @limit
|
* 仅第三方应用使用
|
*/
|
openUserIds?: string[];
|
/**
|
* 参与会话的外部联系人列表
|
*
|
* @limit
|
* 与发起人需要有好友关系
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
externalUserIds?: string[];
|
/**
|
* 参与会话的互联企业成员列表
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
corpGroupUserIds?: Array<{
|
/**
|
* 企业Corp ID
|
*/
|
corpId: string;
|
/**
|
* 成员 ID
|
*
|
* @limit
|
* 仅自建应用使用
|
*/
|
userId?: string;
|
/**
|
* 成员OpenUser ID
|
*
|
* @limit
|
* 仅第三方应用使用
|
*/
|
openUserId?: string;
|
}>;
|
}, {
|
/**
|
* 创建的群聊 ID
|
*/
|
chatId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 创建的群聊 ID
|
*/
|
chatId: string;
|
}>;
|
export declare enum CreateExternalPaymentType {
|
/**
|
* 在聊天中收款
|
*/
|
chat = 0,
|
/**
|
* 收款码收款
|
*/
|
qrcode = 1
|
}
|
/**
|
* 发起对外收款。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 所使用的应用必须具有对外收款权限
|
* - 发起的用户必须在应用可见范围并实名
|
* - 允许第三方应用、代开发应用和自建应用调用
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```ts
|
* ww.createExternalPayment({
|
* paymentType: 0,
|
* totalFee: 300,
|
* description: '可乐一罐'
|
* })
|
* ```
|
*/
|
export declare function createExternalPayment(params?: APIParams<{
|
/**
|
* 收款方式
|
*
|
* 不填默认为在聊天中收款。
|
*/
|
paymentType?: CreateExternalPaymentType;
|
/**
|
* 收款金额
|
*
|
* 单位为分,允许范围 1~5,000,000 分
|
*/
|
totalFee?: number;
|
/**
|
* 收款说明
|
*
|
* “在聊天中收款” 不超过32个字,“收款码收款”不超过16个字。若为空或者超出最大长度,唤起收款页面时,客户端会忽略该字段,由用户填写。
|
*/
|
description?: string;
|
}, {
|
/**
|
* 收款项目 ID
|
*
|
* 可使用该 ID 获取[收款项目的商户单号](#39973)
|
*/
|
paymentId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 收款项目 ID
|
*
|
* 可使用该 ID 获取[收款项目的商户单号](#39973)
|
*/
|
paymentId: string;
|
}>;
|
/**
|
* 发起班级收款。
|
*
|
* 用于老师对学生家长发起付款请求,接口调用成功后会通过家校通知发送付款小程序给家长。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 所使用的应用必须具有对外收款权限
|
* - 仅支持配置在家长可使用范围内的应用
|
* - 企业必须已验证或者已认证
|
* - 发起的用户必须在应用可见范围并实名
|
* - 发起的用户需在个人微信零钱账户的可用范围内
|
*
|
* @compat WeCom iOS, Android, PC >= 3.1.10
|
*
|
* @note
|
* - 用户可以手动调整收款金额,收款项目和收款范围
|
* - 通过接口发起的收款,默认收款账户为“我的微信零钱账户”,且不可修改
|
* - 若用户未授权个人付款码权限,会唤起授权付款码权限页面,授权完成返回页面后会返回错误信息 `'require authorize the payment qr code'`。用户授权完成后可引导用户重新发起收款
|
*
|
* @example
|
* ```ts
|
* ww.createSchoolPayment({
|
* projectName: '1班班费',
|
* amount: 100,
|
* payers: {
|
* students: ['zhagnshan', 'lisi'],
|
* departments: [1, 2]
|
* }
|
* })
|
* ```
|
*/
|
export declare function createSchoolPayment(params: APIParams<{
|
/**
|
* 收款项目名称
|
*
|
* 最多 32 个字。若为空或者超出最大长度,唤起原生收款页面时,客户端会忽略该字段,由用户填写
|
*/
|
projectName?: string;
|
/**
|
* 收款金额
|
*
|
* 每个学生需付费的金额,单位为分,限额 100000,若非法客户端会忽略该字段
|
*/
|
amount?: number;
|
/**
|
* 收款范围
|
*
|
* 传入的收款范围若不在老师管理的范围,客户端会过滤掉不展示范围外的数据
|
*
|
* @limit
|
* 收款范围内展开的学生个数不能超过 1000 人
|
*/
|
payers?: {
|
/**
|
* 需要收款的学生列表
|
*/
|
students: string[];
|
/**
|
* 需要收款的家校通讯录部门列表,支持班级、年级、校区
|
*/
|
departments: number[];
|
};
|
}, {
|
/**
|
* 收款项目 ID,可使用该 ID 调用[获取学生付款结果](#94470)接口
|
*/
|
paymentId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 收款项目 ID,可使用该 ID 调用[获取学生付款结果](#94470)接口
|
*/
|
paymentId: string;
|
}>;
|
/**
|
* 添加设备。
|
*
|
* @deprecated 请使用 addDevice 接口
|
*
|
* @limit
|
* 调用者必须为企业超级管理员
|
*
|
* @compat WeCom iOS, Android >= 2.5.8
|
*
|
* @example
|
* ```ts
|
* ww.discoverDevice({
|
* type: 'qrcode',
|
* qrcode_url: 'https://open.work.weixin.qq.com/connect?xxx'
|
* })
|
* ```
|
*/
|
export declare function discoverDevice(params: APIParams<{
|
/**
|
* 设备发现方式
|
*/
|
type: DiscoverDeviceType;
|
/**
|
* 设备静态 / 动态二维码链接
|
*
|
* 当 type 为 qrcode 时必填
|
*/
|
qrcode_url?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 加入视频会议。
|
*
|
* @limit
|
* 只能加入同企业硬件创建的视频会议。
|
*
|
* @compat WeCom >= 2.5.0
|
*
|
* @example
|
* ```ts
|
* ww.enterHWOpenTalk({
|
* code: code,
|
* ticket: ticket
|
* })
|
* ```
|
*/
|
export declare function enterHWOpenTalk(params: APIParams<{
|
/**
|
* 会议码,从对应的视频会议硬件上获取
|
*/
|
code: string;
|
/**
|
* 会议码票据,调用方可以根据会议码生成对应的会议码票据
|
*
|
* 此票据会在调用 `ww.queryCurrHWOpenTalk` 时返回,便于换回对应的会议码
|
*
|
* 调用方需要记录票据到会议码的映射关系
|
*/
|
ticket: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 跳转认证界面。
|
*
|
* @compat WeCom iOS, Android >= 2.8.7
|
*
|
* @example
|
* ```ts
|
* ww.enterpriseVerify()
|
* ```
|
*/
|
export declare function enterpriseVerify(params?: APIParams): Promise<CommonResult>;
|
export interface SelectedDataItem {
|
/**
|
* 表示选项的唯一识别 ID
|
*/
|
key: string;
|
/**
|
* 选项展示给用户的名字
|
*/
|
value: string;
|
}
|
/**
|
* 获取 saveApprovalSelectedItems 保存的审批选项。
|
*
|
* 当用户打开网页后,应该先调用一次该接口获取用户已经选择的数据作为初始数据。获取到初始数据后,应该恢复已经选择的选项。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 所签名的应用必须具有审批权限
|
*
|
* @note
|
* - 网页应该做好深色模式适配
|
* - 接口仅用于审批设置外部选项场景,请勿用作其他场景
|
*
|
* @compat WeCom >= 4.0.18
|
*
|
* @example
|
* ```ts
|
* ww.getApprovalSelectedItems({
|
* key: 'key'
|
* })
|
* ```
|
*/
|
export declare function getApprovalSelectedItems(params: APIParams<{
|
/**
|
* 从 URL 获取的 key
|
*/
|
key: string;
|
}, {
|
/**
|
* 选中的选项
|
*/
|
selectedData: SelectedDataItem[];
|
}>): Promise<CommonResult & {
|
/**
|
* 选中的选项
|
*/
|
selectedData: SelectedDataItem[];
|
}>;
|
export declare enum EntryType {
|
/**
|
* 从联系人详情进入
|
*/
|
contact_profile = "contact_profile",
|
/**
|
* 从单聊会话的工具栏进入
|
*/
|
single_chat_tools = "single_chat_tools",
|
/**
|
* 从群聊会话的工具栏进入
|
*/
|
group_chat_tools = "group_chat_tools",
|
/**
|
* 从会话的聊天附件栏进入
|
*
|
* @compat WeCom >= 3.1.6
|
*/
|
chat_attachment = "chat_attachment",
|
/**
|
* 从微信客服的工具栏进入
|
*
|
* @compat WeCom >= 3.1.10
|
*/
|
single_kf_tools = "single_kf_tools",
|
/**
|
* 上下游单聊会话的工具栏
|
*
|
* @compat WeCom >= 4.0.8
|
*/
|
chain_single_chat_tools = "chain_single_chat_tools",
|
/**
|
* 上下游群聊会话的工具栏
|
*
|
* @compat WeCom >= 4.0.8
|
*/
|
chain_group_chat_tools = "chain_group_chat_tools",
|
/**
|
* 从内部群群看板进入
|
*
|
* @compat WeCom >= 4.1.36
|
*/
|
internal_group_chat_board = "internal_group_chat_board",
|
/**
|
* 除以上场景之外进入,例如工作台,聊天会话等
|
*/
|
normal = "normal"
|
}
|
/**
|
* 获取当前页面打开场景。
|
*
|
* @note
|
* 调用该接口可以判断用户是从哪个入口打开页面,从而决定是否可以调用客户联系相关的接口。
|
*
|
* @compat WeCom >= 3.0.24
|
*
|
* @example
|
* ```ts
|
* ww.getContext()
|
* ```
|
*/
|
export declare function getContext(params?: APIParams<IEmptyObject, {
|
/**
|
* 进入页面的场景类型
|
*/
|
entry: EntryType;
|
/**
|
* 从设置了 `withShareTicket: true` 的消息进入时返回该字段,用于私密分享
|
*/
|
shareTicket?: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 进入页面的场景类型
|
*/
|
entry: EntryType;
|
/**
|
* 从设置了 `withShareTicket: true` 的消息进入时返回该字段,用于私密分享
|
*/
|
shareTicket?: string;
|
}>;
|
/**
|
* 页面在聊天工具栏中打开时,获取当前上下游互联群的群 ID.
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @limit
|
* - 仅支持上下游聊天工具栏中进入的页面调用,即 getContext 返回 `entry` 为 `chain_single_chat_tools` 或 `chain_group_chat_tools` 的场景
|
* - 本接口必须使用应用身份进行注册
|
* - 当前成员必须在应用的可见范围
|
*
|
* @example
|
* ```
|
* ww.getCurCorpGroupChat()
|
* ```
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | getCurCorpGroupChat:ok| 执行成功 |
|
* | getCurCorpGroupChat:no permission | 应用身份鉴权失败 |
|
* | getCurCorpGroupChat:without context of corpgroup contact | 当前页面入口不支持调用 |
|
*/
|
export declare function getCurCorpGroupChat(params?: APIParams<IEmptyObject, {
|
/**
|
* 当前互联群的群 ID
|
*/
|
chatId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 当前互联群的群 ID
|
*/
|
chatId: string;
|
}>;
|
/**
|
* 页面在上下游聊天工具栏中打开时,获取当前上下游联系人用户 ID。
|
*
|
* @compat WeCom >= 4.0.8
|
*
|
* @limit
|
* - 仅支持上下游聊天工具栏中进入的页面调用,即 getContext 返回 `entry` 为 `chain_single_chat_tools` 或 `chain_group_chat_tools` 的场景
|
* - 本接口必须使用应用身份进行注册
|
* - 当前成员必须在应用的可见范围
|
*
|
* @example
|
* ```
|
* ww.getCurCorpGroupContact()
|
* ```
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | getCurCorpGroupContact:ok| 执行成功 |
|
* | getCurCorpGroupContact:no permission | 应用身份鉴权失败 |
|
* | getCurCorpGroupContact:without context of corpgroup contact | 当前页面入口不支持调用 |
|
*/
|
export declare function getCurCorpGroupContact(params: APIParams<IEmptyObject, {
|
/**
|
* 当前联系人的企业 ID
|
*/
|
corpId: string;
|
/**
|
* 当前联系人用户 ID
|
*/
|
userId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 当前联系人的企业 ID
|
*/
|
corpId: string;
|
/**
|
* 当前联系人用户 ID
|
*/
|
userId: string;
|
}>;
|
/**
|
* 获取当前客户群的群 ID。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 从客户群或班级群的聊天工具栏进入页面时才可成功调用该接口
|
* - 不同的入口对应用及用户有相应的限制
|
* | 入口 | getContext 接口返回的 entry 值 | 自建应用 | 第三方应用 | 用户 | 兼容性 |
|
* | --- | --- | --- | --- | --- | --- |
|
* | 外部群聊工具栏 | group_chat_tools | 需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了[客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.17 |
|
* | 班级群的聊天工具栏 | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 3.0.36 |
|
* | 学生群的聊天工具栏 | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 4.0.8 |
|
*
|
* @compat WeCom >= 2.8.17
|
*
|
* @example
|
* ```ts
|
* ww.getCurExternalChat()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | getCurExternalChat:ok | 执行成功 |
|
* | getCurExternalChat:fail no permission | 应用签名校验失败,或签名所使用的应用不满足权限要求 |
|
* | getCurExternalChat:fail without context of external contact | 当前页面入口不支持调用 |
|
*/
|
export declare function getCurExternalChat(params?: APIParams<IEmptyObject, {
|
/**
|
* 当前客户群的群 ID
|
*/
|
chatId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 当前客户群的群 ID
|
*/
|
chatId: string;
|
}>;
|
/**
|
* 获取当前外部联系人 userId。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 不同的入口对应用及用户有相应的限制,目前支持的入口有联系人详情页、外部单聊工具栏
|
* | getContext 接口返回的 entry 值 | 自建应用 | 第三方应用 | 用户 | 支持的最低版本 |
|
* | --- | --- | --- | --- | --- |
|
* | contact_profile | [客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.5.8 |
|
* | single_chat_tools | [客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.10 |
|
* | single_kf_tools | 所有 | 需有“微信客服权限->获取基础信息”权限 | 所有 | 企业微信 3.1.10 |
|
*
|
* @compat WeCom >= 2.5.8
|
*
|
* @example
|
* ```ts
|
* ww.getCurExternalContact()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | getCurExternalContact:ok | 执行成功 |
|
* | getCurExternalContact:fail no permission | 应用签名校验失败或应用不满足权限条件 |
|
* | getCurExternalContact:fail without context of external contact | 当前页面入口不支持调用 |
|
*/
|
export declare function getCurExternalContact(params?: APIParams<IEmptyObject, {
|
/**
|
* 当前外部联系人的 userId
|
*/
|
userId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 当前外部联系人的 userId
|
*/
|
userId: string;
|
}>;
|
/**
|
* 获取私密消息信息。
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @limit
|
* 本接口必须使用应用身份进行注册
|
*
|
* @example
|
* ```ts
|
* ww.getShareInfo({
|
* shareTicket: 'xxx'
|
* })
|
* ```
|
*/
|
export declare function getShareInfo(params: APIParams<{
|
/**
|
* getContext 接口返回的 shareTicket
|
*/
|
shareTicket: string;
|
}, {
|
/**
|
* 转发信息的加密数据
|
*/
|
encryptedData: string;
|
/**
|
* 加密算法的初始向量
|
*/
|
iv: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 转发信息的加密数据
|
*/
|
encryptedData: string;
|
/**
|
* 加密算法的初始向量
|
*/
|
iv: string;
|
}>;
|
/**
|
* 页面在聊天附件栏中打开时,隐藏聊天附件栏的发送按钮。开发者可以通过[分享消息到当前会话](#sendChatMessage)接口灵活适配对页面或页面中具体内容的转发。
|
*
|
* @limit
|
* - 仅支持聊天附件栏进入的页面调用,即 getContext 返回 `entry` 为 `chat_attachment` 的场景
|
* - 本接口必须使用应用身份进行注册
|
*
|
* @compat WeCom >= 3.1.6
|
*
|
* @example
|
* ```
|
* ww.hideChatAttachmentMenu({
|
* menuList: ["sendMessage"]
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | hideChatAttachmentMenu:ok | 执行成功 |
|
* | hideChatAttachmentMenu:invalid menuList | menuList不合法 |
|
* | hideChatAttachmentMenu:without context of chat_attachment | 未在聊天附件栏打开场景下调用 |
|
*/
|
export declare function hideChatAttachmentMenu(params: APIParams<{
|
/**
|
* 要隐藏的菜单项
|
*
|
* 目前只有 'sendMessage'
|
*/
|
menuList: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 跳转到小程序。
|
*
|
* @note
|
* 打开小程序时如果需要关闭页面,需同步调用 closeWindow,不推荐用 setTimeout 延迟关闭。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 跳转的小程序必须属于页面所属的企业
|
* - 跳转的小程序必须已关联到工作台
|
* - 应用必须与要跳转的小程序应用同属于一个企业
|
* - 跳转的小程序必须已经关联到工作台
|
*
|
* @compat WeCom >= 3.0.36
|
*
|
* @example
|
* ```ts
|
* ww.launchMiniprogram({
|
* appid: 'wx062f7a5507909000',
|
* path: 'pages/home/index'
|
* })
|
* ```
|
*/
|
export declare function launchMiniprogram(params: APIParams<{
|
/**
|
* 跳转的小程序 appid
|
*/
|
appid: string;
|
/**
|
* 跳转的小程序内页面路径及参数
|
*/
|
path?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 在企业微信内快速跳转到添加客户的界面。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
|
* - 当前成员必须配置了客户联系功能
|
*
|
* @compat WeCom iOS, Android >= 3.0.36
|
*
|
* @example
|
* ```ts
|
* ww.navigateToAddCustomer()
|
* ```
|
*/
|
export declare function navigateToAddCustomer(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 进入微信客服消息界面。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有“微信客服->获取基础信息”权限
|
* - 当前企业须已开启「微信客服」应用
|
* - 当前成员须是指定客服账号的坐席
|
*
|
* @compat WeCom iOS, Android, PC >= 3.1.12
|
*
|
* @example
|
* ```ts
|
* ww.navigateToKfChat({
|
* openKfId: 'wkAJ2GCAAAZSfhHCt7IFSvLKtMPxyAAA',
|
* externalUserId: 'wmAJ2GCAAAZSfhHCt7IFSvLKtMPxyBBB'
|
* })
|
* ```
|
*/
|
export declare function navigateToKfChat(params: APIParams<{
|
/**
|
* 客服账号 ID
|
*/
|
openKfId: string;
|
/**
|
* 微信客户 ID
|
*
|
* 若没指定,则跳转到客服账号的消息列表界面
|
*
|
* @compat WeCom >= 3.1.18
|
*/
|
externalUserId?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 共享收货地址。
|
*
|
* @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#共享收货地址接口
|
*/
|
export declare function openAddress(params?: APIParams<IEmptyObject, {
|
/**
|
* 收货人姓名
|
*/
|
userName: string;
|
/**
|
* 邮编
|
*/
|
postalCode: string;
|
/**
|
* 国标收货地址第一级地址(省)
|
*/
|
provinceName: string;
|
/**
|
* 国标收货地址第二级地址(市)
|
*/
|
cityName: string;
|
/**
|
* 国标收货地址第三级地址(国家)
|
*/
|
countryName: string;
|
/**
|
* 详细收货地址信息
|
*/
|
detailInfo: string;
|
/**
|
* 收货地址国家码
|
*/
|
nationalCode: string;
|
/**
|
* 收货人手机号码
|
*/
|
telNumber: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 收货人姓名
|
*/
|
userName: string;
|
/**
|
* 邮编
|
*/
|
postalCode: string;
|
/**
|
* 国标收货地址第一级地址(省)
|
*/
|
provinceName: string;
|
/**
|
* 国标收货地址第二级地址(市)
|
*/
|
cityName: string;
|
/**
|
* 国标收货地址第三级地址(国家)
|
*/
|
countryName: string;
|
/**
|
* 详细收货地址信息
|
*/
|
detailInfo: string;
|
/**
|
* 收货地址国家码
|
*/
|
nationalCode: string;
|
/**
|
* 收货人手机号码
|
*/
|
telNumber: string;
|
}>;
|
/**
|
* 打开应用评价页面。
|
*
|
* 第三方应用可以使用该接口提供按钮,让用户快速打开应用评价页面。
|
*
|
* @compat WeCom iOS, Android, PC >= 4.0.2
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册,
|
* - 仅第三方应用可调用
|
* - 对成员授权的应用,当前用户在应用可见范围内,可以进行应用评价
|
* - 管理员授权的应用,当前用户在可见范围内,或者当前用户为超管或有应用管理权限的分管,可以进行应用评价
|
*
|
* @example
|
* ```
|
* ww.openAppComment()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | openAppComment:ok| 执行成功 |
|
* | openAppComment:fail:no permission | 调用人身份不符合 |
|
* | openAppComment:fail:unknown app | 应用信息获取失败 |
|
* | openAppComment:fail:unsupported app type | 应用类型不符合要求 |
|
* | openAppComment:fail | 其它错误 |
|
*/
|
export declare function openAppComment(params?: APIParams): Promise<CommonResult>;
|
/**
|
* 获取设备数据授权。
|
*
|
* 唤起设备选择列表,企业管理员选择设备后,应用可以通过云端接口获取到设备上报的数据。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有智慧硬件接口权限
|
* - 仅第三方应用使用
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```ts
|
* ww.openAppDeviceDataAuth()
|
* ```
|
*/
|
export declare function openAppDeviceDataAuth(params?: APIParams): Promise<CommonResult>;
|
export declare enum OpenAppManagePageType {
|
/**
|
* 应用权限详情页
|
*/
|
permission = "permission",
|
/**
|
* 数据与智能专区权限授权页
|
*
|
* 需要满足:
|
*
|
* - 企业访问者身份为超级管理员
|
* - 应用需要满足勾选了“数据与智能专区权限”(注:该权限目前灰度开放)
|
* - 应用类型为第三方应用/代开发应用(注:不支持上下游共享应用)
|
*/
|
datazone_permission = "datazone_permission"
|
}
|
/**
|
* 打开应用管理页面。
|
*
|
* 应用可以使用该接口提供按钮,让企业管理员快速打开应用的管理页面。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 当前用户需要是企业超级管理员,或具有应用管理权限
|
*
|
* @compat WeCom >= 4.0.2
|
*
|
* @example
|
* ```
|
* ww.openAppManage({
|
* page: "permission",
|
* suiteId: "wwabcdefghijk",
|
* })
|
* ```
|
*/
|
export declare function openAppManage(params?: APIParams<{
|
/**
|
* 指定跳转的页面地址,不指定时跳转至应用管理首页
|
*/
|
page?: OpenAppManagePageType;
|
/**
|
* 指定跳转的关联应用
|
*
|
* - 不指定时,表示为跳转到 agentConfig 注册应用的管理页
|
* - 指定时,表示为跳转的其他应用管理页,目前仅支持会话内容存档应用
|
*
|
* @limit
|
* 服务商应用调用时,指定的 suiteid 必须为同服务商的应用,应用与当前企业需要有授权关系,且当前用户必须是企业超级管理员。
|
*/
|
suiteId?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 进入应用购买页面。
|
*
|
* 第三方应用可以使用该接口提供按钮,让用户可快速进入应用购买流程。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 当前用户应在应用的可见范围内
|
* - 仅第三方应用可调用
|
*
|
* @compat WeCom >= 4.1.6
|
*
|
* @example
|
* ```
|
* ww.openAppPurchase()
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | openAppPurchase:ok | 执行成功 |
|
* | openAppPurchase:fail:no permission | 应用签名校验失败,或成员不在应用的可见范围内 |
|
* | openAppPurchase:fail | 其它错误 |
|
*/
|
export declare function openAppPurchase(params: APIParams<IEmptyObject>): Promise<CommonResult>;
|
export declare enum EnvVersion {
|
release = "release",// 正式版
|
trial = "trial",// 体验版
|
develop = "develop"
|
}
|
/**
|
* 商户小程序跳转微信支付分小程序。
|
*
|
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/payscore.php?chapter=29_3&index=3
|
*/
|
export declare function openBusinessView(params: APIParams<{
|
/**
|
* 固定配置:wxpayScoreEnable
|
*/
|
businessType: "wxpayScoreEnable";
|
/**
|
* 使用 querystring 方式传递参数
|
*
|
* 格式为 key=value&key2=value2,其中 value、value2 需要进行 url encode 处理
|
*/
|
queryString?: string;
|
/** */
|
envVersion?: string;
|
}, {
|
/** */
|
extraData?: IAnyObject;
|
}>): Promise<CommonResult & {
|
/** */
|
extraData?: IAnyObject;
|
}>;
|
/**
|
* 查看设备。
|
*
|
* @limit
|
* 调用者必须拥有指定 deviceSn 的管理权限。
|
*
|
* @note
|
* 若开发者需要在 web 端引导跳转设备管理,可以构造链接跳转:`https://work.weixin.qq.com/wework_admin/frame#hardware/device?sn={{DEVICESN}}`。
|
*
|
* @compat WeCom iOS, Android >= 2.8.2
|
*
|
* @example
|
* ```ts
|
* ww.openDeviceProfile({
|
* deviceSn: 'QYWX001'
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | openDeviceProfile:ok | 执行成功 |
|
* | openDeviceProfile:fail_device_permission_denied | 管理员无设备管理权限 |
|
* | openDeviceProfile:fail_device_not_found | 不存在此设备 |
|
*/
|
export declare function openDeviceProfile(params: APIParams<{
|
/**
|
* 已绑定的设备SN
|
*/
|
deviceSn: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 打开会话。
|
*
|
* @limit
|
* - 内部群最多 2000 人,外部群最多 500 人
|
* - 若创建的会话包含微信联系人,群成员人数不能超过 40 人
|
* - 第三方应用与代开发应用必须使用应用身份进行注册
|
*
|
* @compat WeCom >= 2.0.0
|
*
|
* @example
|
* ```ts
|
* ww.openEnterpriseChat({
|
* groupName: '讨论组',
|
* userIds: [
|
* 'zhangsan',
|
* 'lisi'
|
* ],
|
* externalUserIds: [
|
* 'wmEAlECwAAHrbWYDOK5u3Bf13xlYDAAA',
|
* 'wmEAlECwAAHibWYDOK5u3Af13xlYDAAA'
|
* ]
|
* })
|
* ```
|
*/
|
export declare function openEnterpriseChat(params?: APIParams<{
|
/**
|
* 会话名称,创建单聊时可以忽略
|
*/
|
groupName?: string;
|
/**
|
* 参与会话的企业成员列表
|
*/
|
userIds?: string | string[];
|
/**
|
* 参与会话的外部联系人列表
|
*
|
* 通过 selectExternalContact 接口获得
|
*
|
* @compat WeCom >= 2.4.20
|
*/
|
externalUserIds?: string | string[];
|
/**
|
* 打开已有会话的 chatId
|
*
|
* 目前仅支持打开客户群,若传入则忽略其他参数
|
*
|
* 使用该参数必须使用应用身份注册
|
*
|
* @compat WeCom >= 3.0.36
|
*/
|
chatId?: string;
|
}, {
|
/**
|
* 当前群聊 ID
|
*
|
* 使用应用身份注册的场景下返回
|
*
|
* @compat WeCom >= 3.0.36
|
*/
|
chatId: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 当前群聊 ID
|
*
|
* 使用应用身份注册的场景下返回
|
*
|
* @compat WeCom >= 3.0.36
|
*/
|
chatId: string;
|
}>;
|
/**
|
* 打开已有群聊并可选发送一条链接消息(link消息)。支持打开企业内部群、外部群、互联群。
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @limit
|
* 本接口必须使用应用身份进行注册
|
*
|
* @example
|
* ```ts
|
* ww.openExistedChatWithMsg({
|
* chatId: 'chatId123',
|
* msg: {
|
* msgtype: 'link',
|
* link: {
|
* title: 'title1',
|
* desc: 'desc1',
|
* url: 'link1',
|
* imgUrl: 'imgurl1'
|
* }
|
* }
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | openExistedChatWithMsg:ok | 执行成功 |
|
* | openExistedChatWithMsg:fail_unsupported_msgtype | msgtype不合法 |
|
* | openExistedChatWithMsg:fail_msg_link_missing_url | msg.link.url未传入 |
|
*/
|
export declare function openExistedChatWithMsg(params: APIParams<{
|
/**
|
* 打开的群聊 ID
|
*/
|
chatId: string;
|
/**
|
* 发送的链接消息。不传则表示仅进入群聊,不发消息
|
*
|
* @compat WeCom iOS, Android >= 3.1.8; WeCom PC, Mac >= 4.0.2
|
*/
|
msg?: LinkMessage;
|
}>): Promise<CommonResult>;
|
/**
|
* 进入应用客服会话。
|
*
|
* 第三方应用可以使用该接口提供按钮,让用户快速打开应用客服的会话。。
|
*
|
* @compat WeCom iOS, Android >= 3.1.18; WeCom PC, Mac >= 4.1.6
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 仅第三方应用可调用
|
* - 第三方应用需要提前配置客服
|
* - 当前用户需要有添加外部联系人权限
|
*
|
* @example
|
* ```
|
* ww.openThirdAppServiceChat()
|
* ```
|
*/
|
export declare function openThirdAppServiceChat(params?: APIParams): Promise<CommonResult>;
|
export declare enum OpenUserProfileType {
|
/**
|
* 企业成员
|
*/
|
internal = 1,
|
/**
|
* 外部联系人
|
*/
|
external = 2
|
}
|
/**
|
* 唤起成员或外部联系人的个人信息页面。
|
*
|
* @compat WeCom >= 2.4.20
|
*
|
* @limit
|
* - 第三方应用调用时,需使用应用身份进行注册
|
*
|
* @example
|
* ```ts
|
* ww.openUserProfile({
|
* type: 1,
|
* userid: 'wmEAlECwAAHrbWYDetiu3Af13xlYDAAA'
|
* })
|
* ```
|
*/
|
export declare function openUserProfile(params: APIParams<{
|
/**
|
* 用户类型
|
*/
|
type: OpenUserProfileType;
|
/**
|
* 企业成员或外部联系人的用户 ID
|
*/
|
userid: string;
|
}>): Promise<CommonResult>;
|
export declare enum PrintFileIdType {
|
/**
|
* mediaid
|
*/
|
mediaid = 1,
|
/**
|
* url
|
*/
|
url = 2,
|
/**
|
* localId
|
*
|
* 可通过以下方式获得:
|
* 1. [从会话选择文件](#34301)
|
* 2. [拍照或从手机相册中选图接口](#14915)
|
*/
|
localId = 4
|
}
|
/**
|
* 发起文件打印。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有“设备信息-打印扫描设备-发起文件打印权限”授权
|
* - 当前触发调用人员身份需要在应用的可见范围内
|
* - 当前企业有安装企业微信打印设备
|
* - 仅第三方应用使用
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```ts
|
* ww.printFile({
|
* fileId: 'fileId',
|
* fileIdType: 1,
|
* fileName: 'fileName.jpg'
|
* })
|
* ```
|
*/
|
export declare function printFile(params: APIParams<{
|
/**
|
* 文件 ID
|
*
|
* 可以是 media_id、文件下载 url 或本地文件路径
|
*/
|
fileId: string;
|
/**
|
* 文件 ID 类型
|
*/
|
fileIdType: PrintFileIdType;
|
/**
|
* 文件名
|
*
|
* 仅当 fileIdType 为 mediaid 或 url 时需要传入
|
*/
|
fileName?: string;
|
}, {
|
/**
|
* 调用结果
|
*/
|
result: {
|
/**
|
* 打印任务 ID
|
*/
|
jobId: string;
|
};
|
}>): Promise<CommonResult & {
|
/**
|
* 调用结果
|
*/
|
result: {
|
/**
|
* 打印任务 ID
|
*/
|
jobId: string;
|
};
|
}>;
|
export declare enum InTalkType {
|
/**
|
* 当前不在任何通话中
|
*/
|
None = "None",
|
/**
|
* 视频会议中
|
*/
|
HWOpenTalk = "HWOpenTalk",
|
/**
|
* voip通话中
|
*/
|
VoIP = "VoIP",
|
/**
|
* 系统通话中
|
*/
|
SystemCall = "SystemCall"
|
}
|
/**
|
* 查询当前是否在视频会议。
|
*
|
* @compat WeCom >= 2.5.0
|
*
|
* @example
|
* ```ts
|
* ww.queryCurrHWOpenTalk()
|
* ```
|
*/
|
export declare function queryCurrHWOpenTalk(params?: APIParams<IEmptyObject, {
|
/**
|
* 当前通话的类型
|
*/
|
inTalkType: InTalkType;
|
/**
|
* 如果当前通话类型为视频会议,会将当前会议码票据(enterHWOpenTalk 中携带的 ticket)回传
|
*/
|
ticket: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 当前通话的类型
|
*/
|
inTalkType: InTalkType;
|
/**
|
* 如果当前通话类型为视频会议,会将当前会议码票据(enterHWOpenTalk 中携带的 ticket)回传
|
*/
|
ticket: string;
|
}>;
|
/**
|
* 发起退款。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有对外收款权限
|
* - 发起的用户必须在应用可见范围并实名
|
* - 只允许退款由应用本身发起的收款
|
*
|
* @compat WeCom >= 4.0.12
|
*
|
* @example
|
* ```ts
|
* ww.refundExternalPayment({
|
* paymentId: 'xxxx',
|
* outTradeNo: 'yyyy',
|
* refundFee: 100,
|
* refundComment: '7天无理由退货'
|
* })
|
* ```
|
*/
|
export declare function refundExternalPayment(params: APIParams<{
|
/**
|
* 收款项目 ID,在[发起对外收款](#39955)中返回
|
*/
|
paymentId: string;
|
/**
|
* 收款单号,每笔支付对应一个商户单号
|
*/
|
outTradeNo: string;
|
/**
|
* 退款金额
|
*
|
* 单位为分,要求低于该次付款的金额,要求低于该次付款的金额。若为空,将退回该次付款的全额
|
*/
|
refundFee?: number;
|
/**
|
* 退款说明,不超过32个字,可为空。若为空或者超出最大长度,唤起退款页面时,客户端会忽略该字段,由用户填写
|
*/
|
refundComment?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 保存用户选择的审批选项。
|
*
|
* 用户在网页中修改审批选项时,调用该接口保存用户的选择。
|
*
|
* @note
|
* - 接口仅用于审批设置外部选项场景,请勿用作其他场景
|
* - 网页应该做好深色模式适配
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有审批权限
|
*
|
* @compat WeCom >= 4.0.18
|
*
|
* @example
|
* ```ts
|
* ww.saveApprovalSelectedItems({
|
* key: 'key',
|
* selectedData: [
|
* {
|
* key: 'item-1',
|
* value: '选项1'
|
* },
|
* {
|
* key: 'item-2',
|
* value: '选项2'
|
* }
|
* ]
|
* })
|
* ```
|
*/
|
export declare function saveApprovalSelectedItems(params: APIParams<{
|
/**
|
* 从 URL 中获取到的 key
|
*/
|
key: string;
|
/**
|
* 选中的选项
|
*/
|
selectedData: SelectedDataItem[];
|
}>): Promise<CommonResult>;
|
export declare enum ScanQRCodeType {
|
/**
|
* 扫描二维码
|
*/
|
qrCode = "qrCode",
|
/**
|
* 扫描条形码
|
*/
|
barCode = "barCode"
|
}
|
/**
|
* 调起企业微信扫一扫。
|
*
|
* @example
|
* ```ts
|
* ww.scanQRCode({
|
* needResult: true,
|
* scanType: ['qrCode']
|
* })
|
* ```
|
*/
|
export declare function scanQRCode(params?: APIParams<{
|
/**
|
* 扫描结果是否由企业微信处理
|
*
|
* 为 false 时直接返回扫描结果
|
*
|
* @default false
|
*/
|
needResult?: boolean;
|
/**
|
* 扫码类型
|
*/
|
scanType?: ScanQRCodeType[];
|
}, {
|
/**
|
* 扫码结果,needResult为true时返回
|
*/
|
resultStr?: string;
|
}>): Promise<CommonResult & {
|
/**
|
* 扫码结果,needResult为true时返回
|
*/
|
resultStr?: string;
|
}>;
|
export declare enum InputCorpGroupContactMode {
|
/**
|
* 单选
|
*/
|
single = "single",
|
/**
|
* 多选
|
*/
|
multi = "multi"
|
}
|
export declare enum InputCorpGroupContactType {
|
/**
|
* 选择部门
|
*/
|
department = "department",
|
/**
|
* 选择成员
|
*/
|
user = "user"
|
}
|
export interface InputExternalDepartment {
|
/**
|
* Corp ID
|
*/
|
corpId: string;
|
/**
|
* 部门 ID
|
*/
|
departmentId: string;
|
}
|
export interface InputExternalUser {
|
/**
|
* Corp ID
|
*/
|
corpId: string;
|
/**
|
* 成员 ID
|
*/
|
userId?: string;
|
/**
|
* 成员 OpenUserID
|
*/
|
openUserId?: string;
|
}
|
export interface OutputDepartment {
|
/**
|
* 部门 ID
|
*/
|
id: string;
|
}
|
export interface OutputUser {
|
/**
|
* 成员 ID,仅自建应用返回
|
*/
|
id?: string;
|
/**
|
* 成员 OpenUserID,仅第三方应用返回
|
*/
|
openUserId?: string;
|
}
|
export interface OutputExternalDepartment {
|
/**
|
* Corp ID
|
*/
|
corpId: string;
|
/**
|
* 部门 ID
|
*/
|
id: string;
|
}
|
export interface OutputExternalUser {
|
/**
|
* Corp ID
|
*/
|
corpId: string;
|
/**
|
* 成员 ID,仅自建应用返回
|
*/
|
id?: string;
|
/**
|
* 成员 OpenUserID,仅第三方应用返回
|
*/
|
openUserId?: string;
|
}
|
/**
|
* 企业互联/上下游选人
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 该接口仅可选择应用可见范围内的成员和部门
|
*
|
* @compat WeCom iOS, Android, PC >= 3.1.6
|
*
|
* @note
|
* 自建应用调用该接口时userid返回的是企业内部的userid,对于服务商该字段返回的是open_userid,同一个服务商,不同应用获取到企业内同一个成员的open_userid是相同的,最多64个字节
|
*
|
* @example
|
* ```ts
|
* ww.selectCorpGroupContact({
|
* fromDepartmentId: -1,
|
* mode: 'single',
|
* type: ['department', 'user'],
|
* selectedDepartmentIds: ['2','3'],
|
* selectedUserIds: ['lisi','lisi2'],
|
* selectedOpenUserIds: ['wabc3','wbcde'],
|
* selectedChainDepartmentIds: [
|
* {
|
* corpId: 'ww3333',
|
* departmentId: '2'
|
* },
|
* {
|
* corpId: 'ww4444',
|
* departmentId: '3'
|
* }
|
* ],
|
* selectedChainUserIds: [
|
* {
|
* corpId: 'ww3333',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* },
|
* {
|
* corpId: 'ww4444',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* }
|
* ],
|
* selectedCorpGroupDepartmentIds: [
|
* {
|
* corpId: 'ww3333',
|
* departmentId: '2'
|
* },
|
* {
|
* corpId: 'ww4444',
|
* departmentId: '3'
|
* }
|
* ],
|
* selectedCorpGroupUserIds: [
|
* {
|
* corpId: 'ww3333',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* },
|
* {
|
* corpId: 'ww4444',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* }
|
* ]
|
* })
|
* ```
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | selectCorpGroupContact:ok | 执行成功 |
|
* | selectCorpGroupContact:fail no permission | 应用身份鉴权失败 |
|
*
|
*/
|
export declare function selectCorpGroupContact(params: APIParams<{
|
/**
|
* 从指定的部门开始展示
|
*
|
* - -1 表示从自己所在部门开始
|
* - 0 表示从最上层开始
|
*
|
* 移动端,当需要展开的部门不在应用可见范围内,则从应用的可见范围开始展开
|
*/
|
fromDepartmentId: number;
|
/**
|
* 选择模式
|
*/
|
mode: InputCorpGroupContactMode;
|
/**
|
* 选择限制类型,指定一个或者多个
|
*/
|
type: InputCorpGroupContactType[];
|
/**
|
* 已选部门 ID 列表,用于多次选人时可重入
|
*/
|
selectedDepartmentIds?: string[];
|
/**
|
* 已选用户 ID 列表,用于多次选人时可重入
|
* 仅自建应用使用,第三方应用会忽略该字段
|
*/
|
selectedUserIds?: string[];
|
/**
|
* 已选用户 OpenUserID 列表,用于多次选人时可重入
|
* 仅第三方应用使用,自建应用会忽略该字段
|
*/
|
selectedOpenUserIds?: string[];
|
/**
|
* 已选上下游部门列表,用于多次选人时可重入
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
selectedChainDepartmentIds?: InputExternalDepartment[];
|
/**
|
* 已选上下游用户列表,用于多次选人时可重入
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
selectedChainUserIds?: InputExternalUser[];
|
/**
|
* 已选企业互联部门列表,用于多次选人时可重入
|
*/
|
selectedCorpGroupDepartmentIds?: InputExternalDepartment[];
|
/**
|
* 已选企业互联用户列表
|
*/
|
selectedCorpGroupUserIds?: InputExternalUser[];
|
}, {
|
result: {
|
/**
|
* 已选的部门列表
|
*/
|
departmentList: OutputDepartment[];
|
/**
|
* 已选的成员列表
|
*/
|
userList: OutputUser[];
|
/**
|
* 已选企业互联部门列表
|
*/
|
corpGroupDepartmentList: OutputExternalDepartment[];
|
/**
|
* 已选企业互联用户列表
|
*/
|
corpGroupUserList: OutputExternalUser[];
|
/**
|
* 已选上下游部门列表
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
chainDepartmentList: OutputExternalDepartment[];
|
/**
|
* 已选上下游用户列表
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
chainUserList: OutputExternalUser[];
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 已选的部门列表
|
*/
|
departmentList: OutputDepartment[];
|
/**
|
* 已选的成员列表
|
*/
|
userList: OutputUser[];
|
/**
|
* 已选企业互联部门列表
|
*/
|
corpGroupDepartmentList: OutputExternalDepartment[];
|
/**
|
* 已选企业互联用户列表
|
*/
|
corpGroupUserList: OutputExternalUser[];
|
/**
|
* 已选上下游部门列表
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
chainDepartmentList: OutputExternalDepartment[];
|
/**
|
* 已选上下游用户列表
|
*
|
* @compat WeCom >= 3.1.20
|
*/
|
chainUserList: OutputExternalUser[];
|
};
|
}>;
|
export declare enum SelectEnterpriseContactMode {
|
/**
|
* 单选
|
*/
|
single = "single",
|
/**
|
* 多选
|
*/
|
multi = "multi"
|
}
|
export declare enum SelectEnterpriseContactType {
|
/**
|
* 选择部门
|
*/
|
department = "department",
|
/**
|
* 选择成员
|
*/
|
user = "user"
|
}
|
/**
|
* 选择通讯录成员。
|
*
|
* @compat WeCom >= 1.3.11; WeChat iOS, Android >= 6.5.10
|
*
|
* @example
|
* ```ts
|
* ww.selectEnterpriseContact({
|
* fromDepartmentId: -1,
|
* mode: 'multi',
|
* type: ['department', 'user'],
|
* selectedDepartmentIds: ['2', '3'],
|
* selectedUserIds: ['lisi', 'lisi2']
|
* })
|
* ```
|
*/
|
export declare function selectEnterpriseContact(params: APIParams<{
|
/**
|
* 从指定的部门开始展示
|
*
|
* - -1 表示从自己所在部门开始
|
* - 0 表示从最上层开始
|
*/
|
fromDepartmentId: number;
|
/**
|
* 选择模式
|
*/
|
mode: SelectEnterpriseContactMode;
|
/**
|
* 选择限制类型
|
*
|
* 指定 department、user 中的一个或者多个
|
*/
|
type: SelectEnterpriseContactType[];
|
/**
|
* 已选部门 ID 列表
|
*/
|
selectedDepartmentIds?: string[];
|
/**
|
* 已选用户 ID 列表
|
*/
|
selectedUserIds?: string[];
|
}, {
|
result: {
|
/**
|
* 已选的部门列表
|
*/
|
departmentList: Array<{
|
/**
|
* 部门 ID
|
*/
|
id: string;
|
/**
|
* 部门名称,从2019年12月30日起,对新创建第三方应用不再返回,2020年6月30日起,对所有历史第三方应用不再返回,第三方页面需要通过[通讯录展示组件](#17172)来展示名字。
|
*/
|
name: string;
|
}>;
|
/**
|
* 已选的成员列表
|
*/
|
userList: Array<{
|
/**
|
* 成员 ID
|
*/
|
id: string;
|
/**
|
* 成员名称,从2019年12月30日起,对新创建第三方应用不再返回,2020年6月30日起,对所有历史第三方应用不再返回,第三方页面需要通过[通讯录展示组件](#17172)来展示名字。
|
*/
|
name: string;
|
/**
|
* 成员头像,从2019年12月30日起,对新创建第三方应用不再返回,2020年6月30日起,对所有历史第三方应用不再返回,第三方页面需要通过[通讯录展示组件](#17172)来展示名字。
|
*/
|
avatar: string;
|
}>;
|
};
|
}>): Promise<CommonResult & {
|
result: {
|
/**
|
* 已选的部门列表
|
*/
|
departmentList: Array<{
|
/**
|
* 部门 ID
|
*/
|
id: string;
|
/**
|
* 部门名称,从2019年12月30日起,对新创建第三方应用不再返回,2020年6月30日起,对所有历史第三方应用不再返回,第三方页面需要通过[通讯录展示组件](#17172)来展示名字。
|
*/
|
name: string;
|
}>;
|
/**
|
* 已选的成员列表
|
*/
|
userList: Array<{
|
/**
|
* 成员 ID
|
*/
|
id: string;
|
/**
|
* 成员名称,从2019年12月30日起,对新创建第三方应用不再返回,2020年6月30日起,对所有历史第三方应用不再返回,第三方页面需要通过[通讯录展示组件](#17172)来展示名字。
|
*/
|
name: string;
|
/**
|
* 成员头像,从2019年12月30日起,对新创建第三方应用不再返回,2020年6月30日起,对所有历史第三方应用不再返回,第三方页面需要通过[通讯录展示组件](#17172)来展示名字。
|
*/
|
avatar: string;
|
}>;
|
};
|
}>;
|
export declare enum SelectExternalContactType {
|
/**
|
* 展示全部外部联系人列表
|
*/
|
all = 0,
|
/**
|
* 仅展示未曾选择过的外部联系人
|
*/
|
unselected = 1
|
}
|
/**
|
* 唤起该成员的外部联系人列表,并返回员工选择的外部联系人的 userId。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用须配置[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
|
* - 当前成员必须配置[客户联系功能](#13473/开始开发)
|
*
|
* @compat WeCom >= 2.4.20
|
*
|
* @example
|
* ```ts
|
* ww.selectExternalContact({
|
* filterType: 0
|
* })
|
* ```
|
*/
|
export declare function selectExternalContact(params?: APIParams<{
|
/**
|
* 展示列表类型
|
*
|
* @compat WeCom >= 2.4.22
|
*/
|
filterType?: SelectExternalContactType;
|
}, {
|
/**
|
* 外部联系人 userId 列表
|
*/
|
userIds: string[];
|
}>): Promise<CommonResult & {
|
/**
|
* 外部联系人 userId 列表
|
*/
|
userIds: string[];
|
}>;
|
export declare enum SelectPrivilegedContactMode {
|
/**
|
* 单选
|
*/
|
single = "single",
|
/**
|
* 多选
|
*/
|
multi = "multi"
|
}
|
/**
|
* 返回 ticket 的选人接口。
|
*
|
* 用于第三方应用唤起选择企业通讯录成员,用户选择的范围区分成两部分回传给第三方应用:
|
*
|
* 1. 过滤应用可见范围后的 openUserId 列表
|
* 2. 完整列表的 ticket,ticket 后续可用于[创建群聊](#30292) 或者[发送模板消息](#94515)
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 仅第三方应用(非通讯录应用)可调用
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @example
|
* ```ts
|
* ww.selectPrivilegedContact({
|
* fromDepartmentId: -1,
|
* mode: 'multi',
|
* selectedContextContact: 1
|
* selectedOpenUserIds: ['xxx', 'yyy'],
|
* selectedTickets: ['ticket1', 'ticket2']
|
* })
|
* ```
|
*/
|
export declare function selectPrivilegedContact(params: APIParams<{
|
/**
|
* 从指定的部门开始展示
|
*
|
* - -1 表示从自己所在部门开始
|
* - 0 表示从最上层开始
|
*/
|
fromDepartmentId: number;
|
/**
|
* 选择模式
|
*/
|
mode: SelectPrivilegedContactMode;
|
/**
|
* 是否勾选当前环境的参与者
|
*
|
* 例如在群「+」号打开,默认勾选当前群成员
|
*/
|
selectedContextContact: boolean;
|
/**
|
* 已选用户 OpenID 列表
|
*
|
* 仅在 mode 为 multi 时支持
|
*
|
* @compat WeCom >= 3.1.12
|
*/
|
selectedOpenUserIds?: string;
|
/**
|
* 已选Ticket列表
|
*
|
* 仅在 mode 为 multi 时支持
|
*
|
* @compat WeCom >= 3.1.12
|
*/
|
selectedTickets?: string[];
|
}, {
|
/**
|
* 当调用成功时返回,对应用户选择的内容
|
*/
|
result: {
|
/**
|
* 对应用户的选择集合凭证
|
*/
|
selectedTicket: string;
|
/**
|
* ticket 的有效时长
|
*
|
* 单位为秒,默认为 7 天
|
*/
|
expiresIn: number;
|
/**
|
* 选择的用户数
|
*/
|
selectedUserCount: string;
|
/**
|
* 选择的可见范围内的用户列表
|
*/
|
userList: Array<{
|
openUserId: string;
|
}>;
|
};
|
}>): Promise<CommonResult & {
|
/**
|
* 当调用成功时返回,对应用户选择的内容
|
*/
|
result: {
|
/**
|
* 对应用户的选择集合凭证
|
*/
|
selectedTicket: string;
|
/**
|
* ticket 的有效时长
|
*
|
* 单位为秒,默认为 7 天
|
*/
|
expiresIn: number;
|
/**
|
* 选择的用户数
|
*/
|
selectedUserCount: string;
|
/**
|
* 选择的可见范围内的用户列表
|
*/
|
userList: Array<{
|
openUserId: string;
|
}>;
|
};
|
}>;
|
export interface SendChatMessageCommonParams {
|
/**
|
* 发送完成后进入会话
|
*
|
* @compat WeCom >= 3.1.10
|
*/
|
enterChat?: boolean;
|
}
|
export interface SendChatMessageImageMessage {
|
/**
|
* 消息类型
|
*/
|
msgtype: "image";
|
image: {
|
/**
|
* 图片的素材 ID
|
*/
|
mediaid?: string;
|
};
|
}
|
export type SendChatMessage = TextMessage | SendChatMessageImageMessage | VideoMessage | FileMessage | NewsMessage | MiniprogramMessage | MenuMessage | ShopMessage;
|
/**
|
* 从聊天工具栏或附件栏打开的页面中向当前会话发送消息
|
*
|
* @note
|
* 消息格式支持文本(“text”),图片(“image”),视频(“video”),文件(“file”),H5(“news”),小程序(“miniprogram”),菜单消息(“msgmenu”)和视频号商品(“channels_shop_product”)
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 仅从特定入口进入页面才可调用,可通过 getContext 接口进行判断
|
* - 不同的入口对应用及用户有相应的限制
|
* | getContext 接口返回的 entry 值 | 自建应用 | 第三方应用 | 用户 | 支持的最低版本 |
|
* | --- | --- | --- | --- | --- |
|
* | single_chat_tools | 需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[配置了客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.10 |
|
* | group_chat_tools | 需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[配置了客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.10 |
|
* | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 3.0.36 |
|
* | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 4.0.8 |
|
* | chat_attachment | 所有 | 所有 | 所有 | 企业微信 3.1.6(mac 端暂不支持) |
|
* | single_kf_tools | 所有 | 需有“微信客服权限->获取基础信息”权限 | 所有 | 企业微信 3.1.10 |
|
* - 消息中的 mediaId 可通过[素材管理](#10112)接口获得,暂不支持公众平台的 mediaId
|
*
|
* @compat WeCom >= 2.8.10
|
*
|
* @example
|
* ```ts
|
* ww.sendChatMessage({
|
* msgtype: 'text',
|
* text: {
|
* content: '你好'
|
* }
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | sendChatMessage:ok | 执行成功 |
|
* | claimClassAdmin:fail without context of external contact | 当前页面打开的场景不支持调用 |
|
* | claimClassAdmin:fail no permission | 应用签名错误,或不满足权限要求 |
|
* | claimClassAdmin:fail invalid imgUrl | 小程序消息封面图不合法 |
|
*/
|
export declare function sendChatMessage(params: APIParams<SendChatMessageCommonParams & SendChatMessage>): Promise<CommonResult>;
|
/**
|
* 设置私密消息。
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @limit
|
* 本接口必须使用应用身份进行注册
|
*
|
* @example
|
* ```ts
|
* ww.setShareAttr({
|
* withShareTicket: true,
|
* state: 'STATE'
|
* })
|
* ```
|
*/
|
export declare function setShareAttr(params?: APIParams<{
|
/**
|
* 分享消息是否携带 share ticket
|
*/
|
withShareTicket?: boolean;
|
/**
|
* 详见 [私密消息](#94495/state的作用)
|
*/
|
state?: string;
|
}>): Promise<CommonResult>;
|
export type ShareToExternalAttachment = ImageMessage | LinkMessage | MiniprogramMessage | VideoMessage | FileMessage;
|
export interface ShareToExternalCompleteParams {
|
/**
|
* @compat WeCom >= 3.1.6
|
*/
|
text?: {
|
/**
|
* 文本内容
|
*
|
* @limit
|
* 最多支持 4000 字
|
*/
|
content: string;
|
};
|
/**
|
* @limit
|
* 最多传入 9 个
|
*
|
* @compat WeCom >= 3.1.6
|
*/
|
attachments?: ShareToExternalAttachment[];
|
}
|
export type ShareToExternalParams = ShareToExternalCompleteParams | NewsMessage["news"];
|
/**
|
* 具有客户联系权限的企业成员,可通过该接口将文本内容和附件传递到客户群群发、发送到客户群。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
|
* - 当前成员必须配置了[客户联系功能](#13473/配置可使用客户联系功能的成员)
|
*
|
* @note
|
* - 为防止滥用,同一个成员每日向一个客户最多可群发一条消息,每次群发最多可选 2000 个最近活跃的客户群
|
*
|
* @compat WeCom >= 2.8.7
|
*
|
* @example
|
* ```ts
|
* // WeCom >= 3.1.6
|
* ww.shareToExternalChat({
|
* chatIds: ["wr2GCAAAXAAAaWJHDDGasdadAAA","wr2GCAAAXBBBaWJHDDGasdadBBB"],
|
* text: {
|
* content: '企业微信'
|
* },
|
* attachments: [
|
* {
|
* msgtype: 'image',
|
* image: {
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png'
|
* }
|
* }
|
* ]
|
* })
|
* // 或者
|
* ww.shareToExternalChat({
|
* title: '', // 消息的标题
|
* desc: '', // 消息的描述
|
* link: '', // 消息链接
|
* imgUrl: '' // 消息封面
|
* })
|
* ```
|
*/
|
export declare function shareToExternalChat(params: APIParams<ShareToExternalParams & {
|
/**
|
* 客户群ID
|
* @compat WeCom iOS, Android, PC >= 4.1.10
|
*/
|
chatIds?: string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 具有客户联系权限的企业成员,可通过该接口将文本内容和附件传递到群发助手、发送给客户。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
|
* - 当前成员必须配置了[客户联系功能](#13473/配置可使用客户联系功能的成员)
|
*
|
* @note
|
* - 为防止滥用,同一个成员每日向一个客户最多可群发一条消息,每次群发最多可选 20000 个客户
|
*
|
*
|
* @compat WeCom >= 2.8.7
|
*
|
* @example
|
* ```ts
|
* // WeCom >= 3.1.6
|
* ww.shareToExternalContact({
|
* externalUserIds: ["wr2GCAAAXAAAaWJHDDGasdadAAA","wr2GCAAAXBBBaWJHDDGasdadBBB"],
|
* text: {
|
* content: '企业微信'
|
* },
|
* attachments: [
|
* {
|
* msgtype: 'image',
|
* image: {
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png'
|
* }
|
* }
|
* ]
|
* })
|
*
|
* // 或者
|
* ww.shareToExternalContact({
|
* title: '', // 消息的标题
|
* desc: '', // 消息的描述
|
* link: '', // 消息链接
|
* imgUrl: '' // 消息封面
|
* })
|
* ```
|
*/
|
export declare function shareToExternalContact(params: APIParams<ShareToExternalParams & {
|
/**
|
* 客户列表
|
* @compat WeCom iOS, Android, PC >= 4.1.10
|
*/
|
externalUserIds?: string[];
|
}>): Promise<CommonResult>;
|
export type ShareToExternalMomentsAttachment = ImageMessage | LinkMessage | VideoMessage;
|
/**
|
* 发表内容到客户朋友圈。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
|
* - 当前成员必须配置了客户联系功能
|
* - 当前成员必须在客户朋友圈使用范围
|
* - 当前成员必须具备外部沟通管理成员使用权限
|
*
|
* @compat WeCom iOS, Android >= 3.1.12
|
*
|
* @example
|
* ```ts
|
* ww.shareToExternalMoments({
|
* text: {
|
* content: '企业微信'
|
* },
|
* attachments: [
|
* {
|
* msgtype: 'image',
|
* image: {
|
* imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png'
|
* }
|
* }
|
* ]
|
* })
|
* ```
|
*/
|
export declare function shareToExternalMoments(params: APIParams<{
|
/**
|
* 文本消息
|
*/
|
text?: {
|
/**
|
* 消息文本内容
|
*
|
* @limit
|
* 最多支持 2000 字
|
*/
|
content?: string;
|
};
|
/**
|
* 附件
|
*
|
* @limit
|
* 最多支持 9 张图片、1 个视频或 1 个链接
|
*/
|
attachments?: Array<ShareToExternalMomentsAttachment>;
|
}>): Promise<CommonResult>;
|
/**
|
* 发起无线投屏。
|
*
|
* @compat WeCom
|
*
|
* @limit
|
* 仅支持第三方服务商接入。
|
* 需要配合硬件设备使用,硬件接入流程参考 [无线投屏](#14789)。
|
*
|
* @example
|
* ```ts
|
* ww.startWecast()
|
* ```
|
*/
|
export declare function startWecast(params?: APIParams): Promise<CommonResult>;
|
export declare enum OAType {
|
/**
|
* 发起审批
|
*/
|
create_approval = "10001",
|
/**
|
* 查看审批详情
|
*/
|
view_approval = "10002"
|
}
|
export declare enum OaExtDataType {
|
/**
|
* 链接
|
*/
|
link = "link",
|
/**
|
* 文本
|
*/
|
text = "text"
|
}
|
/**
|
* 在应用页面中发起审批流程。之后审批流程的每次状态变化都会通知开发者,开发者可按需进行拓展开发。具体参见[审批流程引擎](#14584)。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用必须具有审批权限
|
*
|
* @compat WeCom >= 2.5.0
|
*
|
* @example
|
* ```ts
|
* ww.thirdPartyOpenPage({
|
* oaType: '10001',
|
* templateId: '46af67a118a6ebf000002',
|
* thirdNo: 'thirdNo',
|
* extData: {
|
* fieldList: [
|
* {
|
* type: 'text',
|
* title: '采购类型',
|
* value: '市场活动'
|
* },
|
* {
|
* type: 'link',
|
* title: '订单链接',
|
* value: 'https://work.weixin.qq.com'
|
* }
|
* ]
|
* }
|
* })
|
* ```
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | 已存在相同的审批编号 | oaType为10001时,传入的thirdNo已经被其他审批单占用。 |
|
* | 审批申请不存在 | oaType为10002时,在历史记录中,传入的thirdNo对应的审批单不存在。 |
|
* | 审批模板ID不正确 | 调用接口时传入了错误的templateId |
|
* | 应用ID不正确 | 使用了错误的 agentId |
|
*/
|
export declare function thirdPartyOpenPage(params: APIParams<{
|
/**
|
* 操作类型
|
*/
|
oaType: OAType;
|
/**
|
* 发起审批的模板 ID
|
*
|
* 可在第三方应用-审批接口中创建模板获取
|
*/
|
templateId: string;
|
/**
|
* 审批单号
|
*
|
* 由开发者自行定义,不可重复
|
*/
|
thirdNo: string;
|
/**
|
* 详情数据,用于审批详情页信息展示
|
* 开发者可利用此特性,在发起审批时,传入需要申请人、审批人、抄送人看到的信息
|
* 若需用户填写数据,可在自行使用表单收集,并传入exData中,用于展示
|
*/
|
extData: {
|
fieldList: Array<{
|
/**
|
* 标题
|
*/
|
title?: string;
|
/**
|
* 字段类型
|
*
|
* link 类型仅在审批详情页展示
|
*/
|
type?: OaExtDataType;
|
/**
|
* 字段值
|
*/
|
value?: string;
|
}>;
|
};
|
}>): Promise<CommonResult>;
|
/**
|
* 变更企业互联/上下游群成员
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 当前成员必须在应用的可见范围
|
* - 仅支持往群里添加企业内部成员/企业互联成员
|
* - 仅限企业互联/上下游企业可调用
|
* - 当前成员为下游企业成员时,需要打开上下游空间中的“允许外部单位之间互相查看”配置才可以往群里添加其他下游企业成员
|
*
|
* @compat WeCom >= 3.1.8
|
*
|
* @example
|
* ```ts
|
* ww.updateCorpGroupChat({
|
* chatId: 'CHATID',
|
* userIdsToAdd: ['lisi', 'lisi2'],
|
* openUserIdsToAdd: ['wabc3', 'wbcde'],
|
* corpGroupUserIdsToAdd: [
|
* {
|
* corpId: 'ww3333',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* },
|
* {
|
* corpId: 'ww4444',
|
* userId: 'userid123',
|
* openUserId: 'wx1111'
|
* }
|
* ]
|
* })
|
* ```
|
*
|
* @throws
|
* | errMsg | 说明 |
|
* | --- | --- |
|
* | updateCorpGroupChat:ok | 执行成功 |
|
* | updateCorpGroupChat:fail no permission | 应用签名校验失败 |
|
* | updateCorpGroupChat:fail exceed user id list size | 超过人数上限 |
|
* | updateCorpGroupChat:fail invalid parameter | 参数不合法 |
|
* | updateCorpGroupChat:fail unsupported chat | 不支持群类型 |
|
*/
|
export declare function updateCorpGroupChat(params: APIParams<{
|
/**
|
* 通过企业微信创建群聊接口返回的 chatId
|
*/
|
chatId: string;
|
/**
|
* 新增的企业成员列表
|
*
|
* @limit
|
* 仅自建应用使用
|
*/
|
userIdsToAdd?: string;
|
/**
|
* 新增的企业成员列表
|
*
|
* @limit
|
* 仅第三方应用使用
|
*/
|
openUserIdsToAdd?: string;
|
/**
|
* 新增的互联企业成员列表
|
*/
|
corpGroupUserIdsToAdd?: Array<{
|
/**
|
* 企业 CorpID
|
*/
|
corpId: string;
|
/**
|
* 成员 ID
|
*
|
* @limit
|
* 仅自建应用使用
|
*/
|
userId?: string;
|
/**
|
* 成员 OpenUserID
|
*
|
* @limit
|
* 仅第三方应用使用
|
*/
|
openUserId?: string;
|
}>;
|
}>): Promise<CommonResult>;
|
/**
|
* 变更群成员。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 目前仅支持添加企业内部成员
|
* - 仅支持客户群调用
|
*
|
* @compat WeCom iOS, Android, PC >= 3.0.36
|
*
|
* @example
|
* ```ts
|
* ww.updateEnterpriseChat({
|
* chatId: 'CHATID',
|
* userIdsToAdd: [
|
* 'zhangsan',
|
* 'lisi'
|
* ]
|
* })
|
* ```
|
*/
|
export declare function updateEnterpriseChat(params: APIParams<{
|
/**
|
* 通过企业微信创建群聊接口返回的 chatId
|
*/
|
chatId: string;
|
/**
|
* 参与会话的企业成员列表
|
*/
|
userIdsToAdd: string | string[];
|
}>): Promise<CommonResult>;
|
/**
|
* 设置朋友圈封面与签名。
|
*
|
* @compat WeCom iOS, Android >= 3.1.12
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
|
* - 当前成员必须配置了客户联系功能
|
* - 当前成员必须在客户朋友圈使用范围
|
* - 当前成员必须具备外部沟通管理成员使用权限
|
*
|
* @note
|
* 同时设置了签名跟封面url,客户端更新顺序为先更新签名,再更新封面图url(封面图若不符合要求会让用户重新调整)。
|
*
|
* @example
|
* ```ts
|
* ww.updateMomentsSetting({
|
* signature: '个性签名',
|
* imgUrl: 'https://work.weixin.qq.com/'
|
* })
|
* ```
|
*/
|
export declare function updateMomentsSetting(params: APIParams<{
|
/**
|
* 个性签名
|
*
|
* 空字符串表示清空个性签名
|
*
|
* @limit
|
* 最多支持 30 字
|
*/
|
signature?: string;
|
/**
|
* 朋友圈封面
|
*
|
* 封面图建议为正方形,尺寸建议为 1125*1125 像素
|
*/
|
imgUrl?: string;
|
}>): Promise<CommonResult>;
|
/**
|
* 保持屏幕常亮。
|
*
|
* 在企业微信内打开 H5 页面时,调用该接口让屏幕保持常亮。
|
*
|
* @note
|
* 仅在当前页面生效,离开页面后设置失效。
|
*
|
* @limit
|
* - 本接口必须使用应用身份进行注册
|
* - 成员必须在应用可见范围内
|
*
|
* @compat @compat WeCom iOS, Android >= 4.0.20
|
*
|
* @example
|
* ```ts
|
* ww.setKeepScreenOn({
|
* keepScreenOn: true,
|
* })
|
* ```
|
*/
|
export declare function setKeepScreenOn(params: APIParams<{
|
/**
|
* 是否保持常亮
|
*/
|
keepScreenOn: boolean;
|
}>): Promise<CommonResult>;
|
/**
|
* JSAPI 类型
|
*/
|
export type CommonJSAPI<TParams = any, TSucc = any, TFail = any> = (params: APIParams<TParams, TSucc, TFail>) => Promise<CommonResult & TSucc>;
|
/**
|
* 获取指定 JS 接口参数类型
|
*/
|
export type JSAPIParams<T extends CommonJSAPI> = T extends CommonJSAPI<infer R> ? R : never;
|
/**
|
* 获取指定 JS 接口返回值类型
|
*/
|
export type JSAPIResult<T extends CommonJSAPI> = T extends CommonJSAPI<any, any, infer R> ? R : never;
|
/**
|
* 获取指定 JS 事件参数类型
|
*/
|
export type JSAPICallbackParams<T extends (callback: APICallback<any>) => any> = T extends (callback: APICallback<infer R>) => any ? R : never;
|
/**
|
* 触发或等待 config、agentConfig 完成
|
*
|
* @example
|
* ```ts
|
* await ww.ensureConfigReady()
|
* ```
|
*/
|
export declare function ensureConfigReady(): Promise<CorpConfigInfo> | Promise<AgentConfigInfo>;
|
/**
|
* WeixinJSBridge 是否已注入到 window
|
*/
|
export declare let isWeixinJSBridgeReady: boolean;
|
/**
|
* 等待 WeixinJSBridge 注入到 window
|
*/
|
export declare let onWeixinJSBridgeReady: Promise<void>;
|
/**
|
* 监听 JSSDK 未定义的事件
|
*
|
* @example
|
* ```ts
|
* ww.on('onBeaconsInRange', res => {
|
* console.log(res)
|
* })
|
* ```
|
*
|
* @param name 事件名称
|
* @param callback 监听回调
|
*/
|
export declare function on<TEvent>(name: string, callback: (event: TEvent) => void): Promise<void>;
|
/**
|
* 调用 JSSDK 未定义的 JSAPI
|
*
|
* @example
|
* ```ts
|
* ww.invoke('openEnterpriseChat', params, res => {
|
* console.log(res)
|
* })
|
* ```
|
*
|
* @param name JSAPI 名称
|
* @param params JSAPI 参数
|
* @param callback 回调函数
|
* @returns JSAPI 返回值
|
*/
|
export declare function invoke<TResult = CommonResult>(name: string, params?: any, callback?: (res: TResult) => void): Promise<TResult>;
|
/**
|
* 获取 config 或 agentConfig 传入的相关参数
|
*
|
* 用于外部 sdk 调用私有方法
|
*/
|
export declare function getVerifyParams(): {
|
appId: string | undefined;
|
verifyAppId: string | undefined;
|
verifySignType: string;
|
verifyTimestamp: string;
|
verifyNonceStr: string;
|
verifySignature: string;
|
} | undefined;
|
/**
|
* **注意:页面上需要提前引入 `jwxwork-1.0.0.js`:**
|
*
|
* ```html
|
* <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script>
|
* ```
|
*
|
* 初始化[通讯录展示组件](#91958)。
|
*
|
* 在该接口返回成功后,可以直接调用通讯录展示组件的相关方法。
|
*
|
* @example
|
* ```ts
|
* ww.initOpenData()
|
* ```
|
*/
|
export declare function initOpenData(params?: CommonParams<AgentConfigResult>): Promise<CommonResult & AgentConfigResult>;
|
declare const PANEL_JSAPI: {
|
readonly selectEnterpriseContact: typeof selectEnterpriseContact;
|
readonly shareAppMessage: typeof shareAppMessage;
|
};
|
export type AsyncGetter<T> = T | (() => T | Promise<T>);
|
export interface InnerStyle {
|
/**
|
* 光标样式
|
*/
|
cursor: string;
|
}
|
export interface JSAPIPanelOptions<TApi extends CommonJSAPI> {
|
/**
|
* 将 iframe 挂载在指定容器元素
|
*
|
* 参数可以是一个 DOM 元素或 CSS 选择器
|
*/
|
el?: string | Element;
|
/**
|
* OAuth 登录后企业微信返回的 web_token
|
*/
|
webToken?: string;
|
/**
|
* 自定义 iframe body 样式
|
*/
|
styles?: InnerStyle;
|
/**
|
* JSAPI 参数
|
*
|
* 可传入一个函数,返回需要调用的 JSAPI 参数
|
*/
|
params: AsyncGetter<JSAPIParams<TApi> & CommonParams<JSAPIResult<TApi>>>;
|
/**
|
* 错误回调
|
*/
|
onError?: (error: CommonResult) => void;
|
}
|
/**
|
* 创建 JSAPI 触发面板。
|
*
|
* 在非企业微信内置浏览器环境下,开发者可以创建 JSAPI 触发面板。当用户点击面板时,内置的 iframe 将调起用户本地的企业微信客户端并调用指定的 JSAPI。
|
*
|
* @param name 要调用的 JSAPI 名称
|
*
|
* @limit
|
* - 应用必须经过 SSO 登录获取 web_token
|
* - 用户必须登录了企业微信桌面端且当前用户身份和页面身份一致
|
*/
|
export declare function createJSAPIPanel<TName extends keyof typeof PANEL_JSAPI>(name: TName, options: JSAPIPanelOptions<(typeof PANEL_JSAPI)[TName]>): {
|
/**
|
* JSAPI 触发面板的 iframe 元素
|
*/
|
el: HTMLIFrameElement;
|
/**
|
* 卸载 JSAPI 触发面板
|
*/
|
unmount(): void;
|
};
|
export interface CreateOpenDataFrameFactoryParams {
|
/**
|
* 全局错误回调
|
*
|
* 企业微信环境内,获取登录态失败时触发
|
*
|
* @param error 错误信息
|
*/
|
handleError?: (error: unknown) => void;
|
/**
|
* 全局错误回调
|
*
|
* @deprecated 请使用 `handleError 回调
|
*
|
* @param error 错误信息
|
*/
|
onError?: (error: unknown) => void;
|
}
|
export type OpenDataFrameInstance<TData = Record<string, any>, TMethods = Record<string, any>> = TMethods & OpenDataFrameBuiltin<TData>;
|
export interface OpenDataFrameBuiltin<TData> {
|
/**
|
* 组件根元素
|
*/
|
el: HTMLElement;
|
/**
|
* 组件初始数据
|
*/
|
data: TData;
|
/**
|
* 更新组件数据
|
*
|
* @param partialData 这次要改变的数据
|
*/
|
setData(partialData: Record<string, unknown>): Promise<void>;
|
/**
|
* 销毁 open-data frame 组件
|
*/
|
dispose(): void;
|
}
|
export interface ModalInfo {
|
/** 弹窗 iframe URL */
|
modalUrl: string;
|
/** 弹窗大小 */
|
modalSize?: {
|
width: number;
|
height: number;
|
};
|
}
|
export interface CreateOpenDataFrameParams<TData, TMethods> {
|
/** 组件父元素 */
|
el?: HTMLElement | string;
|
/** 初始化数据 */
|
data?: TData;
|
/** 模板 */
|
template: string;
|
/** 样式表 */
|
style?: string;
|
/**
|
* 视图挂载成功回调
|
*/
|
handleMounted?: () => void;
|
/**
|
* 视图更新成功回调
|
*/
|
handleUpdated?: () => void;
|
/**
|
* 通用错误回调
|
*
|
* @param error 错误信息
|
*/
|
handleError?: (error: unknown) => void;
|
/**
|
* 弹窗处理回调
|
*
|
* @returns 是否由开发者自行创建弹窗 iframe
|
*/
|
handleModal?: (info: ModalInfo) => Promise<boolean | void> | boolean | void;
|
/**
|
* 通用错误回调
|
*
|
* @deprecated 请使用 `handleError 回调
|
*
|
* @param error 错误信息
|
*/
|
error?: (error: unknown) => void;
|
/**
|
* 方法列表
|
*/
|
methods?: TMethods & ThisType<OpenDataFrameInstance<TData, TMethods>>;
|
/**
|
* 其他回调事件
|
*/
|
[key: string]: any;
|
}
|
/**
|
* 创建 open-data frame 工厂对象。
|
*
|
* @compat WeCom >= 4.0.20
|
*
|
* @example
|
* ```ts
|
* const factory = ww.createOpenDataFrameFactory()
|
* const instance = factory.createOpenDataFrame(options)
|
*
|
* containerEl.appendChild(instance.el)
|
* ```
|
*/
|
export declare function createOpenDataFrameFactory(params?: CreateOpenDataFrameFactoryParams): {
|
/**
|
* 创建 open-data frame 组件
|
*/
|
createOpenDataFrame: <TData extends Record<string, any>, TMethods extends Record<string, (...args: unknown[]) => unknown>>(options: CreateOpenDataFrameParams<TData, TMethods>) => OpenDataFrameInstance<TData, TMethods>;
|
};
|
export interface SecurityGatewayConfirmModalOptions {
|
/**
|
* 确认 ID
|
*/
|
confirmId: string;
|
/**
|
* 点击确认或关闭按钮的回调
|
*
|
* 仅在桌面端环境生效
|
*
|
* @compat PC, Mac
|
*/
|
onClose?: () => void;
|
}
|
/**
|
* 显示确认安全网关配置页面。
|
*
|
* 在桌面端页面以 iframe 弹窗的形式覆盖在页面上;在移动端页面将跳转至确认页面,返回后页面需要主动确认 confirm_id 的确认情况。
|
*/
|
export declare function showSecurityGatewayConfirmModal(options: SecurityGatewayConfirmModalOptions): {
|
/**
|
* 弹窗面板的 iframe 元素
|
*/
|
el: HTMLIFrameElement;
|
/**
|
* 卸载弹窗面板
|
*/
|
unmount(): void;
|
} | undefined;
|
export interface WWLoginOptions {
|
/**
|
* 登录组件挂载元素
|
*
|
* 可以指定 `DOM` 元素或 `CSS` 选择器
|
*/
|
el?: string | Element;
|
/**
|
* 登录参数
|
*/
|
params: WWLoginParams;
|
/**
|
* 获取企业微信桌面端登录状态回调
|
*/
|
onCheckWeComLogin?: (event: WWLoginCheckLoginResp) => void;
|
/**
|
* 企业微信登录成功回调
|
*
|
* 需配置 `redirect_type=callback`
|
*/
|
onLoginSuccess?: (res: WWLoginSuccessResp) => void;
|
/**
|
* 企业微信登录错误回调
|
*
|
* [登录相关错误码](#45752/附录)
|
*/
|
onLoginFail?: (res: WWLoginErrorResp) => void;
|
/**
|
* 打开企业微信客户端成功回调
|
*/
|
onOpenInWecom?: () => void;
|
}
|
export interface WWLoginParams {
|
/**
|
* 登录类型
|
*/
|
login_type?: WWLoginType;
|
/**
|
* AppID
|
*
|
* 登录类型为企业自建应用/服务商代开发应用时填企业 `CorpID`,第三方登录时填[登录授权 `SuiteID`](#45846/开启网页授权登录)
|
*/
|
appid: string;
|
/**
|
* 企业自建应用/服务商代开发应用 `AgentID`
|
*/
|
agentid?: string;
|
/**
|
* 登录成功重定向 `url`
|
*
|
* 无需进行 `URLEncode`
|
*/
|
redirect_uri: string;
|
/**
|
* 登录 `state`
|
*
|
* 用于保持请求和回调的状态,授权请求后原样带回给企业。该参数可用于防止 `CSRF` 攻击(跨站请求伪造攻击),
|
* 建议带上该参数,可设置为简单的随机数加 `session` 进行校验
|
*/
|
state?: string;
|
/**
|
* 登录成功跳转类型
|
*/
|
redirect_type?: WWLoginRedirectType;
|
/**
|
* 登录面板大小
|
*/
|
panel_size?: WWLoginPanelSizeType;
|
/**
|
* 语言类型
|
*/
|
lang?: WWLoginLangType;
|
/**
|
* 其他参数
|
*/
|
[key: string]: any;
|
}
|
/**
|
* 登录类型
|
*/
|
export declare enum WWLoginType {
|
/**
|
* [第三方应用登录](#45846)
|
*/
|
serviceApp = "ServiceApp",
|
/**
|
* [企业自建应用登录](/document/path/98151)、[服务商代开发应用登录](/document/path/98173)
|
*/
|
corpApp = "CorpApp"
|
}
|
/**
|
* 语言类型
|
*/
|
export declare enum WWLoginLangType {
|
/**
|
* 中文
|
*/
|
zh = "zh",
|
/**
|
* 英文
|
*/
|
en = "en"
|
}
|
/**
|
* 登录成功跳转类型
|
*/
|
export declare enum WWLoginRedirectType {
|
/**
|
* 默认 `top window` 顶层页面跳转
|
*/
|
top = "top",
|
/**
|
* 通过 `onLoginSuccess` 回调用户授权 `code`,开发者自行处理跳转
|
*/
|
callback = "callback",
|
/**
|
* 登录组件跳转
|
*/
|
self = "self"
|
}
|
/**
|
* 登录面板大小
|
*/
|
export declare enum WWLoginPanelSizeType {
|
/**
|
* 默认: 480x416px
|
*/
|
middle = "middle",
|
/**
|
* 小尺寸: 320x380px
|
*/
|
small = "small"
|
}
|
/**
|
* 企业微信登录状态
|
*/
|
export interface WWLoginCheckLoginResp {
|
/**
|
* 企业微信桌面端是否已登录
|
*/
|
isWeComLogin: boolean;
|
}
|
/**
|
* 企业微信登录成功回调
|
*/
|
export interface WWLoginSuccessResp {
|
/**
|
* `Auth Code`
|
*/
|
code: string;
|
}
|
/**
|
* 企业微信登录错误回调
|
*/
|
export interface WWLoginErrorResp {
|
/**
|
* 错误码
|
*/
|
errCode?: number;
|
/**
|
* 错误信息
|
*/
|
errMsg?: string;
|
}
|
export interface WWLoginInstance {
|
/**
|
* 登录面板 `iframe` 元素
|
*/
|
el: HTMLIFrameElement;
|
/**
|
* 卸载登录面板
|
*/
|
unmount(): void;
|
}
|
/**
|
* 初始化企业微信Web登录组件,创建登录面板。
|
*
|
* @example
|
* ```ts
|
* // 初始化登录组件
|
* const wwLogin = ww.createWWLoginPanel({
|
* el: '#ww_login',
|
* params: {
|
* login_type: 'CorpApp',
|
* appid: 'wwbbb6a7b539f2xxxxx',
|
* agentid: '10000xx',
|
* redirect_uri: 'https://work.weixin.qq.com',
|
* state: 'loginState',
|
* redirect_type: 'callback',
|
* },
|
* onCheckWeComLogin({ isWeComLogin }) {
|
* console.log(isWeComLogin)
|
* },
|
* onLoginSuccess({ code }) {
|
* console.log({ code })
|
* },
|
* onLoginFail(err) {
|
* console.log(err)
|
* },
|
* })
|
* ```
|
*/
|
export declare function createWWLoginPanel(options: WWLoginOptions): WWLoginInstance;
|
export interface InvokeOptions {
|
serialize?: boolean;
|
transfer?: Transferable[];
|
dropResult?: boolean;
|
}
|
export interface Ref {
|
frame: object;
|
invoke<TRes>(method: string, data: unknown, opts?: InvokeOptions): Promise<TRes>;
|
subscribe<TData>(fn: (data: TData) => void): () => void;
|
}
|
export interface BindRes {
|
width: number;
|
height: number;
|
}
|
export declare class FrameCanvas {
|
#private;
|
constructor(ref: Ref, refId: number, info: BindRes);
|
/**
|
* canvas 元素宽度
|
*/
|
get width(): number;
|
set width(value: number);
|
/**
|
* canvas 元素高度
|
*/
|
get height(): number;
|
set height(value: number);
|
/**
|
* 通过 url 创建图片元素
|
*
|
* @param src 图片 url,只支持传入 data uri
|
*/
|
createImage(src: string): HTMLImageElement;
|
/**
|
* 通过 ArrayBuffer 创建图片元素
|
*
|
* @param data 图片二进制数据
|
* @param type 图片 MIME 类型
|
*/
|
createImage(data: ArrayBuffer, type?: string): HTMLImageElement;
|
/**
|
* 获取 canvas 的上下文
|
*
|
* @param type 上下文类型,目前只支持 2d
|
* @param attrs 渲染上下文配置
|
*/
|
getContext(type: "2d", attrs?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D;
|
/**
|
* 添加事件监听器
|
*/
|
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
/**
|
* 移除事件监听器
|
*/
|
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
}
|
/**
|
* 获取 open-data frame 组件内的 canvas 元素。
|
*
|
* @param instance open-data frame 组件实例
|
* @param refName 模板引用名称
|
*
|
* @example
|
* ```ts
|
* const canvas = await ww.getCanvas(frame, 'canvas')
|
* const context = canvas.getContext('2d')
|
* ```
|
*/
|
export declare function getCanvas(instance: OpenDataFrameInstance, refName: string): Promise<FrameCanvas | undefined>;
|
export interface FrameScrollToOptions {
|
/**
|
* 顶部距离
|
*/
|
top?: number;
|
/**
|
* 左边界距离
|
*/
|
left?: number;
|
}
|
export interface FrameScrollIntoViewOptions {
|
/**
|
* 定义垂直方向的对齐
|
* @default 'start'
|
*/
|
block?: "start" | "center" | "end" | "nearest";
|
/**
|
* 定义水平方向的对齐
|
* @default 'nearest'
|
*/
|
inline?: "start" | "center" | "end" | "nearest";
|
}
|
export interface ScrollViewContext {
|
/**
|
* 滚动至指定位置
|
*/
|
scrollTo(options: FrameScrollToOptions): void;
|
/**
|
* 滚动至指定位置
|
*
|
* @param selector 元素选择器
|
* @param options 滚动选项
|
*/
|
scrollIntoView(selector: string, options?: FrameScrollIntoViewOptions): void;
|
}
|
/**
|
* 创建 open-data frame 组件内指定 scroll-view 元素的上下文。
|
*
|
* @param instance open-data frame 组件实例
|
* @param refName 模板引用名称
|
*
|
* @example
|
* ```ts
|
* const scrollView = await ww.createScrollViewContext(instance, 'scroll-view')
|
*
|
* scrollView.scrollTo({ top: 100 })
|
* ```
|
*/
|
export declare function createScrollViewContext(instance: OpenDataFrameInstance, refName: string): Promise<ScrollViewContext | undefined>;
|
export interface NodeInfo {
|
rect?: NodeRectInfo;
|
}
|
export interface NodeRectInfo {
|
/**
|
* 宽度
|
*/
|
width: number;
|
/**
|
* 高度
|
*/
|
height: number;
|
/**
|
* 上边界坐标
|
*/
|
top: number;
|
/**
|
* 右边界坐标
|
*/
|
right: number;
|
/**
|
* 下边界坐标
|
*/
|
bottom: number;
|
/**
|
* 左边界坐标
|
*/
|
left: number;
|
}
|
export interface GetNodeInfoFields {
|
/**
|
* 是否返回节点布局位置
|
*
|
* @default false
|
*/
|
rect?: boolean;
|
}
|
/**
|
* 获取节点的相关信息
|
*
|
* @param instance open-data frame 组件实例
|
* @param refName 模板引用名称
|
* @param fields 需要获取的字段
|
*
|
* @example
|
* ```ts
|
* ww.getNodeInfo(instance, 'node-ref')
|
* ```
|
*/
|
export declare function getNodeInfo(instance: OpenDataFrameInstance, refName: string, fields: GetNodeInfoFields): Promise<NodeInfo | undefined>;
|
export interface GetSignatureOptions {
|
/**
|
* 用于签名的 jsapi ticket
|
*/
|
ticket: string;
|
/**
|
* 生成签名的随机串
|
*/
|
nonceStr?: string;
|
/**
|
* 生成签名的时间戳
|
*/
|
timestamp?: number | string;
|
/**
|
* 当前页面的 URL
|
*/
|
url?: string;
|
}
|
export interface GetSignatureResult {
|
/**
|
* 生成签名的时间戳
|
*/
|
timestamp: number | string;
|
/**
|
* 生成签名的随机串
|
*/
|
nonceStr: string;
|
/**
|
* jsapi 签名
|
*/
|
signature: string;
|
}
|
/**
|
* 根据 ticket 生成 jsapi 签名
|
*
|
* @param ticket 用于签名的 jsapi ticket
|
*/
|
export declare function getSignature(ticket: string): GetSignatureResult;
|
/**
|
* 根据提供的参数生成 jsapi 签名
|
*/
|
export declare function getSignature(options: GetSignatureOptions): GetSignatureResult;
|
export declare const SDK_VERSION: string;
|
export declare const env: {
|
isWeChat: boolean;
|
isWeCom: boolean;
|
};
|
export declare const IS_WECOM_SDK = true;
|
|
export {};
|