-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
487 lines (373 loc) · 9.96 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
/**
* Copyright (c) 2015,Egret-Labs.org
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Egret-Labs.org nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY EGRET-LABS.ORG AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL EGRET-LABS.ORG AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Created by wibrst on 2015/1/10.
*/
type GetEnvParam = {
(cb: {
miniprogram: boolean
}): void
}
type GetEnv = {
(cb: GetEnvParam): void
}
type PostMessage = {
(param: {
data: unknown
}): void
}
type CommonCall = {
success?: Function,
fail?: Function,
complete?: Function,
}
type RouteParam = {
url: string
} & CommonCall
type RouteFunction<T> = {
(param: T): void
}
type NavigateToParam = RouteParam & {
events?: Object
}
type NavigateBackParam = {
delta?: number,
} & CommonCall
type MiniProgram = {
getEnv: GetEnv,
postMessage: PostMessage,
redirectTo: RouteFunction<RouteParam>,
reLaunch: RouteFunction<RouteParam>,
switchTab: RouteFunction<RouteParam>,
navigateTo: RouteFunction<NavigateToParam>,
navigateBack: RouteFunction<NavigateBackParam>
}
declare class wx {
/**
* 通过config接口注入权限验证配置
* @param bodyConfig
*/
static config(bodyConfig: BodyConfig): void;
/**
* 通过ready接口处理成功验证
* @param cbValidated 成功验证后的处理函数
*/
static ready(cbValidated: Function): void;
/**
* 通过error接口处理失败验证
* @param cbError 处理失败验证后的处理函数
*/
static error(cbError: Function): void;
/**
* 判断当前客户端版本是否支持指定JS接口
* @param bodyCheckJsAPISupport
*/
static checkJsApi(bodyCheckJsAPISupport: BodyCheckJsAPISupport): void;
/**
* 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
* @param bodyMenuShareTimeline
*/
static onMenuShareTimeline(bodyMenuShareTimeline: BodyMenuShareTimeline): void;
/**
* 获取“分享给朋友”按钮点击状态及自定义分享内容接口
* @param bodyMenuShareAppMessage
*/
static onMenuShareAppMessage(bodyMenuShareAppMessage: BodyMenuShareAppMessage): void;
/**
* 获取“分享到QQ”按钮点击状态及自定义分享内容接口
* @param bodyMenuShareQQ
*/
static onMenuShareQQ(bodyMenuShareQQ: BodyMenuShareQQ): void;
/**
* 自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容
* @param bodyTimelineShareData
*/
static updateTimelineShareData(bodyTimelineShareData: BodyTimelineShareData): void;
/**
* 自定义“分享给朋友”及“分享到QQ”按钮的分享内容
* @param bodyAppMessageShareData
*/
static updateAppMessageShareData(bodyAppMessageShareData: BodyAppMessageShareData): void;
/**
* 获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口
* @param bodyMenuShareWeibo
*/
static onMenuShareWeibo(bodyMenuShareWeibo: BodyMenuShareWeibo): void;
/// 华丽的分界线, 以下接口参数结构较简单或使用较少,均可自行查阅微信官方api文档给出适合的参数
/**
* 拍照或从手机相册中选图接口
* @param bodyChooseImage
*/
static chooseImage(body: Object): void;
static getLocalImgData(body: {
localId: string,
success: (res: { localData: string }) => void
}): void;
/**
* 预览图片接口
* @param body
*/
static previewImage(body: Object): void;
/**
* 上传图片接口
* @param body
*/
static uploadImage(body: Object): void;
/**
* 下载图片接口
* @param body
*/
static downloadImage(body: Object): void;
/**
* 开始录音接口
* @param body
*/
static startRecord(body: Object): void;
/**
* 停止录音接口
* @param body
*/
static stopRecord(body: Object): void;
/**
* 监听录音自动停止接口
* @param body
*/
static onVoiceRecordEnd(body: Object): void;
/**
* 播放语音接口
* @param body
*/
static playVoice(body: Object): void;
/**
* 暂停播放接口
* @param body
*/
static pauseVoice(body: Object): void;
/**
* 停止播放接口
* @param body
*/
static stopVoice(body: Object): void;
/**
* 监听语音播放完毕接口
* @param body
*/
static onVoicePlayEnd(body: Object): void;
/**
* 上传语音接口
* @param body
*/
static uploadVoice(body: Object): void;
/**
* 下载语音接口
* @param body
*/
static downloadVoice(body: Object): void;
// ---- 智能接口
/**
* 识别音频并返回识别结果接口
* @param body
*/
static translateVoice(body: Object): void;
/// ---- 设备信息
/**
* 获取网络状态接口
* @param body
*/
static getNetworkType(body: Object): void;
/// ---- 地理位置
/**
* 使用微信内置地图查看位置接口
* @param body
*/
static openLocation(body: Object): void;
/**
* 获取地理位置接口
* @param body
*/
static getLocation(body: Object): void;
/// ---- 界面操作
/**
* 隐藏右上角菜单接口
* @param body
*/
static hideOptionMenu(body: Object): void;
/**
* 显示右上角菜单接口
* @param body
*/
static showOptionMenu(body: Object): void;
/**
* 关闭当前网页窗口接口
* @param body
*/
static closeWindow(body: Object): void;
/**
* 批量隐藏功能按钮接口
* @param body
*/
static hideMenuItems(body: Object): void;
/**
* 批量显示功能按钮接口
* @param body
*/
static showMenuItems(body: Object): void;
/**
* 隐藏所有非基础按钮接口
* @param body
*/
static hideAllNonBaseMenuItem(body: Object): void;
/**
* 显示所有功能按钮接口
* @param body
*/
static showAllNonBaseMenuItem(body: Object): void;
/// ---- 微信扫一扫
/**
* 调起微信扫一扫接口
* @param body
*/
static scanQRCode(body: Object): void;
/// ---- 微信小店
/**
* 跳转微信商品页接口
* @param body
*/
static openProductSpecificView(body: Object): void;
/// ---- 微信卡券
/**
* 调起适用于门店的卡券列表并获取用户选择列表
* @param body
*/
static chooseCard(body: Object): void;
/**
* 批量添加卡券接口
* @param body
*/
static addCard(body: Object): void;
/**
* 查看微信卡包中的卡券接口
* @param body
*/
static openCard(body: Object): void;
/// ---- 微信支付
/**
* 发起一个微信支付请求
* @param body
*/
static chooseWXPay(body: Object): void;
static miniProgram: MiniProgram | undefined
}
///////////////////////////////// 常用API的参数结构类
/**
* config 参数结构
* jsApiList: 所有要调用的 API
*/
declare class BodyConfig {
debug: boolean;
appId: string;
timestamp: number;
nonceStr: string;
signature: string;
jsApiList: Array<string>;
}
/**
* checkJsApi 参数结构
* jsApiList: 需要检测的JS接口列表
*/
declare class BodyCheckJsAPISupport {
success: Function;
jsApiList: Array<string>;
}
/**
* onMenuShareTimeline 参数结构
*/
declare class BodyMenuShareTimeline {
title: string;
link: string;
imgUrl: string;
success: Function;
cancel: Function;
}
/**
* onMenuShareAppMessage 参数结构
*/
declare class BodyMenuShareAppMessage {
title: string;
desc: string;
link: string;
imgUrl: string;
type: string;
dataUrl: string;
success: Function;
cancel: Function;
}
/**
* onMenuShareQQ 参数结构
*/
declare class BodyMenuShareQQ {
title: string;
desc: string;
link: string;
imgUrl: string;
type: string;
dataUrl: string;
success: Function;
cancel: Function;
}
/**
* onMenuShareTimeline 参数结构
*/
declare class BodyTimelineShareData {
title: string;
link: string;
imgUrl: string;
success: Function;
cancel: Function;
}
/**
* onMenuShareTimeline 参数结构
*/
declare class BodyAppMessageShareData {
title: string;
link: string;
desc: string;
imgUrl: string;
success: Function;
cancel: Function;
}
/**
* onMenuShareWeibo 参数结构
*/
declare class BodyMenuShareWeibo {
title: string;
desc: string;
link: string;
imgUrl: string;
success: Function;
cancel: Function;
}
export default wx;