@hairy/wechat-jssdk 1.47.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -21
- package/README.md +66 -66
- package/dist/index.cjs +235 -269
- package/dist/index.d.cts +117 -0
- package/dist/index.d.mts +117 -0
- package/dist/index.mjs +242 -0
- package/package.json +18 -21
- package/dist/index.d.ts +0 -114
- package/dist/index.global.js +0 -253
- package/dist/index.js +0 -250
package/dist/index.cjs
CHANGED
|
@@ -1,277 +1,243 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _hairy_utils = require("@hairy/utils");
|
|
19
3
|
|
|
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
|
-
if (defer)
|
|
48
|
-
element.defer = defer;
|
|
49
|
-
if (crossOrigin)
|
|
50
|
-
element.crossOrigin = crossOrigin;
|
|
51
|
-
if (noModule)
|
|
52
|
-
element.noModule = noModule;
|
|
53
|
-
if (referrerPolicy)
|
|
54
|
-
element.referrerPolicy = referrerPolicy;
|
|
55
|
-
shouldAppend = true;
|
|
56
|
-
} else if (Object.hasOwn(element.dataset, "loaded")) {
|
|
57
|
-
resolve(element);
|
|
58
|
-
}
|
|
59
|
-
element.addEventListener("error", (event) => reject(event));
|
|
60
|
-
element.addEventListener("abort", (event) => reject(event));
|
|
61
|
-
element.addEventListener("load", () => {
|
|
62
|
-
element.dataset.loaded = "true";
|
|
63
|
-
onLoaded(element);
|
|
64
|
-
resolve(element);
|
|
65
|
-
});
|
|
66
|
-
if (shouldAppend)
|
|
67
|
-
element = document.head.appendChild(element);
|
|
68
|
-
if (!waitForScriptLoad)
|
|
69
|
-
resolve(element);
|
|
70
|
-
});
|
|
4
|
+
//#region src/internal/load_script.ts
|
|
5
|
+
function loadScript(source, onLoaded = _hairy_utils.noop, options = {}) {
|
|
6
|
+
const { type = "text/javascript", async = true, crossOrigin, referrerPolicy, noModule, defer, waitForScriptLoad = true } = options;
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
let shouldAppend = false;
|
|
9
|
+
let element = document.querySelector(`script[src="${source}"]`);
|
|
10
|
+
if (!element) {
|
|
11
|
+
element = document.createElement("script");
|
|
12
|
+
element.type = type;
|
|
13
|
+
element.async = async;
|
|
14
|
+
element.src = source;
|
|
15
|
+
if (defer) element.defer = defer;
|
|
16
|
+
if (crossOrigin) element.crossOrigin = crossOrigin;
|
|
17
|
+
if (noModule) element.noModule = noModule;
|
|
18
|
+
if (referrerPolicy) element.referrerPolicy = referrerPolicy;
|
|
19
|
+
shouldAppend = true;
|
|
20
|
+
} else if (Object.hasOwn(element.dataset, "loaded")) resolve(element);
|
|
21
|
+
element.addEventListener("error", (event) => reject(event));
|
|
22
|
+
element.addEventListener("abort", (event) => reject(event));
|
|
23
|
+
element.addEventListener("load", () => {
|
|
24
|
+
element.dataset.loaded = "true";
|
|
25
|
+
onLoaded(element);
|
|
26
|
+
resolve(element);
|
|
27
|
+
});
|
|
28
|
+
if (shouldAppend) element = document.head.appendChild(element);
|
|
29
|
+
if (!waitForScriptLoad) resolve(element);
|
|
30
|
+
});
|
|
71
31
|
}
|
|
72
32
|
|
|
73
|
-
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/helper.ts
|
|
35
|
+
/**
|
|
36
|
+
* jssdk 的前置处理类
|
|
37
|
+
* @constructor 加载配置(apiHost,appId,config,version,jssdk)
|
|
38
|
+
* @function implement 提供 wxApi 执行器(等待 config 与 ready 结束,在调用 api)
|
|
39
|
+
* @function config 加载配置,提供 promise 式返回
|
|
40
|
+
* @function ready wx.ready,提供 promise 式返回
|
|
41
|
+
*/
|
|
74
42
|
var WechatJssdkHelper = class {
|
|
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
|
-
return this.ready().catch((error) => error);
|
|
128
|
-
}
|
|
129
|
-
async implement(key, options) {
|
|
130
|
-
if (this.configPromise)
|
|
131
|
-
await this.configPromise;
|
|
132
|
-
await this.ready();
|
|
133
|
-
wx[key](options);
|
|
134
|
-
}
|
|
43
|
+
version;
|
|
44
|
+
isReady = false;
|
|
45
|
+
requestConfig;
|
|
46
|
+
loadPromise;
|
|
47
|
+
configPromise;
|
|
48
|
+
readyPromise;
|
|
49
|
+
loadJssdk() {
|
|
50
|
+
this.loadPromise = loadScript(`https://res.wx.qq.com/open/js/jweixin-${this.version}.js`).then(() => {
|
|
51
|
+
this.loadPromise = void 0;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
constructor(options) {
|
|
55
|
+
const { immediate = true, version, requestConfig } = options;
|
|
56
|
+
this.version = version || "1.3.0";
|
|
57
|
+
this.requestConfig = requestConfig;
|
|
58
|
+
this.loadJssdk();
|
|
59
|
+
if (immediate) this.config();
|
|
60
|
+
}
|
|
61
|
+
async config() {
|
|
62
|
+
if (this.configPromise) return this.configPromise;
|
|
63
|
+
if (this.loadPromise) await this.loadPromise;
|
|
64
|
+
this.configPromise = (async () => {
|
|
65
|
+
wx.config(await this.requestConfig());
|
|
66
|
+
})();
|
|
67
|
+
return this.configPromise;
|
|
68
|
+
}
|
|
69
|
+
async ready() {
|
|
70
|
+
if (this.readyPromise) return this.readyPromise;
|
|
71
|
+
if (this.loadPromise) await this.loadPromise;
|
|
72
|
+
if (this.isReady) return;
|
|
73
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
74
|
+
wx.ready(() => {
|
|
75
|
+
this.isReady = true;
|
|
76
|
+
this.readyPromise = void 0;
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
79
|
+
wx.error((error) => {
|
|
80
|
+
this.isReady = false;
|
|
81
|
+
this.readyPromise = void 0;
|
|
82
|
+
reject(error);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return this.readyPromise;
|
|
86
|
+
}
|
|
87
|
+
async error() {
|
|
88
|
+
return this.ready().catch((error) => error);
|
|
89
|
+
}
|
|
90
|
+
async implement(key, options) {
|
|
91
|
+
if (this.configPromise) await this.configPromise;
|
|
92
|
+
await this.ready();
|
|
93
|
+
wx[key](options);
|
|
94
|
+
}
|
|
135
95
|
};
|
|
136
96
|
|
|
137
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/index.ts
|
|
99
|
+
/**
|
|
100
|
+
* @description WechatJssdk Api 封装,与 [jssdk 文档](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html) 保持一致,主要以下改动
|
|
101
|
+
* @description 内置请求,读取 config 配置,初始化自动调用 wx.config
|
|
102
|
+
* @description 所有 api 的 promise 化处理(仅等待 wx.ready)
|
|
103
|
+
* @description 简易化初始化构建,config 处理
|
|
104
|
+
* @description 可指定加载 jssdk 版本(默认 1.3.0)
|
|
105
|
+
* @template `const wxJssdk = new WechatJssdk({env, config})`
|
|
106
|
+
*/
|
|
138
107
|
var WechatJssdk = class extends WechatJssdkHelper {
|
|
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
|
-
return this.implement("uploadVoice", options);
|
|
272
|
-
}
|
|
108
|
+
constructor(options) {
|
|
109
|
+
super(options);
|
|
110
|
+
}
|
|
111
|
+
updateAppMessageShareData(options) {
|
|
112
|
+
return this.implement("updateAppMessageShareData", options);
|
|
113
|
+
}
|
|
114
|
+
updateTimelineShareData(options) {
|
|
115
|
+
return this.implement("updateTimelineShareData", options);
|
|
116
|
+
}
|
|
117
|
+
addCard() {
|
|
118
|
+
return this.implement("addCard");
|
|
119
|
+
}
|
|
120
|
+
checkJsApi(options) {
|
|
121
|
+
return this.implement("checkJsApi", options);
|
|
122
|
+
}
|
|
123
|
+
chooseCard(options) {
|
|
124
|
+
return this.implement("chooseCard", options);
|
|
125
|
+
}
|
|
126
|
+
chooseImage(options) {
|
|
127
|
+
return this.implement("chooseImage", options);
|
|
128
|
+
}
|
|
129
|
+
chooseWXPay(options) {
|
|
130
|
+
return this.implement("chooseWXPay", options);
|
|
131
|
+
}
|
|
132
|
+
closeWindow() {
|
|
133
|
+
return this.implement("closeWindow");
|
|
134
|
+
}
|
|
135
|
+
consumeAndShareCard(options) {
|
|
136
|
+
return this.implement("consumeAndShareCard", options);
|
|
137
|
+
}
|
|
138
|
+
downloadImage(options) {
|
|
139
|
+
return this.implement("downloadImage", options);
|
|
140
|
+
}
|
|
141
|
+
downloadVoice(options) {
|
|
142
|
+
return this.implement("downloadVoice", options);
|
|
143
|
+
}
|
|
144
|
+
getLocalImgData(options) {
|
|
145
|
+
return this.implement("getLocalImgData", options);
|
|
146
|
+
}
|
|
147
|
+
getLocation(options) {
|
|
148
|
+
return this.implement("getLocation", options);
|
|
149
|
+
}
|
|
150
|
+
getNetworkType(options) {
|
|
151
|
+
return this.implement("getNetworkType", options);
|
|
152
|
+
}
|
|
153
|
+
hideAllNonBaseMenuItem() {
|
|
154
|
+
return this.implement("hideAllNonBaseMenuItem");
|
|
155
|
+
}
|
|
156
|
+
hideMenuItems(options) {
|
|
157
|
+
return this.implement("hideMenuItems", options);
|
|
158
|
+
}
|
|
159
|
+
hideOptionMenu() {
|
|
160
|
+
return this.implement("hideOptionMenu");
|
|
161
|
+
}
|
|
162
|
+
onMenuShareAppMessage(options) {
|
|
163
|
+
return this.implement("onMenuShareAppMessage", options);
|
|
164
|
+
}
|
|
165
|
+
onMenuShareQQ(options) {
|
|
166
|
+
return this.implement("onMenuShareQQ", options);
|
|
167
|
+
}
|
|
168
|
+
onMenuShareQZone(options) {
|
|
169
|
+
return this.implement("onMenuShareQZone", options);
|
|
170
|
+
}
|
|
171
|
+
onMenuShareTimeline(options) {
|
|
172
|
+
return this.implement("onMenuShareTimeline", options);
|
|
173
|
+
}
|
|
174
|
+
onMenuShareWeibo(options) {
|
|
175
|
+
return this.implement("onMenuShareWeibo", options);
|
|
176
|
+
}
|
|
177
|
+
onSearchBeacons(options) {
|
|
178
|
+
return this.implement("onSearchBeacons", options);
|
|
179
|
+
}
|
|
180
|
+
onVoicePlayEnd(options) {
|
|
181
|
+
return this.implement("onVoicePlayEnd", options);
|
|
182
|
+
}
|
|
183
|
+
onVoiceRecordEnd(options) {
|
|
184
|
+
return this.implement("onVoiceRecordEnd", options);
|
|
185
|
+
}
|
|
186
|
+
openCard(options) {
|
|
187
|
+
return this.implement("openCard", options);
|
|
188
|
+
}
|
|
189
|
+
openLocation(options) {
|
|
190
|
+
return this.implement("openLocation", options);
|
|
191
|
+
}
|
|
192
|
+
openProductSpecificView(options) {
|
|
193
|
+
return this.implement("openProductSpecificView", options);
|
|
194
|
+
}
|
|
195
|
+
pauseVoice(options) {
|
|
196
|
+
return this.implement("pauseVoice", options);
|
|
197
|
+
}
|
|
198
|
+
playVoice(options) {
|
|
199
|
+
return this.implement("playVoice", options);
|
|
200
|
+
}
|
|
201
|
+
previewImage(options) {
|
|
202
|
+
return this.implement("previewImage", options);
|
|
203
|
+
}
|
|
204
|
+
scanQRCode(options) {
|
|
205
|
+
return this.implement("scanQRCode", options);
|
|
206
|
+
}
|
|
207
|
+
showAllNonBaseMenuItem() {
|
|
208
|
+
return this.implement("showAllNonBaseMenuItem");
|
|
209
|
+
}
|
|
210
|
+
showMenuItems(options) {
|
|
211
|
+
return this.implement("showMenuItems", options);
|
|
212
|
+
}
|
|
213
|
+
showOptionMenu() {
|
|
214
|
+
return this.implement("showOptionMenu");
|
|
215
|
+
}
|
|
216
|
+
startRecord() {
|
|
217
|
+
return this.implement("startRecord");
|
|
218
|
+
}
|
|
219
|
+
startSearchBeacons(options) {
|
|
220
|
+
return this.implement("startSearchBeacons", options);
|
|
221
|
+
}
|
|
222
|
+
stopRecord(options) {
|
|
223
|
+
return this.implement("stopRecord", options);
|
|
224
|
+
}
|
|
225
|
+
stopSearchBeacons(options) {
|
|
226
|
+
return this.implement("stopSearchBeacons", options);
|
|
227
|
+
}
|
|
228
|
+
stopVoice(options) {
|
|
229
|
+
return this.implement("stopVoice", options);
|
|
230
|
+
}
|
|
231
|
+
translateVoice(options) {
|
|
232
|
+
return this.implement("translateVoice", options);
|
|
233
|
+
}
|
|
234
|
+
uploadImage(options) {
|
|
235
|
+
return this.implement("uploadImage", options);
|
|
236
|
+
}
|
|
237
|
+
uploadVoice(options) {
|
|
238
|
+
return this.implement("uploadVoice", options);
|
|
239
|
+
}
|
|
273
240
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
});
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
exports.WechatJssdk = WechatJssdk;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as WxType from "jweixin";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
declare module 'jweixin' {
|
|
5
|
+
type v4ApiMethod = 'updateTimelineShareData' | 'updateAppMessageShareData';
|
|
6
|
+
function config(config_: {
|
|
7
|
+
debug?: boolean | undefined;
|
|
8
|
+
appId: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
nonceStr: string;
|
|
11
|
+
signature: string;
|
|
12
|
+
jsApiList: (WxType.ApiMethod | v4ApiMethod)[];
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
15
|
+
declare global {
|
|
16
|
+
const wx: typeof WxType;
|
|
17
|
+
}
|
|
18
|
+
type WechatJssdkConfig = Omit<Parameters<typeof wx.config>[0], 'catch' | 'finally' | 'then'>;
|
|
19
|
+
interface WechatJssdkOptions {
|
|
20
|
+
/**
|
|
21
|
+
* 初始化请求配置
|
|
22
|
+
*/
|
|
23
|
+
requestConfig: () => Promise<WechatJssdkConfig> | WechatJssdkConfig;
|
|
24
|
+
/**
|
|
25
|
+
* 是否立即加载 config
|
|
26
|
+
*
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
immediate?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* wechat-jssdk 版本
|
|
32
|
+
*
|
|
33
|
+
* @default 1.3.0
|
|
34
|
+
*/
|
|
35
|
+
version?: '1.2.0' | '1.3.0' | '1.4.0' | '1.5.0' | '1.6.0';
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/helper.d.ts
|
|
39
|
+
/**
|
|
40
|
+
* jssdk 的前置处理类
|
|
41
|
+
* @constructor 加载配置(apiHost,appId,config,version,jssdk)
|
|
42
|
+
* @function implement 提供 wxApi 执行器(等待 config 与 ready 结束,在调用 api)
|
|
43
|
+
* @function config 加载配置,提供 promise 式返回
|
|
44
|
+
* @function ready wx.ready,提供 promise 式返回
|
|
45
|
+
*/
|
|
46
|
+
declare class WechatJssdkHelper {
|
|
47
|
+
private version;
|
|
48
|
+
private isReady;
|
|
49
|
+
private requestConfig;
|
|
50
|
+
private loadPromise?;
|
|
51
|
+
private configPromise?;
|
|
52
|
+
private readyPromise?;
|
|
53
|
+
private loadJssdk;
|
|
54
|
+
constructor(options: WechatJssdkOptions);
|
|
55
|
+
config(): Promise<void>;
|
|
56
|
+
ready(): Promise<void>;
|
|
57
|
+
error(): Promise<any>;
|
|
58
|
+
protected implement<Key extends keyof typeof wx | string>(key: Key, options?: any): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/index.d.ts
|
|
62
|
+
/**
|
|
63
|
+
* @description WechatJssdk Api 封装,与 [jssdk 文档](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html) 保持一致,主要以下改动
|
|
64
|
+
* @description 内置请求,读取 config 配置,初始化自动调用 wx.config
|
|
65
|
+
* @description 所有 api 的 promise 化处理(仅等待 wx.ready)
|
|
66
|
+
* @description 简易化初始化构建,config 处理
|
|
67
|
+
* @description 可指定加载 jssdk 版本(默认 1.3.0)
|
|
68
|
+
* @template `const wxJssdk = new WechatJssdk({env, config})`
|
|
69
|
+
*/
|
|
70
|
+
declare class WechatJssdk extends WechatJssdkHelper {
|
|
71
|
+
constructor(options: WechatJssdkOptions);
|
|
72
|
+
updateAppMessageShareData(options: WxType.IonMenuShareAppMessage): Promise<void>;
|
|
73
|
+
updateTimelineShareData(options: WxType.IonMenuShareAppMessage): Promise<void>;
|
|
74
|
+
addCard(): Promise<void>;
|
|
75
|
+
checkJsApi(options: WxType.IcheckJsApi): Promise<void>;
|
|
76
|
+
chooseCard(options: WxType.IchooseCard): Promise<void>;
|
|
77
|
+
chooseImage(options: WxType.IchooseImage): Promise<void>;
|
|
78
|
+
chooseWXPay(options: WxType.IchooseWXPay): Promise<void>;
|
|
79
|
+
closeWindow(): Promise<void>;
|
|
80
|
+
consumeAndShareCard(options: WxType.IconsumeAndShareCard): Promise<void>;
|
|
81
|
+
downloadImage(options: WxType.IdownloadImage): Promise<void>;
|
|
82
|
+
downloadVoice(options: WxType.IupdownloadVoice): Promise<void>;
|
|
83
|
+
getLocalImgData(options: WxType.IgetLocalImgData): Promise<void>;
|
|
84
|
+
getLocation(options: WxType.IgetLocation): Promise<void>;
|
|
85
|
+
getNetworkType(options: WxType.IgetNetworkType): Promise<void>;
|
|
86
|
+
hideAllNonBaseMenuItem(): Promise<void>;
|
|
87
|
+
hideMenuItems(options: WxType.IhideMenuItems): Promise<void>;
|
|
88
|
+
hideOptionMenu(): Promise<void>;
|
|
89
|
+
onMenuShareAppMessage(options: WxType.IonMenuShareAppMessage): Promise<void>;
|
|
90
|
+
onMenuShareQQ(options: WxType.IonMenuShareQQ): Promise<void>;
|
|
91
|
+
onMenuShareQZone(options: WxType.IonMenuShareQZone): Promise<void>;
|
|
92
|
+
onMenuShareTimeline(options: WxType.IonMenuShareTimeline): Promise<void>;
|
|
93
|
+
onMenuShareWeibo(options: WxType.IonMenuShareWeibo): Promise<void>;
|
|
94
|
+
onSearchBeacons(options: WxType.IonSearchBeacons): Promise<void>;
|
|
95
|
+
onVoicePlayEnd(options: WxType.IonVoicePlayEnd): Promise<void>;
|
|
96
|
+
onVoiceRecordEnd(options: WxType.IonVoiceRecordEnd): Promise<void>;
|
|
97
|
+
openCard(options: WxType.IopenCard): Promise<void>;
|
|
98
|
+
openLocation(options: WxType.IopenLocation): Promise<void>;
|
|
99
|
+
openProductSpecificView(options: WxType.IopenProductSpecificView): Promise<void>;
|
|
100
|
+
pauseVoice(options: WxType.IplaypausestopVoice): Promise<void>;
|
|
101
|
+
playVoice(options: WxType.IplaypausestopVoice): Promise<void>;
|
|
102
|
+
previewImage(options: WxType.IpreviewImage): Promise<void>;
|
|
103
|
+
scanQRCode(options: WxType.IscanQRCode): Promise<void>;
|
|
104
|
+
showAllNonBaseMenuItem(): Promise<void>;
|
|
105
|
+
showMenuItems(options: WxType.IshowMenuItems): Promise<void>;
|
|
106
|
+
showOptionMenu(): Promise<void>;
|
|
107
|
+
startRecord(): Promise<void>;
|
|
108
|
+
startSearchBeacons(options: WxType.IstartSearchBeacons): Promise<void>;
|
|
109
|
+
stopRecord(options: WxType.IstopRecord): Promise<void>;
|
|
110
|
+
stopSearchBeacons(options: WxType.IstopSearchBeacons): Promise<void>;
|
|
111
|
+
stopVoice(options: WxType.IplaypausestopVoice): Promise<void>;
|
|
112
|
+
translateVoice(options: WxType.ItranslateVoice): Promise<void>;
|
|
113
|
+
uploadImage(options: WxType.IuploadImage): Promise<void>;
|
|
114
|
+
uploadVoice(options: WxType.IupdownloadVoice): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { WechatJssdk };
|