qsh-webview-sdk 2.4.3 → 2.4.5
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/README.md +14 -6
- package/dist/qsh-webview-sdk.es.js +820 -738
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +1 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Ht = Object.defineProperty, zt = Object.defineProperties;
|
|
2
|
+
var Yt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Je = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var Xt = Object.prototype.hasOwnProperty, Zt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Te = (t, e, r) => e in t ? Ht(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, g = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Xt.call(e, r) && Te(t, r, e[r]);
|
|
8
8
|
if (Je)
|
|
9
9
|
for (var r of Je(e))
|
|
10
|
-
|
|
10
|
+
Zt.call(e, r) && Te(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
}, m = (t, e) =>
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, m = (t, e) => zt(t, Yt(e));
|
|
13
|
+
var B = (t, e, r) => Te(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
|
+
var I = (t, e, r) => new Promise((n, i) => {
|
|
15
15
|
var s = (u) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
l(r.next(u));
|
|
18
18
|
} catch (p) {
|
|
19
19
|
i(p);
|
|
20
20
|
}
|
|
21
21
|
}, o = (u) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
l(r.throw(u));
|
|
24
24
|
} catch (p) {
|
|
25
25
|
i(p);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, l = (u) => u.done ? n(u.value) : Promise.resolve(u.value).then(s, o);
|
|
28
|
+
l((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
30
|
function pe() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
@@ -33,7 +33,7 @@ function pe() {
|
|
|
33
33
|
function De() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function C() {
|
|
37
37
|
const t = pe();
|
|
38
38
|
if (!t) return !1;
|
|
39
39
|
if (t.__wxjs_environment === "miniprogram" || t.wx && t.wx.miniProgram)
|
|
@@ -41,7 +41,7 @@ function _() {
|
|
|
41
41
|
const e = De();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Me() {
|
|
45
45
|
const t = pe();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
@@ -75,31 +75,31 @@ function Z() {
|
|
|
75
75
|
}
|
|
76
76
|
return !1;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return Se() ? "uvue" : Re() ? "nvue" :
|
|
78
|
+
function Qt() {
|
|
79
|
+
return Se() ? "uvue" : Re() ? "nvue" : C() ? "weixin" : Z() ? "offline" : Me() ? "plus" : tt() ? "webview" : Oe() ? "UniApp" : "h5";
|
|
80
80
|
}
|
|
81
81
|
let Ee = null;
|
|
82
82
|
function H(t = !1) {
|
|
83
83
|
return Ee && !t || (Ee = {
|
|
84
|
-
isWeixinMiniProgram:
|
|
85
|
-
isAppPlus:
|
|
84
|
+
isWeixinMiniProgram: C(),
|
|
85
|
+
isAppPlus: Me(),
|
|
86
86
|
isNvue: Re(),
|
|
87
87
|
isUvue: Se(),
|
|
88
88
|
isUniApp: Oe(),
|
|
89
89
|
isHtml5Plus: Ue(),
|
|
90
90
|
isUniAppWebView: tt(),
|
|
91
91
|
isOfflineWebview: Z(),
|
|
92
|
-
type:
|
|
92
|
+
type: Qt()
|
|
93
93
|
}), Ee;
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const f = H(), T = {
|
|
96
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
97
97
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
98
98
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
99
99
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
100
100
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
101
101
|
};
|
|
102
|
-
class
|
|
102
|
+
class N extends Error {
|
|
103
103
|
/**
|
|
104
104
|
* 构造函数
|
|
105
105
|
* @param {string} type - 错误类型
|
|
@@ -108,7 +108,7 @@ class T extends Error {
|
|
|
108
108
|
* @param {Error} [originalError] - 原始错误对象
|
|
109
109
|
*/
|
|
110
110
|
constructor(e, r, n = {}, i = null) {
|
|
111
|
-
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
111
|
+
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* 转换为 JSON 格式
|
|
@@ -156,13 +156,13 @@ const S = class S {
|
|
|
156
156
|
*/
|
|
157
157
|
static handleApiError(e, r = {}) {
|
|
158
158
|
let n;
|
|
159
|
-
return e instanceof
|
|
160
|
-
|
|
159
|
+
return e instanceof N ? n = e : e instanceof Error ? n = new N(
|
|
160
|
+
T.API_CALL_FAILED,
|
|
161
161
|
e.message,
|
|
162
162
|
r,
|
|
163
163
|
e
|
|
164
|
-
) : n = new
|
|
165
|
-
|
|
164
|
+
) : n = new N(
|
|
165
|
+
T.API_CALL_FAILED,
|
|
166
166
|
String(e),
|
|
167
167
|
r
|
|
168
168
|
), S.logError(n), S.notifyCallbacks(n), n;
|
|
@@ -174,8 +174,8 @@ const S = class S {
|
|
|
174
174
|
* @returns {QshError} 错误对象
|
|
175
175
|
*/
|
|
176
176
|
static handlePlatformNotSupported(e, r) {
|
|
177
|
-
const n = new
|
|
178
|
-
|
|
177
|
+
const n = new N(
|
|
178
|
+
T.PLATFORM_NOT_SUPPORTED,
|
|
179
179
|
`API "${r}" is not supported on platform "${e}"`,
|
|
180
180
|
{ platformType: e, apiName: r }
|
|
181
181
|
);
|
|
@@ -187,8 +187,8 @@ const S = class S {
|
|
|
187
187
|
* @returns {QshError} 错误对象
|
|
188
188
|
*/
|
|
189
189
|
static handleBridgeNotReady(e) {
|
|
190
|
-
const r = new
|
|
191
|
-
|
|
190
|
+
const r = new N(
|
|
191
|
+
T.BRIDGE_NOT_READY,
|
|
192
192
|
`Bridge is not ready when calling "${e}"`,
|
|
193
193
|
{ apiName: e }
|
|
194
194
|
);
|
|
@@ -203,8 +203,8 @@ const S = class S {
|
|
|
203
203
|
* @returns {QshError} 错误对象
|
|
204
204
|
*/
|
|
205
205
|
static handleInvalidParameters(e, r, n, i) {
|
|
206
|
-
const s = new
|
|
207
|
-
|
|
206
|
+
const s = new N(
|
|
207
|
+
T.INVALID_PARAMETERS,
|
|
208
208
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
209
209
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
210
210
|
);
|
|
@@ -230,7 +230,7 @@ const S = class S {
|
|
|
230
230
|
* @returns {Promise} Promise 对象
|
|
231
231
|
*/
|
|
232
232
|
static safeExecuteAsync(n) {
|
|
233
|
-
return
|
|
233
|
+
return I(this, arguments, function* (e, r = {}) {
|
|
234
234
|
try {
|
|
235
235
|
return yield e();
|
|
236
236
|
} catch (i) {
|
|
@@ -282,17 +282,17 @@ const S = class S {
|
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
const
|
|
285
|
+
B(S, "isDebugMode", !1), B(S, "errorCallbacks", []);
|
|
286
|
+
let d = S;
|
|
287
|
+
const x = {
|
|
288
288
|
UNINITIALIZED: "uninitialized",
|
|
289
289
|
INITIALIZING: "initializing",
|
|
290
290
|
READY: "ready",
|
|
291
291
|
ERROR: "error"
|
|
292
292
|
};
|
|
293
|
-
class
|
|
293
|
+
class er {
|
|
294
294
|
constructor() {
|
|
295
|
-
this.state =
|
|
295
|
+
this.state = x.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* 获取当前状态
|
|
@@ -306,21 +306,21 @@ class tr {
|
|
|
306
306
|
* @returns {boolean} 是否就绪
|
|
307
307
|
*/
|
|
308
308
|
isReady() {
|
|
309
|
-
return this.state ===
|
|
309
|
+
return this.state === x.READY;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* 检查是否正在初始化
|
|
313
313
|
* @returns {boolean} 是否正在初始化
|
|
314
314
|
*/
|
|
315
315
|
isInitializing() {
|
|
316
|
-
return this.state ===
|
|
316
|
+
return this.state === x.INITIALIZING;
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
319
|
* 检查是否出错
|
|
320
320
|
* @returns {boolean} 是否出错
|
|
321
321
|
*/
|
|
322
322
|
hasError() {
|
|
323
|
-
return this.state ===
|
|
323
|
+
return this.state === x.ERROR;
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
326
|
* 获取初始化错误
|
|
@@ -344,10 +344,10 @@ class tr {
|
|
|
344
344
|
* @returns {Promise<void>} 初始化 Promise
|
|
345
345
|
*/
|
|
346
346
|
startInitialization(e) {
|
|
347
|
-
return
|
|
348
|
-
if (this.state !==
|
|
347
|
+
return I(this, null, function* () {
|
|
348
|
+
if (this.state !== x.UNINITIALIZED)
|
|
349
349
|
return this.waitForReady();
|
|
350
|
-
this.state =
|
|
350
|
+
this.state = x.INITIALIZING;
|
|
351
351
|
try {
|
|
352
352
|
yield e(), this.handleBridgeReady();
|
|
353
353
|
} catch (r) {
|
|
@@ -361,11 +361,11 @@ class tr {
|
|
|
361
361
|
* @private
|
|
362
362
|
*/
|
|
363
363
|
handleBridgeReady() {
|
|
364
|
-
this.state ===
|
|
364
|
+
this.state === x.INITIALIZING && (this.state = x.READY, this.readyCallbacks.forEach((e) => {
|
|
365
365
|
try {
|
|
366
366
|
e();
|
|
367
367
|
} catch (r) {
|
|
368
|
-
|
|
368
|
+
d.handleApiError(r, { context: "StateManager.handleBridgeReady" });
|
|
369
369
|
}
|
|
370
370
|
}), this.readyCallbacks = [], this.errorCallbacks = []);
|
|
371
371
|
}
|
|
@@ -375,11 +375,11 @@ class tr {
|
|
|
375
375
|
* @private
|
|
376
376
|
*/
|
|
377
377
|
handleInitializationError(e) {
|
|
378
|
-
this.state =
|
|
378
|
+
this.state = x.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
379
379
|
try {
|
|
380
380
|
r(e);
|
|
381
381
|
} catch (n) {
|
|
382
|
-
|
|
382
|
+
d.handleApiError(n, { context: "StateManager.handleInitializationError" });
|
|
383
383
|
}
|
|
384
384
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
385
385
|
}
|
|
@@ -387,7 +387,7 @@ class tr {
|
|
|
387
387
|
* 重置状态管理器(用于测试或重新初始化)
|
|
388
388
|
*/
|
|
389
389
|
reset() {
|
|
390
|
-
this.state =
|
|
390
|
+
this.state = x.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
393
|
* 添加状态变化监听器
|
|
@@ -402,7 +402,7 @@ class tr {
|
|
|
402
402
|
const n = () => {
|
|
403
403
|
this.state === e && r(this.state);
|
|
404
404
|
};
|
|
405
|
-
return e ===
|
|
405
|
+
return e === x.READY ? this.readyCallbacks.push(n) : e === x.ERROR && this.errorCallbacks.push(n), () => {
|
|
406
406
|
const i = this.readyCallbacks.indexOf(n);
|
|
407
407
|
i > -1 && this.readyCallbacks.splice(i, 1);
|
|
408
408
|
const s = this.errorCallbacks.indexOf(n);
|
|
@@ -423,7 +423,7 @@ class tr {
|
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
const Y = new
|
|
426
|
+
const Y = new er(), rt = () => Y.waitForReady(), tr = () => Y.isReady(), rr = () => Y.getState(), P = {
|
|
427
427
|
ERROR: 0,
|
|
428
428
|
WARN: 1,
|
|
429
429
|
INFO: 2,
|
|
@@ -491,7 +491,7 @@ const Y = new tr(), rt = () => Y.waitForReady(), rr = () => Y.isReady(), nr = ()
|
|
|
491
491
|
static log(e, r, n, ...i) {
|
|
492
492
|
if (!h.shouldLog(e, r))
|
|
493
493
|
return;
|
|
494
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), o = le[e],
|
|
494
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), o = le[e], l = r ? `[${r}]` : "", u = `${h.prefix} ${l} ${n}`, p = {
|
|
495
495
|
timestamp: s,
|
|
496
496
|
level: e,
|
|
497
497
|
levelName: o,
|
|
@@ -502,7 +502,7 @@ const Y = new tr(), rt = () => Y.waitForReady(), rr = () => Y.isReady(), nr = ()
|
|
|
502
502
|
if (h.addToHistory(p), typeof h.reporter == "function")
|
|
503
503
|
try {
|
|
504
504
|
h.reporter(p);
|
|
505
|
-
} catch (
|
|
505
|
+
} catch (M) {
|
|
506
506
|
}
|
|
507
507
|
h.outputToConsole(e, u, ...i);
|
|
508
508
|
}
|
|
@@ -653,11 +653,11 @@ const Y = new tr(), rt = () => Y.waitForReady(), rr = () => Y.isReady(), nr = ()
|
|
|
653
653
|
h.reporter = typeof e == "function" ? e : null;
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
let
|
|
656
|
+
B(h, "currentLevel", P.ERROR), // 生产环境默认只显示错误
|
|
657
|
+
B(h, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
658
|
+
B(h, "logHistory", []), // 日志历史(最多保留1000条)
|
|
659
|
+
B(h, "maxHistorySize", 1e3), B(h, "prefix", "[QSH-SDK]"), B(h, "reporter", null);
|
|
660
|
+
let L = h;
|
|
661
661
|
if (typeof window != "undefined") {
|
|
662
662
|
const t = window.location && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("192.168.")), e = window.location && (window.location.search.includes("debug=true") || window.location.search.includes("qsh_debug=1"));
|
|
663
663
|
let r = !1;
|
|
@@ -665,10 +665,10 @@ if (typeof window != "undefined") {
|
|
|
665
665
|
r = localStorage && localStorage.getItem("qsh_debug") === "true";
|
|
666
666
|
} catch (n) {
|
|
667
667
|
}
|
|
668
|
-
(t || e || r) &&
|
|
668
|
+
(t || e || r) && L.enableDevMode();
|
|
669
669
|
}
|
|
670
|
-
const A =
|
|
671
|
-
function
|
|
670
|
+
const A = L.createModuleLogger("Bridge"), E = L.createModuleLogger("Platform"), a = L.createModuleLogger("API"), D = L.createModuleLogger("State"), Ae = /complete|loaded|interactive/;
|
|
671
|
+
function nr(t) {
|
|
672
672
|
if (!Z()) return !1;
|
|
673
673
|
A.debug("检测到离线包环境,开始初始化");
|
|
674
674
|
const e = () => {
|
|
@@ -686,31 +686,31 @@ function ir(t) {
|
|
|
686
686
|
}
|
|
687
687
|
return !0;
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function ir(t) {
|
|
690
690
|
return Oe() || Ue() ? (A.debug("检测到 APP 环境,开始初始化"), window.__uniapp_x_postMessage || window.__uniapp_x_ || window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? (A.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)) : window.plus && Ae.test(document.readyState) ? (A.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : window.plus ? (A.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)) : Ae.test(document.readyState) ? setTimeout(t, 0) : document.addEventListener("DOMContentLoaded", t, { once: !0 }), !0) : !1;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function ar(t) {
|
|
693
693
|
return window.wx && window.wx.miniProgram ? (A.debug("检测到微信小程序环境,开始初始化"), window.WeixinJSBridge && window.WeixinJSBridge.invoke ? (A.debug("微信 JSBridge 已就绪,立即初始化"), setTimeout(t, 0)) : (A.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"), document.addEventListener("WeixinJSBridgeReady", t)), !0) : !1;
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return A.info("开始初始化 JSBridge"),
|
|
695
|
+
function sr(t) {
|
|
696
|
+
return A.info("开始初始化 JSBridge"), nr(t) ? (A.info("使用离线包环境初始化"), !0) : ir(t) ? (A.info("使用 APP 环境初始化"), !0) : ar(t) ? (A.info("使用微信小程序环境初始化"), !0) : (A.debug("使用默认 H5 环境初始化"), Ae.test(document.readyState) ? (A.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (A.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function or() {
|
|
699
699
|
return Y.waitForReady();
|
|
700
700
|
}
|
|
701
701
|
function nt() {
|
|
702
|
-
return Y.startInitialization(() =>
|
|
702
|
+
return Y.startInitialization(() => I(null, null, function* () {
|
|
703
703
|
return new Promise((t, e) => {
|
|
704
704
|
const r = () => {
|
|
705
705
|
t();
|
|
706
706
|
}, n = (i) => {
|
|
707
|
-
const s =
|
|
707
|
+
const s = d.handleApiError(i, {
|
|
708
708
|
context: "bridge initialization"
|
|
709
709
|
});
|
|
710
710
|
e(s);
|
|
711
711
|
};
|
|
712
712
|
try {
|
|
713
|
-
|
|
713
|
+
sr(() => {
|
|
714
714
|
r();
|
|
715
715
|
});
|
|
716
716
|
} catch (i) {
|
|
@@ -719,7 +719,7 @@ function nt() {
|
|
|
719
719
|
});
|
|
720
720
|
}));
|
|
721
721
|
}
|
|
722
|
-
const
|
|
722
|
+
const b = {
|
|
723
723
|
UNINITIALIZED: "uninitialized",
|
|
724
724
|
CONFIGURING: "configuring",
|
|
725
725
|
CONFIGURED: "configured",
|
|
@@ -728,47 +728,80 @@ const N = {
|
|
|
728
728
|
function K() {
|
|
729
729
|
return typeof window == "undefined" || !window.wx ? !1 : typeof window.wx.config == "function" && typeof window.wx.ready == "function" && typeof window.wx.error == "function";
|
|
730
730
|
}
|
|
731
|
-
class
|
|
731
|
+
class cr {
|
|
732
732
|
constructor() {
|
|
733
|
-
this.state =
|
|
733
|
+
this.state = b.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.configVersion = 0, this.configuredConfigKey = null, this.runtimeConfig = {
|
|
734
734
|
clientId: null,
|
|
735
|
-
isProd: !1
|
|
735
|
+
isProd: !1,
|
|
736
|
+
debug: !1,
|
|
737
|
+
url: ""
|
|
736
738
|
}, this.CONFIG_API_URL = this.getConfigApiUrl(this.runtimeConfig.isProd), this.DEFAULT_JS_API_LIST = ["chooseImage", "uploadImage", "previewImage", "downloadImage", "getLocalImgData", "scanQRCode", "getLocation", "openLocation", "updateAppMessageShareData", "updateTimelineShareData"], this.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
737
739
|
}
|
|
738
740
|
configure(e = {}) {
|
|
739
741
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
740
|
-
throw new
|
|
741
|
-
|
|
742
|
+
throw new N(
|
|
743
|
+
T.INVALID_PARAMETERS,
|
|
742
744
|
"config参数异常",
|
|
743
745
|
{ config: e }
|
|
744
746
|
);
|
|
745
747
|
if (!Object.prototype.hasOwnProperty.call(e, "clientId"))
|
|
746
748
|
throw this.createMissingClientIdError();
|
|
747
749
|
if (typeof e.clientId != "string" || !e.clientId.trim())
|
|
748
|
-
throw new
|
|
749
|
-
|
|
750
|
+
throw new N(
|
|
751
|
+
T.INVALID_PARAMETERS,
|
|
750
752
|
"clientId参数异常",
|
|
751
753
|
{ clientId: e.clientId }
|
|
752
754
|
);
|
|
753
755
|
if (Object.prototype.hasOwnProperty.call(e, "isProd") && typeof e.isProd != "boolean")
|
|
754
|
-
throw new
|
|
755
|
-
|
|
756
|
+
throw new N(
|
|
757
|
+
T.INVALID_PARAMETERS,
|
|
756
758
|
"isProd参数异常",
|
|
757
759
|
{ isProd: e.isProd }
|
|
758
760
|
);
|
|
759
|
-
|
|
761
|
+
if (Object.prototype.hasOwnProperty.call(e, "debug") && typeof e.debug != "boolean")
|
|
762
|
+
throw new N(
|
|
763
|
+
T.INVALID_PARAMETERS,
|
|
764
|
+
"debug参数异常",
|
|
765
|
+
{ debug: e.debug }
|
|
766
|
+
);
|
|
767
|
+
if (Object.prototype.hasOwnProperty.call(e, "url") && typeof e.url != "string")
|
|
768
|
+
throw new N(
|
|
769
|
+
T.INVALID_PARAMETERS,
|
|
770
|
+
"url参数异常",
|
|
771
|
+
{ url: e.url }
|
|
772
|
+
);
|
|
773
|
+
const r = e.clientId.trim(), n = e.isProd === !0, i = n ? !1 : e.debug === !0, s = typeof e.url == "string" ? e.url.trim() : "", o = r !== this.runtimeConfig.clientId || n !== this.runtimeConfig.isProd || i !== this.runtimeConfig.debug || s !== this.runtimeConfig.url;
|
|
760
774
|
return this.runtimeConfig = m(g({}, this.runtimeConfig), {
|
|
761
775
|
clientId: r,
|
|
762
|
-
isProd: n
|
|
763
|
-
|
|
776
|
+
isProd: n,
|
|
777
|
+
debug: i,
|
|
778
|
+
url: s
|
|
779
|
+
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === b.ERROR || o && (this.state === b.CONFIGURING || this.state === b.CONFIGURED)) && this.reset({ preserveCallbacks: !0 }), E.info("Updated Weixin runtime config", {
|
|
764
780
|
clientId: this.runtimeConfig.clientId,
|
|
765
781
|
isProd: this.runtimeConfig.isProd,
|
|
782
|
+
debug: this.runtimeConfig.debug,
|
|
783
|
+
url: this.runtimeConfig.url,
|
|
766
784
|
configApiUrl: this.CONFIG_API_URL
|
|
767
785
|
}), this.getRuntimeConfig();
|
|
768
786
|
}
|
|
769
787
|
getRuntimeConfig() {
|
|
770
788
|
return g({}, this.runtimeConfig);
|
|
771
789
|
}
|
|
790
|
+
getEffectiveConfigUrl(e = {}) {
|
|
791
|
+
const { requireWindow: r = !1 } = e;
|
|
792
|
+
return this.runtimeConfig.url ? this.runtimeConfig.url : r ? this.getCurrentPageUrl() : typeof window == "undefined" || !window.location ? "" : this.getCurrentPageUrl();
|
|
793
|
+
}
|
|
794
|
+
getRuntimeConfigKey() {
|
|
795
|
+
return JSON.stringify({
|
|
796
|
+
clientId: this.runtimeConfig.clientId,
|
|
797
|
+
isProd: this.runtimeConfig.isProd,
|
|
798
|
+
debug: this.runtimeConfig.debug,
|
|
799
|
+
url: this.getEffectiveConfigUrl()
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
isCurrentConfigRun(e, r) {
|
|
803
|
+
return e === this.configVersion && r === this.getRuntimeConfigKey();
|
|
804
|
+
}
|
|
772
805
|
hasClientId() {
|
|
773
806
|
return typeof this.runtimeConfig.clientId == "string" && this.runtimeConfig.clientId.length > 0;
|
|
774
807
|
}
|
|
@@ -776,8 +809,8 @@ class ur {
|
|
|
776
809
|
return this.isTestMode() || this.hasClientId();
|
|
777
810
|
}
|
|
778
811
|
createMissingClientIdError() {
|
|
779
|
-
return new
|
|
780
|
-
|
|
812
|
+
return new N(
|
|
813
|
+
T.INVALID_PARAMETERS,
|
|
781
814
|
"clientId错误",
|
|
782
815
|
{ field: "clientId" }
|
|
783
816
|
);
|
|
@@ -807,32 +840,32 @@ class ur {
|
|
|
807
840
|
* @private
|
|
808
841
|
*/
|
|
809
842
|
fetchWeixinConfig() {
|
|
810
|
-
return
|
|
811
|
-
const e = this.
|
|
843
|
+
return I(this, null, function* () {
|
|
844
|
+
const e = this.getEffectiveConfigUrl({ requireWindow: !0 });
|
|
812
845
|
if (this.isTestMode())
|
|
813
|
-
return
|
|
846
|
+
return E.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
814
847
|
if (!this.hasClientId())
|
|
815
848
|
throw this.createMissingClientIdError();
|
|
816
849
|
const r = this.getConfigApiUrl(this.runtimeConfig.isProd);
|
|
817
850
|
this.CONFIG_API_URL = r;
|
|
818
851
|
const n = `${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;
|
|
819
|
-
|
|
852
|
+
E.debug("请求微信配置", { url: n });
|
|
820
853
|
try {
|
|
821
854
|
const i = yield fetch(n);
|
|
822
855
|
if (!i.ok)
|
|
823
856
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
824
857
|
const s = yield i.json();
|
|
825
|
-
if (
|
|
858
|
+
if (E.debug("微信配置响应", s), !s.success || s.code !== 200)
|
|
826
859
|
throw new Error(`配置获取失败: ${s.message || "未知错误"}`);
|
|
827
860
|
const { data: o } = s;
|
|
828
861
|
if (!o || !o.appId || !o.timestamp || !o.nonceStr || !o.signature)
|
|
829
862
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
830
863
|
return o;
|
|
831
864
|
} catch (i) {
|
|
832
|
-
if (
|
|
833
|
-
return
|
|
834
|
-
throw new
|
|
835
|
-
|
|
865
|
+
if (E.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
866
|
+
return E.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
867
|
+
throw new N(
|
|
868
|
+
T.NETWORK_ERROR,
|
|
836
869
|
`获取微信配置失败: ${i.message}`,
|
|
837
870
|
{ url: n, originalError: i }
|
|
838
871
|
);
|
|
@@ -882,38 +915,41 @@ class ur {
|
|
|
882
915
|
* @param {Object} configData - 配置数据
|
|
883
916
|
* @private
|
|
884
917
|
*/
|
|
885
|
-
executeWeixinConfig(e) {
|
|
918
|
+
executeWeixinConfig(e, r, n) {
|
|
886
919
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
887
|
-
|
|
888
|
-
this.handleConfigSuccess();
|
|
920
|
+
E.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
921
|
+
this.handleConfigSuccess(r, n);
|
|
889
922
|
}, 100);
|
|
890
923
|
return;
|
|
891
924
|
}
|
|
892
925
|
if (!K())
|
|
893
926
|
throw new Error("微信JS-SDK未加载");
|
|
894
|
-
const
|
|
895
|
-
debug:
|
|
896
|
-
// 生产环境关闭调试
|
|
927
|
+
const i = {
|
|
928
|
+
debug: this.runtimeConfig.debug,
|
|
897
929
|
appId: e.appId,
|
|
898
930
|
timestamp: parseInt(e.timestamp),
|
|
899
931
|
nonceStr: e.nonceStr,
|
|
900
932
|
signature: e.signature,
|
|
901
933
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
902
934
|
};
|
|
903
|
-
|
|
935
|
+
E.info("执行微信配置", i), window.wx.ready(() => this.handleConfigSuccess(r, n)), window.wx.error((s) => this.handleConfigError(s, r, n)), window.wx.config(i);
|
|
904
936
|
}
|
|
905
937
|
/**
|
|
906
938
|
* 处理配置成功
|
|
907
939
|
* @private
|
|
908
940
|
*/
|
|
909
|
-
handleConfigSuccess() {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
941
|
+
handleConfigSuccess(e = this.configVersion, r = this.getRuntimeConfigKey()) {
|
|
942
|
+
if (!this.isCurrentConfigRun(e, r)) {
|
|
943
|
+
E.debug("忽略过期的微信配置成功回调");
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
E.info("微信配置成功"), this.state = b.CONFIGURED, this.configuredConfigKey = r, this.lastError = null, this.configPromise = null;
|
|
947
|
+
const n = [...this.readyCallbacks];
|
|
948
|
+
this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
913
949
|
try {
|
|
914
|
-
|
|
915
|
-
} catch (
|
|
916
|
-
|
|
950
|
+
i();
|
|
951
|
+
} catch (s) {
|
|
952
|
+
d.handleApiError(s, { context: "WeixinConfigManager.handleConfigSuccess" });
|
|
917
953
|
}
|
|
918
954
|
});
|
|
919
955
|
}
|
|
@@ -922,21 +958,25 @@ class ur {
|
|
|
922
958
|
* @param {Object} res - 微信返回的错误信息
|
|
923
959
|
* @private
|
|
924
960
|
*/
|
|
925
|
-
handleConfigError(e) {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
961
|
+
handleConfigError(e, r = this.configVersion, n = this.getRuntimeConfigKey()) {
|
|
962
|
+
if (!this.isCurrentConfigRun(r, n)) {
|
|
963
|
+
E.debug("忽略过期的微信配置错误回调", e);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
const i = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
967
|
+
E.error(i, e);
|
|
968
|
+
const s = new N(
|
|
969
|
+
T.API_CALL_FAILED,
|
|
970
|
+
i,
|
|
931
971
|
{ weixinErrorResponse: e }
|
|
932
972
|
);
|
|
933
|
-
this.state =
|
|
934
|
-
const
|
|
935
|
-
this.readyCallbacks = [], this.errorCallbacks = [],
|
|
973
|
+
this.state = b.ERROR, this.lastError = s, this.configPromise = null;
|
|
974
|
+
const o = [...this.errorCallbacks];
|
|
975
|
+
this.readyCallbacks = [], this.errorCallbacks = [], o.forEach((l) => {
|
|
936
976
|
try {
|
|
937
|
-
s
|
|
938
|
-
} catch (
|
|
939
|
-
|
|
977
|
+
l(s);
|
|
978
|
+
} catch (u) {
|
|
979
|
+
d.handleApiError(u, { context: "WeixinConfigManager.handleConfigError" });
|
|
940
980
|
}
|
|
941
981
|
});
|
|
942
982
|
}
|
|
@@ -945,8 +985,18 @@ class ur {
|
|
|
945
985
|
* @returns {Promise<void>} 配置完成的Promise
|
|
946
986
|
*/
|
|
947
987
|
autoConfig() {
|
|
948
|
-
return
|
|
949
|
-
|
|
988
|
+
return I(this, null, function* () {
|
|
989
|
+
if (!this.hasRequiredConfig())
|
|
990
|
+
return E.warn("clientId为空,等待qsh.config({ clientId })"), Promise.resolve();
|
|
991
|
+
if (this.isReady())
|
|
992
|
+
return Promise.resolve();
|
|
993
|
+
if (this.state === b.CONFIGURED && this.reset({ preserveCallbacks: !0 }), this.state === b.ERROR)
|
|
994
|
+
return Promise.reject(this.lastError);
|
|
995
|
+
if (this.configPromise)
|
|
996
|
+
return this.configPromise;
|
|
997
|
+
this.state = b.CONFIGURING;
|
|
998
|
+
const e = this.configVersion, r = this.getRuntimeConfigKey();
|
|
999
|
+
return this.configPromise = this.performAutoConfig(e, r), this.configPromise;
|
|
950
1000
|
});
|
|
951
1001
|
}
|
|
952
1002
|
/**
|
|
@@ -954,36 +1004,44 @@ class ur {
|
|
|
954
1004
|
* @returns {Promise<void>}
|
|
955
1005
|
* @private
|
|
956
1006
|
*/
|
|
957
|
-
performAutoConfig() {
|
|
958
|
-
return
|
|
1007
|
+
performAutoConfig(e, r) {
|
|
1008
|
+
return I(this, null, function* () {
|
|
959
1009
|
try {
|
|
960
1010
|
if (typeof window == "undefined")
|
|
961
1011
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
962
1012
|
if (!K())
|
|
963
1013
|
throw new Error("微信JS-SDK未加载,无法执行配置");
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1014
|
+
const n = yield this.fetchWeixinConfig();
|
|
1015
|
+
if (!this.isCurrentConfigRun(e, r)) {
|
|
1016
|
+
E.debug("忽略过期的微信配置响应");
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
return this.executeWeixinConfig(n, e, r), yield new Promise((i, s) => {
|
|
1020
|
+
if (this.isReady()) {
|
|
1021
|
+
i();
|
|
968
1022
|
return;
|
|
969
1023
|
}
|
|
970
|
-
if (this.state ===
|
|
971
|
-
|
|
1024
|
+
if (this.state === b.ERROR) {
|
|
1025
|
+
s(this.lastError);
|
|
972
1026
|
return;
|
|
973
1027
|
}
|
|
974
|
-
this.readyCallbacks.push(
|
|
1028
|
+
this.readyCallbacks.push(i), this.errorCallbacks.push(s);
|
|
975
1029
|
});
|
|
976
|
-
} catch (
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1030
|
+
} catch (n) {
|
|
1031
|
+
if (!this.isCurrentConfigRun(e, r)) {
|
|
1032
|
+
E.debug("忽略过期的微信配置异常", n);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const i = n instanceof N ? n : d.handleApiError(n, { context: "WeixinConfigManager.performAutoConfig" });
|
|
1036
|
+
this.state = b.ERROR, this.lastError = i, this.configPromise = null;
|
|
1037
|
+
const s = [...this.errorCallbacks];
|
|
1038
|
+
throw this.readyCallbacks = [], this.errorCallbacks = [], s.forEach((o) => {
|
|
981
1039
|
try {
|
|
982
|
-
i
|
|
983
|
-
} catch (
|
|
984
|
-
|
|
1040
|
+
o(i);
|
|
1041
|
+
} catch (l) {
|
|
1042
|
+
d.handleApiError(l, { context: "WeixinConfigManager.performAutoConfig.errorCallback" });
|
|
985
1043
|
}
|
|
986
|
-
}),
|
|
1044
|
+
}), i;
|
|
987
1045
|
}
|
|
988
1046
|
});
|
|
989
1047
|
}
|
|
@@ -992,16 +1050,16 @@ class ur {
|
|
|
992
1050
|
* @returns {Promise<void>} 配置完成的Promise
|
|
993
1051
|
*/
|
|
994
1052
|
waitForReady() {
|
|
995
|
-
return this.state ===
|
|
1053
|
+
return this.isReady() ? Promise.resolve() : (this.state === b.CONFIGURED && this.reset({ preserveCallbacks: !0 }), this.state === b.ERROR ? Promise.reject(this.lastError) : this.hasRequiredConfig() ? this.state === b.UNINITIALIZED ? this.autoConfig() : new Promise((e, r) => {
|
|
996
1054
|
this.readyCallbacks.push(e), this.errorCallbacks.push(r);
|
|
997
|
-
}) : Promise.reject(this.createMissingClientIdError());
|
|
1055
|
+
}) : Promise.reject(this.createMissingClientIdError()));
|
|
998
1056
|
}
|
|
999
1057
|
/**
|
|
1000
1058
|
* 检查配置状态
|
|
1001
1059
|
* @returns {boolean} 是否已配置
|
|
1002
1060
|
*/
|
|
1003
1061
|
isReady() {
|
|
1004
|
-
return this.state ===
|
|
1062
|
+
return this.state === b.CONFIGURED && this.configuredConfigKey === this.getRuntimeConfigKey();
|
|
1005
1063
|
}
|
|
1006
1064
|
/**
|
|
1007
1065
|
* 获取当前状态
|
|
@@ -1020,8 +1078,9 @@ class ur {
|
|
|
1020
1078
|
/**
|
|
1021
1079
|
* 重置配置管理器(用于重试或测试)
|
|
1022
1080
|
*/
|
|
1023
|
-
reset() {
|
|
1024
|
-
|
|
1081
|
+
reset(e = {}) {
|
|
1082
|
+
const { preserveCallbacks: r = !1 } = e;
|
|
1083
|
+
this.configVersion += 1, this.state = b.UNINITIALIZED, this.configPromise = null, r || (this.readyCallbacks = [], this.errorCallbacks = []), this.lastError = null, this.configuredConfigKey = null, E.debug("微信配置管理器已重置");
|
|
1025
1084
|
}
|
|
1026
1085
|
/**
|
|
1027
1086
|
* 获取配置统计信息
|
|
@@ -1034,30 +1093,35 @@ class ur {
|
|
|
1034
1093
|
errorCallbacksCount: this.errorCallbacks.length,
|
|
1035
1094
|
hasConfigPromise: !!this.configPromise,
|
|
1036
1095
|
hasLastError: !!this.lastError,
|
|
1096
|
+
configVersion: this.configVersion,
|
|
1097
|
+
configuredConfigKey: this.configuredConfigKey,
|
|
1037
1098
|
configApiUrl: this.CONFIG_API_URL,
|
|
1038
1099
|
clientId: this.runtimeConfig.clientId,
|
|
1039
1100
|
isProd: this.runtimeConfig.isProd,
|
|
1101
|
+
debug: this.runtimeConfig.debug,
|
|
1102
|
+
url: this.runtimeConfig.url,
|
|
1103
|
+
effectiveUrl: this.getEffectiveConfigUrl(),
|
|
1040
1104
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
1041
1105
|
};
|
|
1042
1106
|
}
|
|
1043
1107
|
}
|
|
1044
|
-
const
|
|
1108
|
+
const v = new cr();
|
|
1045
1109
|
let re = !1, ge = !1, U = null, Pe = !1;
|
|
1046
|
-
function
|
|
1110
|
+
function ur(t) {
|
|
1047
1111
|
return new Promise((e) => {
|
|
1048
1112
|
let r = !1, n = null;
|
|
1049
|
-
const i = (
|
|
1113
|
+
const i = (l) => I(null, null, function* () {
|
|
1050
1114
|
if (!r) {
|
|
1051
|
-
if (r = !0, n && clearTimeout(n), re = !1, ge =
|
|
1115
|
+
if (r = !0, n && clearTimeout(n), re = !1, ge = l, l)
|
|
1052
1116
|
try {
|
|
1053
1117
|
yield it();
|
|
1054
1118
|
} catch (u) {
|
|
1055
|
-
|
|
1119
|
+
E.error("微信配置失败,将使用消息桥作为后备", u);
|
|
1056
1120
|
}
|
|
1057
1121
|
e();
|
|
1058
1122
|
}
|
|
1059
1123
|
}), s = () => i(K()), o = () => {
|
|
1060
|
-
|
|
1124
|
+
E.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"), i(!1);
|
|
1061
1125
|
};
|
|
1062
1126
|
t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", o, { once: !0 }), setTimeout(() => {
|
|
1063
1127
|
K() && s();
|
|
@@ -1067,14 +1131,14 @@ function lr(t) {
|
|
|
1067
1131
|
});
|
|
1068
1132
|
}
|
|
1069
1133
|
function We() {
|
|
1070
|
-
return
|
|
1134
|
+
return I(this, arguments, function* (t = {}) {
|
|
1071
1135
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1072
1136
|
if (yield at({ force: e }), !K())
|
|
1073
1137
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
1074
|
-
r &&
|
|
1138
|
+
r && fr();
|
|
1075
1139
|
});
|
|
1076
1140
|
}
|
|
1077
|
-
function
|
|
1141
|
+
function lr(t = !1) {
|
|
1078
1142
|
if (typeof window == "undefined") return !1;
|
|
1079
1143
|
if (K())
|
|
1080
1144
|
return ge = !0, !1;
|
|
@@ -1083,18 +1147,18 @@ function fr(t = !1) {
|
|
|
1083
1147
|
const e = navigator.userAgent || "", r = /micromessenger/i.test(e), n = /miniProgram/i.test(e), i = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram", s = !!(window.wx && window.wx.miniProgram);
|
|
1084
1148
|
return r && (n || i || s);
|
|
1085
1149
|
}
|
|
1086
|
-
function
|
|
1087
|
-
|
|
1150
|
+
function fr() {
|
|
1151
|
+
v.getState() === "error" && (v.reset(), Pe = !1);
|
|
1088
1152
|
}
|
|
1089
1153
|
function it() {
|
|
1090
|
-
return
|
|
1154
|
+
return I(this, null, function* () {
|
|
1091
1155
|
if (Pe)
|
|
1092
|
-
return
|
|
1093
|
-
Pe = !0,
|
|
1156
|
+
return v.waitForReady();
|
|
1157
|
+
Pe = !0, E.info("开始自动配置微信JS-SDK");
|
|
1094
1158
|
try {
|
|
1095
|
-
yield
|
|
1159
|
+
yield v.autoConfig(), E.info("微信JS-SDK自动配置完成");
|
|
1096
1160
|
} catch (t) {
|
|
1097
|
-
|
|
1161
|
+
E.error("微信JS-SDK自动配置失败", t);
|
|
1098
1162
|
}
|
|
1099
1163
|
});
|
|
1100
1164
|
}
|
|
@@ -1105,65 +1169,65 @@ function at(t = {}) {
|
|
|
1105
1169
|
if (K())
|
|
1106
1170
|
return ge = !0, Promise.resolve();
|
|
1107
1171
|
const r = document.getElementById("weixin-jssdk");
|
|
1108
|
-
return r ? U || (re = !0, U =
|
|
1172
|
+
return r ? U || (re = !0, U = ur(r).finally(() => {
|
|
1109
1173
|
U = null;
|
|
1110
|
-
}), U) :
|
|
1174
|
+
}), U) : lr(e) ? U || (U = new Promise((n) => {
|
|
1111
1175
|
re = !0;
|
|
1112
1176
|
try {
|
|
1113
1177
|
const i = document.createElement("script");
|
|
1114
1178
|
i.id = "weixin-jssdk", i.type = "text/javascript", i.async = !0, i.src = "https://res.wx.qq.com/open/js/jweixin-1.6.2.js", i.onload = function() {
|
|
1115
|
-
return
|
|
1116
|
-
ge = !0, re = !1,
|
|
1179
|
+
return I(this, null, function* () {
|
|
1180
|
+
ge = !0, re = !1, E.info("微信 JS-SDK 已自动加载");
|
|
1117
1181
|
try {
|
|
1118
1182
|
yield it();
|
|
1119
1183
|
} catch (o) {
|
|
1120
|
-
|
|
1184
|
+
E.error("微信配置失败,将使用消息桥作为后备", o);
|
|
1121
1185
|
}
|
|
1122
1186
|
n();
|
|
1123
1187
|
});
|
|
1124
1188
|
}, i.onerror = function() {
|
|
1125
|
-
re = !1,
|
|
1189
|
+
re = !1, E.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), n();
|
|
1126
1190
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(i);
|
|
1127
1191
|
} catch (i) {
|
|
1128
|
-
re = !1,
|
|
1192
|
+
re = !1, E.error("注入微信 JS-SDK 失败", i), n();
|
|
1129
1193
|
}
|
|
1130
1194
|
}).finally(() => {
|
|
1131
1195
|
U = null;
|
|
1132
1196
|
}), U) : Promise.resolve();
|
|
1133
1197
|
}
|
|
1134
1198
|
function Q() {
|
|
1135
|
-
return We({ force: !0, recoverFromError: !0 }).then(() =>
|
|
1199
|
+
return We({ force: !0, recoverFromError: !0 }).then(() => v.waitForReady());
|
|
1136
1200
|
}
|
|
1137
1201
|
function He(t = {}) {
|
|
1138
|
-
const e =
|
|
1202
|
+
const e = v.configure(t);
|
|
1139
1203
|
return typeof window == "undefined" || We({
|
|
1140
1204
|
force: !0,
|
|
1141
|
-
recoverFromError:
|
|
1205
|
+
recoverFromError: v.getState() === "error"
|
|
1142
1206
|
}).then(() => {
|
|
1143
|
-
if (!
|
|
1144
|
-
return
|
|
1145
|
-
|
|
1207
|
+
if (!v.isReady())
|
|
1208
|
+
return v.waitForReady().catch((r) => {
|
|
1209
|
+
E.error("Failed to auto-configure Weixin after qsh.config()", r);
|
|
1146
1210
|
});
|
|
1147
|
-
window.wx && !K() &&
|
|
1211
|
+
window.wx && !K() && E.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置");
|
|
1148
1212
|
}).catch((r) => {
|
|
1149
|
-
|
|
1213
|
+
E.error("Failed to preload Weixin JS-SDK", r);
|
|
1150
1214
|
}), e;
|
|
1151
1215
|
}
|
|
1152
1216
|
function oe() {
|
|
1153
|
-
return
|
|
1217
|
+
return v.isReady();
|
|
1154
1218
|
}
|
|
1155
|
-
function
|
|
1156
|
-
return
|
|
1219
|
+
function dr() {
|
|
1220
|
+
return v.getState();
|
|
1157
1221
|
}
|
|
1158
1222
|
function ve() {
|
|
1159
|
-
return
|
|
1223
|
+
return v;
|
|
1160
1224
|
}
|
|
1161
|
-
function
|
|
1162
|
-
return
|
|
1163
|
-
return
|
|
1225
|
+
function gr() {
|
|
1226
|
+
return I(this, null, function* () {
|
|
1227
|
+
return E.info("手动重试微信配置"), v.reset(), Pe = !1, yield We({ force: !0 }), v.waitForReady();
|
|
1164
1228
|
});
|
|
1165
1229
|
}
|
|
1166
|
-
class
|
|
1230
|
+
class hr {
|
|
1167
1231
|
constructor() {
|
|
1168
1232
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], a.debug("插件管理器已初始化");
|
|
1169
1233
|
}
|
|
@@ -1175,7 +1239,7 @@ class pr {
|
|
|
1175
1239
|
* pluginManager.register(imagePlugin)
|
|
1176
1240
|
*/
|
|
1177
1241
|
register(e) {
|
|
1178
|
-
return
|
|
1242
|
+
return d.safeExecute(() => {
|
|
1179
1243
|
this.validatePlugin(e);
|
|
1180
1244
|
const { name: r, version: n } = e;
|
|
1181
1245
|
if (this.plugins.has(r)) {
|
|
@@ -1215,8 +1279,8 @@ class pr {
|
|
|
1215
1279
|
* await pluginManager.install('image', qsh)
|
|
1216
1280
|
*/
|
|
1217
1281
|
install(e, r) {
|
|
1218
|
-
return
|
|
1219
|
-
return
|
|
1282
|
+
return I(this, null, function* () {
|
|
1283
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
1220
1284
|
if (!this.plugins.has(e))
|
|
1221
1285
|
throw new Error(`插件 ${e} 未注册`);
|
|
1222
1286
|
if (this.installed.has(e)) {
|
|
@@ -1245,8 +1309,8 @@ class pr {
|
|
|
1245
1309
|
* await pluginManager.uninstall('image', qsh)
|
|
1246
1310
|
*/
|
|
1247
1311
|
uninstall(e, r) {
|
|
1248
|
-
return
|
|
1249
|
-
return
|
|
1312
|
+
return I(this, null, function* () {
|
|
1313
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
1250
1314
|
if (!this.installed.has(e)) {
|
|
1251
1315
|
a.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1252
1316
|
return;
|
|
@@ -1267,7 +1331,7 @@ class pr {
|
|
|
1267
1331
|
* @returns {Promise<void>}
|
|
1268
1332
|
*/
|
|
1269
1333
|
uninstallAll(e) {
|
|
1270
|
-
return
|
|
1334
|
+
return I(this, null, function* () {
|
|
1271
1335
|
const r = [...this.installOrder].reverse();
|
|
1272
1336
|
for (const n of r)
|
|
1273
1337
|
yield this.uninstall(n, e);
|
|
@@ -1294,7 +1358,7 @@ class pr {
|
|
|
1294
1358
|
* await pluginManager.installAll(['image', 'location'], qsh)
|
|
1295
1359
|
*/
|
|
1296
1360
|
installAll(e, r) {
|
|
1297
|
-
return
|
|
1361
|
+
return I(this, null, function* () {
|
|
1298
1362
|
if (!Array.isArray(e))
|
|
1299
1363
|
throw new Error("names 必须是数组");
|
|
1300
1364
|
for (const n of e)
|
|
@@ -1356,8 +1420,8 @@ class pr {
|
|
|
1356
1420
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1357
1421
|
}
|
|
1358
1422
|
}
|
|
1359
|
-
const fe = new
|
|
1360
|
-
class
|
|
1423
|
+
const fe = new hr();
|
|
1424
|
+
class pr {
|
|
1361
1425
|
constructor() {
|
|
1362
1426
|
this.requestInterceptors = [], this.responseInterceptors = [], a.debug("拦截器链已初始化");
|
|
1363
1427
|
}
|
|
@@ -1416,7 +1480,7 @@ class mr {
|
|
|
1416
1480
|
* @private
|
|
1417
1481
|
*/
|
|
1418
1482
|
runRequest(e) {
|
|
1419
|
-
return
|
|
1483
|
+
return I(this, null, function* () {
|
|
1420
1484
|
let r = g({}, e);
|
|
1421
1485
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1422
1486
|
if (r.abort) {
|
|
@@ -1442,7 +1506,7 @@ class mr {
|
|
|
1442
1506
|
* @private
|
|
1443
1507
|
*/
|
|
1444
1508
|
runResponse(e, r) {
|
|
1445
|
-
return
|
|
1509
|
+
return I(this, null, function* () {
|
|
1446
1510
|
let n = e;
|
|
1447
1511
|
for (const { fn: i } of this.responseInterceptors)
|
|
1448
1512
|
try {
|
|
@@ -1471,7 +1535,7 @@ class mr {
|
|
|
1471
1535
|
};
|
|
1472
1536
|
}
|
|
1473
1537
|
}
|
|
1474
|
-
const z = new
|
|
1538
|
+
const z = new pr(), mr = {
|
|
1475
1539
|
/**
|
|
1476
1540
|
* 请求日志
|
|
1477
1541
|
*/
|
|
@@ -1526,19 +1590,19 @@ const z = new mr(), wr = {
|
|
|
1526
1590
|
q.metrics.clear();
|
|
1527
1591
|
}
|
|
1528
1592
|
};
|
|
1529
|
-
function
|
|
1593
|
+
function wr(t = {}) {
|
|
1530
1594
|
const {
|
|
1531
1595
|
maxRetries: e = 3,
|
|
1532
1596
|
retryDelay: r = 1e3,
|
|
1533
1597
|
shouldRetry: n = (i) => !i.success
|
|
1534
1598
|
} = t;
|
|
1535
1599
|
return {
|
|
1536
|
-
response: (i, s) =>
|
|
1600
|
+
response: (i, s) => I(null, null, function* () {
|
|
1537
1601
|
return s.retryCount || (s.retryCount = 0), n(i) && s.retryCount < e && (s.retryCount++, a.warn(`API 调用失败,第 ${s.retryCount} 次重试: ${s.apiName}`), yield new Promise((o) => setTimeout(o, r)), i.shouldRetry = !0, i.retryContext = s), i;
|
|
1538
1602
|
})
|
|
1539
1603
|
};
|
|
1540
1604
|
}
|
|
1541
|
-
function
|
|
1605
|
+
function Er(t = {}) {
|
|
1542
1606
|
return {
|
|
1543
1607
|
request: (e) => {
|
|
1544
1608
|
const r = t[e.apiName];
|
|
@@ -1550,7 +1614,7 @@ function yr(t = {}) {
|
|
|
1550
1614
|
}
|
|
1551
1615
|
};
|
|
1552
1616
|
}
|
|
1553
|
-
class
|
|
1617
|
+
class yr {
|
|
1554
1618
|
constructor() {
|
|
1555
1619
|
this.state = {
|
|
1556
1620
|
// SDK 状态
|
|
@@ -1562,12 +1626,12 @@ class Ir {
|
|
|
1562
1626
|
},
|
|
1563
1627
|
// 平台信息
|
|
1564
1628
|
platform: {
|
|
1565
|
-
type:
|
|
1566
|
-
isWeixinMiniProgram:
|
|
1567
|
-
isAppPlus:
|
|
1568
|
-
isNvue:
|
|
1569
|
-
isUvue:
|
|
1570
|
-
isOfflineWebview:
|
|
1629
|
+
type: f.type,
|
|
1630
|
+
isWeixinMiniProgram: f.isWeixinMiniProgram,
|
|
1631
|
+
isAppPlus: f.isAppPlus,
|
|
1632
|
+
isNvue: f.isNvue,
|
|
1633
|
+
isUvue: f.isUvue,
|
|
1634
|
+
isOfflineWebview: f.isOfflineWebview,
|
|
1571
1635
|
features: {}
|
|
1572
1636
|
// 平台支持的特性
|
|
1573
1637
|
},
|
|
@@ -1617,7 +1681,7 @@ class Ir {
|
|
|
1617
1681
|
* store.set('network.online', false)
|
|
1618
1682
|
*/
|
|
1619
1683
|
set(e, r) {
|
|
1620
|
-
const n = e.split("."), i = n.pop(), s = n.reduce((
|
|
1684
|
+
const n = e.split("."), i = n.pop(), s = n.reduce((l, u) => ((!l[u] || typeof l[u] != "object") && (l[u] = {}), l[u]), this.state), o = s[i];
|
|
1621
1685
|
o !== r && (s[i] = r, D.debug(`状态已更新: ${e}`, { oldValue: o, newValue: r }), this.notify(e, r, o));
|
|
1622
1686
|
}
|
|
1623
1687
|
/**
|
|
@@ -1680,20 +1744,20 @@ class Ir {
|
|
|
1680
1744
|
i && i.forEach((o) => {
|
|
1681
1745
|
try {
|
|
1682
1746
|
o(r, n, e);
|
|
1683
|
-
} catch (
|
|
1684
|
-
D.error("订阅者执行失败",
|
|
1747
|
+
} catch (l) {
|
|
1748
|
+
D.error("订阅者执行失败", l);
|
|
1685
1749
|
}
|
|
1686
1750
|
});
|
|
1687
1751
|
const s = e.split(".");
|
|
1688
1752
|
for (let o = 1; o < s.length; o++) {
|
|
1689
|
-
const
|
|
1753
|
+
const l = s.slice(0, o).join("."), u = this.listeners.get(l);
|
|
1690
1754
|
if (u) {
|
|
1691
|
-
const p = this.get(
|
|
1692
|
-
u.forEach((
|
|
1755
|
+
const p = this.get(l);
|
|
1756
|
+
u.forEach((M) => {
|
|
1693
1757
|
try {
|
|
1694
|
-
|
|
1695
|
-
} catch (
|
|
1696
|
-
D.error("父路径订阅者执行失败",
|
|
1758
|
+
M(p, void 0, l);
|
|
1759
|
+
} catch (_) {
|
|
1760
|
+
D.error("父路径订阅者执行失败", _);
|
|
1697
1761
|
}
|
|
1698
1762
|
});
|
|
1699
1763
|
}
|
|
@@ -1701,8 +1765,8 @@ class Ir {
|
|
|
1701
1765
|
this.wildcardListeners.forEach((o) => {
|
|
1702
1766
|
try {
|
|
1703
1767
|
o(r, n, e);
|
|
1704
|
-
} catch (
|
|
1705
|
-
D.error("通配符订阅者执行失败",
|
|
1768
|
+
} catch (l) {
|
|
1769
|
+
D.error("通配符订阅者执行失败", l);
|
|
1706
1770
|
}
|
|
1707
1771
|
});
|
|
1708
1772
|
}
|
|
@@ -1795,7 +1859,7 @@ class Ir {
|
|
|
1795
1859
|
};
|
|
1796
1860
|
}
|
|
1797
1861
|
}
|
|
1798
|
-
const G = new
|
|
1862
|
+
const G = new yr(), c = {
|
|
1799
1863
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1800
1864
|
SDK_NOT_READY: "E_SDK_001",
|
|
1801
1865
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1902,7 +1966,7 @@ const G = new Ir(), c = {
|
|
|
1902
1966
|
// 配置问题
|
|
1903
1967
|
UNKNOWN: "unknown"
|
|
1904
1968
|
// 未知问题
|
|
1905
|
-
},
|
|
1969
|
+
}, Ir = {
|
|
1906
1970
|
// 图片相关
|
|
1907
1971
|
"IMAGE/USER_CANCEL": c.IMAGE_CANCELLED,
|
|
1908
1972
|
"IMAGE/PERMISSION_DENIED": c.IMAGE_NO_PERMISSION,
|
|
@@ -1961,10 +2025,10 @@ const G = new Ir(), c = {
|
|
|
1961
2025
|
function st(t) {
|
|
1962
2026
|
return t ? t.includes("CANCEL") ? W.USER_CANCEL : t.includes("PERM") || t.includes("PERMISSION") ? W.PERMISSION : t.includes("NET") || t.includes("NETWORK") ? W.NETWORK : t.includes("PARAM") ? W.PARAM : t.includes("CONFIG") ? W.CONFIG : t.includes("SDK") || t.includes("PLATFORM") ? W.SYSTEM : W.UNKNOWN : W.UNKNOWN;
|
|
1963
2027
|
}
|
|
1964
|
-
function
|
|
2028
|
+
function Ar(t) {
|
|
1965
2029
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === c.NETWORK_ERROR || t === c.NETWORK_TIMEOUT || t === c.API_TIMEOUT;
|
|
1966
2030
|
}
|
|
1967
|
-
function
|
|
2031
|
+
function Pr(t) {
|
|
1968
2032
|
return t.includes("CANCEL") || st(t) === W.USER_CANCEL;
|
|
1969
2033
|
}
|
|
1970
2034
|
function ne(t) {
|
|
@@ -1978,7 +2042,7 @@ class V extends Error {
|
|
|
1978
2042
|
* @param {Object} options - 选项
|
|
1979
2043
|
*/
|
|
1980
2044
|
constructor(e, r, n = {}) {
|
|
1981
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r || ne(e), this.platform = n.platform ||
|
|
2045
|
+
super(r), this.name = "StandardError", this.code = e, this.message = r || ne(e), this.platform = n.platform || f.type, this.apiName = n.apiName, this.category = n.category || st(e), this.retriable = n.retriable !== void 0 ? n.retriable : Ar(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1982
2046
|
}
|
|
1983
2047
|
/**
|
|
1984
2048
|
* 是否可重试
|
|
@@ -1992,7 +2056,7 @@ class V extends Error {
|
|
|
1992
2056
|
* @returns {boolean}
|
|
1993
2057
|
*/
|
|
1994
2058
|
isUserAction() {
|
|
1995
|
-
return
|
|
2059
|
+
return Pr(this.code);
|
|
1996
2060
|
}
|
|
1997
2061
|
/**
|
|
1998
2062
|
* 转为普通对象
|
|
@@ -2016,8 +2080,8 @@ class V extends Error {
|
|
|
2016
2080
|
function ot(t, e = {}) {
|
|
2017
2081
|
if (t instanceof V)
|
|
2018
2082
|
return t;
|
|
2019
|
-
const { apiName: r, platform: n =
|
|
2020
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2083
|
+
const { apiName: r, platform: n = f.type } = e;
|
|
2084
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? Cr(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? _r(t, { apiName: r, platform: n }) : typeof t == "string" ? new V(
|
|
2021
2085
|
c.UNKNOWN_ERROR,
|
|
2022
2086
|
t,
|
|
2023
2087
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -2032,8 +2096,8 @@ function ot(t, e = {}) {
|
|
|
2032
2096
|
}
|
|
2033
2097
|
);
|
|
2034
2098
|
}
|
|
2035
|
-
function
|
|
2036
|
-
const { apiName: r, platform: n } = e, i = t.code, s =
|
|
2099
|
+
function Cr(t, e) {
|
|
2100
|
+
const { apiName: r, platform: n } = e, i = t.code, s = Ir[i] || c.UNKNOWN_ERROR;
|
|
2037
2101
|
return a.debug("转换旧版错误码", {
|
|
2038
2102
|
legacy: i,
|
|
2039
2103
|
new: s
|
|
@@ -2051,11 +2115,11 @@ function Mr(t, e) {
|
|
|
2051
2115
|
}
|
|
2052
2116
|
);
|
|
2053
2117
|
}
|
|
2054
|
-
function
|
|
2118
|
+
function _r(t, e) {
|
|
2055
2119
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2056
2120
|
if (r && Ye[r]) {
|
|
2057
|
-
const
|
|
2058
|
-
for (const [u, p] of Object.entries(
|
|
2121
|
+
const l = Ye[r];
|
|
2122
|
+
for (const [u, p] of Object.entries(l))
|
|
2059
2123
|
if (i.includes(u.toLowerCase()))
|
|
2060
2124
|
return new V(p, ne(p), {
|
|
2061
2125
|
apiName: r,
|
|
@@ -2064,8 +2128,8 @@ function Cr(t, e) {
|
|
|
2064
2128
|
});
|
|
2065
2129
|
}
|
|
2066
2130
|
const s = ze[n] || ze.uniapp;
|
|
2067
|
-
for (const { pattern:
|
|
2068
|
-
if (
|
|
2131
|
+
for (const { pattern: l, code: u } of s.patterns)
|
|
2132
|
+
if (l.test(i))
|
|
2069
2133
|
return new V(u, ne(u), {
|
|
2070
2134
|
apiName: r,
|
|
2071
2135
|
platform: n,
|
|
@@ -2093,7 +2157,7 @@ const ct = {
|
|
|
2093
2157
|
if (!t.success && t.error) {
|
|
2094
2158
|
const r = ot(t.error, {
|
|
2095
2159
|
apiName: e.apiName,
|
|
2096
|
-
platform:
|
|
2160
|
+
platform: f.type
|
|
2097
2161
|
});
|
|
2098
2162
|
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), a.debug("错误已标准化", {
|
|
2099
2163
|
api: e.apiName,
|
|
@@ -2104,25 +2168,25 @@ const ct = {
|
|
|
2104
2168
|
return t;
|
|
2105
2169
|
}
|
|
2106
2170
|
};
|
|
2107
|
-
function
|
|
2171
|
+
function Mr(t, e = {}) {
|
|
2108
2172
|
return new V(t, ne(t), e);
|
|
2109
2173
|
}
|
|
2110
|
-
function
|
|
2174
|
+
function Rr(t) {
|
|
2111
2175
|
return t instanceof V;
|
|
2112
2176
|
}
|
|
2113
|
-
function
|
|
2177
|
+
function Sr(t, e, r) {
|
|
2114
2178
|
return e ? Promise.race([
|
|
2115
2179
|
t(),
|
|
2116
2180
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2117
2181
|
]) : t();
|
|
2118
2182
|
}
|
|
2119
|
-
function
|
|
2120
|
-
return
|
|
2183
|
+
function Or() {
|
|
2184
|
+
return I(this, arguments, function* (t = [], e = {}) {
|
|
2121
2185
|
for (const r of t) {
|
|
2122
2186
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2123
2187
|
if (typeof i == "function")
|
|
2124
2188
|
try {
|
|
2125
|
-
yield
|
|
2189
|
+
yield Sr(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2126
2190
|
} catch (s) {
|
|
2127
2191
|
if (typeof r.onError == "function" && r.onError(s), typeof e.onError == "function")
|
|
2128
2192
|
e.onError(s, r);
|
|
@@ -2259,7 +2323,7 @@ class ut {
|
|
|
2259
2323
|
}
|
|
2260
2324
|
}
|
|
2261
2325
|
let de = [];
|
|
2262
|
-
function
|
|
2326
|
+
function Nr() {
|
|
2263
2327
|
if (de.length === 0 && window.plus) {
|
|
2264
2328
|
const t = plus.webview.currentWebview();
|
|
2265
2329
|
if (!t)
|
|
@@ -2290,7 +2354,7 @@ function br(t, e) {
|
|
|
2290
2354
|
};
|
|
2291
2355
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2292
2356
|
}
|
|
2293
|
-
function
|
|
2357
|
+
function Tr(t, e) {
|
|
2294
2358
|
const r = {
|
|
2295
2359
|
options: {
|
|
2296
2360
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2311,14 +2375,14 @@ function vr(t, e) {
|
|
|
2311
2375
|
};
|
|
2312
2376
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2313
2377
|
}
|
|
2314
|
-
function
|
|
2378
|
+
function vr(t, e) {
|
|
2315
2379
|
const r = {
|
|
2316
2380
|
options: {
|
|
2317
2381
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2318
2382
|
},
|
|
2319
2383
|
name: t,
|
|
2320
2384
|
arg: e
|
|
2321
|
-
}, n =
|
|
2385
|
+
}, n = Nr();
|
|
2322
2386
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2323
2387
|
plus.webview.postMessageToUniNView({
|
|
2324
2388
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2334,7 +2398,7 @@ function Lr(t, e) {
|
|
|
2334
2398
|
);
|
|
2335
2399
|
}
|
|
2336
2400
|
}
|
|
2337
|
-
function
|
|
2401
|
+
function Lr(t, e) {
|
|
2338
2402
|
const r = {
|
|
2339
2403
|
options: {
|
|
2340
2404
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2348,10 +2412,10 @@ function xr(t, e) {
|
|
|
2348
2412
|
pageId: ""
|
|
2349
2413
|
}, "*");
|
|
2350
2414
|
}
|
|
2351
|
-
function
|
|
2415
|
+
function xr(t) {
|
|
2352
2416
|
return !!(t && typeof t == "object" && t.type === "qsh_api_call" && typeof t.api == "string" && typeof t.callbackId == "string");
|
|
2353
2417
|
}
|
|
2354
|
-
function
|
|
2418
|
+
function Dr(t, e) {
|
|
2355
2419
|
const r = {
|
|
2356
2420
|
options: {
|
|
2357
2421
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2359,7 +2423,7 @@ function Ur(t, e) {
|
|
|
2359
2423
|
name: t,
|
|
2360
2424
|
arg: e
|
|
2361
2425
|
};
|
|
2362
|
-
if (t === "postMessage" &&
|
|
2426
|
+
if (t === "postMessage" && xr(e))
|
|
2363
2427
|
return window.__offline_bridge_postMessage(e);
|
|
2364
2428
|
window.__offline_bridge_postMessage({
|
|
2365
2429
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2368,7 +2432,7 @@ function Ur(t, e) {
|
|
|
2368
2432
|
});
|
|
2369
2433
|
}
|
|
2370
2434
|
function he(t, e) {
|
|
2371
|
-
Se() ? br(t, e) : Re() ?
|
|
2435
|
+
Se() ? br(t, e) : Re() ? Tr(t, e) : Z() ? Dr(t, e) : Me() ? vr(t, e) : Lr(t, e);
|
|
2372
2436
|
}
|
|
2373
2437
|
class lt extends ut {
|
|
2374
2438
|
constructor() {
|
|
@@ -2389,17 +2453,17 @@ class lt extends ut {
|
|
|
2389
2453
|
* @returns {void}
|
|
2390
2454
|
*/
|
|
2391
2455
|
performNavigation(e, r) {
|
|
2392
|
-
return
|
|
2456
|
+
return d.safeExecute(() => {
|
|
2393
2457
|
const { url: n, delta: i } = r;
|
|
2394
|
-
if (
|
|
2458
|
+
if (E.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2395
2459
|
const o = window.wx.miniProgram[e];
|
|
2396
2460
|
if (typeof o == "function") {
|
|
2397
|
-
|
|
2398
|
-
const
|
|
2399
|
-
return o.call(window.wx.miniProgram,
|
|
2461
|
+
E.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2462
|
+
const l = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2463
|
+
return o.call(window.wx.miniProgram, l);
|
|
2400
2464
|
}
|
|
2401
2465
|
}
|
|
2402
|
-
|
|
2466
|
+
E.debug(`使用消息桥接执行: ${e}`), he(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2403
2467
|
}, {
|
|
2404
2468
|
platform: this.name,
|
|
2405
2469
|
method: "performNavigation",
|
|
@@ -2413,7 +2477,7 @@ class lt extends ut {
|
|
|
2413
2477
|
* @returns {void}
|
|
2414
2478
|
*/
|
|
2415
2479
|
performPostMessage(e) {
|
|
2416
|
-
return
|
|
2480
|
+
return d.safeExecute(() => {
|
|
2417
2481
|
const { data: r } = e;
|
|
2418
2482
|
if (this.isWeixinApiAvailable())
|
|
2419
2483
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
@@ -2430,7 +2494,7 @@ class lt extends ut {
|
|
|
2430
2494
|
* @returns {void}
|
|
2431
2495
|
*/
|
|
2432
2496
|
performGetEnv(e) {
|
|
2433
|
-
return
|
|
2497
|
+
return d.safeExecute(() => {
|
|
2434
2498
|
if (!e || typeof e != "function")
|
|
2435
2499
|
throw new Error("Callback function is required for getEnv");
|
|
2436
2500
|
if (this.isWeixinApiAvailable() && window.wx.miniProgram.getEnv)
|
|
@@ -2445,17 +2509,17 @@ class lt extends ut {
|
|
|
2445
2509
|
});
|
|
2446
2510
|
}
|
|
2447
2511
|
}
|
|
2448
|
-
const ee = new lt(),
|
|
2512
|
+
const ee = new lt(), Ur = (t) => ee.navigateTo(t), Wr = (t) => ee.navigateBack(t), $r = (t) => ee.switchTab(t), Fr = (t) => ee.reLaunch(t), kr = (t) => ee.redirectTo(t), Br = (t) => ee.postMessage(t), Gr = (t) => ee.getEnv(t);
|
|
2449
2513
|
var ft = /* @__PURE__ */ Object.freeze({
|
|
2450
2514
|
__proto__: null,
|
|
2451
2515
|
WeixinPlatform: lt,
|
|
2452
|
-
getEnv:
|
|
2453
|
-
navigateBack:
|
|
2454
|
-
navigateTo:
|
|
2455
|
-
postMessage:
|
|
2456
|
-
reLaunch:
|
|
2516
|
+
getEnv: Gr,
|
|
2517
|
+
navigateBack: Wr,
|
|
2518
|
+
navigateTo: Ur,
|
|
2519
|
+
postMessage: Br,
|
|
2520
|
+
reLaunch: Fr,
|
|
2457
2521
|
redirectTo: kr,
|
|
2458
|
-
switchTab:
|
|
2522
|
+
switchTab: $r
|
|
2459
2523
|
});
|
|
2460
2524
|
class dt extends ut {
|
|
2461
2525
|
constructor() {
|
|
@@ -2468,7 +2532,7 @@ class dt extends ut {
|
|
|
2468
2532
|
* @returns {void}
|
|
2469
2533
|
*/
|
|
2470
2534
|
performNavigation(e, r) {
|
|
2471
|
-
return
|
|
2535
|
+
return d.safeExecute(() => {
|
|
2472
2536
|
const { url: n, delta: i } = r;
|
|
2473
2537
|
he(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2474
2538
|
}, {
|
|
@@ -2484,7 +2548,7 @@ class dt extends ut {
|
|
|
2484
2548
|
* @returns {void}
|
|
2485
2549
|
*/
|
|
2486
2550
|
performPostMessage(e) {
|
|
2487
|
-
return
|
|
2551
|
+
return d.safeExecute(() => {
|
|
2488
2552
|
const { data: r } = e;
|
|
2489
2553
|
he("postMessage", r);
|
|
2490
2554
|
}, {
|
|
@@ -2499,64 +2563,64 @@ class dt extends ut {
|
|
|
2499
2563
|
* @returns {void}
|
|
2500
2564
|
*/
|
|
2501
2565
|
performGetEnv(e) {
|
|
2502
|
-
return
|
|
2566
|
+
return d.safeExecute(() => {
|
|
2503
2567
|
if (!e || typeof e != "function")
|
|
2504
2568
|
throw new Error("Callback function is required for getEnv");
|
|
2505
2569
|
const r = {};
|
|
2506
2570
|
let n = !1;
|
|
2507
|
-
Se() ? (r.uvue = !0, n = !0) : Re() ? (r.nvue = !0, n = !0) :
|
|
2571
|
+
Se() ? (r.uvue = !0, n = !0) : Re() ? (r.nvue = !0, n = !0) : Me() ? (r.plus = !0, n = !0) : Z() && (r.offline = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2508
2572
|
}, {
|
|
2509
2573
|
platform: this.name,
|
|
2510
2574
|
method: "performGetEnv"
|
|
2511
2575
|
});
|
|
2512
2576
|
}
|
|
2513
2577
|
}
|
|
2514
|
-
const te = new dt(),
|
|
2578
|
+
const te = new dt(), Kr = (t) => te.navigateTo(t), Vr = (t) => te.navigateBack(t), qr = (t) => te.switchTab(t), jr = (t) => te.reLaunch(t), Jr = (t) => te.redirectTo(t), Hr = (t) => te.postMessage(t), zr = (t) => te.getEnv(t);
|
|
2515
2579
|
var gt = /* @__PURE__ */ Object.freeze({
|
|
2516
2580
|
__proto__: null,
|
|
2517
2581
|
AppPlatform: dt,
|
|
2518
|
-
getEnv:
|
|
2519
|
-
navigateBack:
|
|
2520
|
-
navigateTo:
|
|
2521
|
-
postMessage:
|
|
2522
|
-
reLaunch:
|
|
2523
|
-
redirectTo:
|
|
2524
|
-
switchTab:
|
|
2582
|
+
getEnv: zr,
|
|
2583
|
+
navigateBack: Vr,
|
|
2584
|
+
navigateTo: Kr,
|
|
2585
|
+
postMessage: Hr,
|
|
2586
|
+
reLaunch: jr,
|
|
2587
|
+
redirectTo: Jr,
|
|
2588
|
+
switchTab: qr
|
|
2525
2589
|
});
|
|
2526
2590
|
function me() {
|
|
2527
|
-
return
|
|
2591
|
+
return C() ? ft : gt;
|
|
2528
2592
|
}
|
|
2529
|
-
function
|
|
2593
|
+
function Yr(t) {
|
|
2530
2594
|
return me().navigateTo(t);
|
|
2531
2595
|
}
|
|
2532
|
-
function
|
|
2596
|
+
function Xr(t) {
|
|
2533
2597
|
return me().navigateBack(t);
|
|
2534
2598
|
}
|
|
2535
|
-
function
|
|
2599
|
+
function Zr(t) {
|
|
2536
2600
|
return me().switchTab(t);
|
|
2537
2601
|
}
|
|
2538
|
-
function
|
|
2602
|
+
function Qr(t) {
|
|
2539
2603
|
return me().reLaunch(t);
|
|
2540
2604
|
}
|
|
2541
|
-
function
|
|
2605
|
+
function en(t) {
|
|
2542
2606
|
return me().redirectTo(t);
|
|
2543
2607
|
}
|
|
2544
2608
|
function ht() {
|
|
2545
|
-
return
|
|
2609
|
+
return C() ? ft : gt;
|
|
2546
2610
|
}
|
|
2547
|
-
function
|
|
2611
|
+
function tn(t = {}) {
|
|
2548
2612
|
return ht().postMessage(t);
|
|
2549
2613
|
}
|
|
2550
|
-
function
|
|
2614
|
+
function rn(t) {
|
|
2551
2615
|
return ht().getEnv(t);
|
|
2552
2616
|
}
|
|
2553
|
-
function
|
|
2617
|
+
function nn(t) {
|
|
2554
2618
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2555
2619
|
}
|
|
2556
|
-
function
|
|
2620
|
+
function an() {
|
|
2557
2621
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2558
2622
|
}
|
|
2559
|
-
class
|
|
2623
|
+
class sn {
|
|
2560
2624
|
constructor() {
|
|
2561
2625
|
this.callbacks = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.persistentCallbacksByApi = /* @__PURE__ */ new Map(), this.defaultTimeout = 3e4, typeof window != "undefined" && (window.qshWebviewCallbacks || (window.qshWebviewCallbacks = {})), A.debug("WebView 桥接器已初始化");
|
|
2562
2626
|
}
|
|
@@ -2568,15 +2632,15 @@ class on {
|
|
|
2568
2632
|
* @returns {void}
|
|
2569
2633
|
*/
|
|
2570
2634
|
callApi(i) {
|
|
2571
|
-
return
|
|
2572
|
-
return
|
|
2635
|
+
return I(this, arguments, function* (e, r = {}, n = {}) {
|
|
2636
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
2573
2637
|
var p;
|
|
2574
2638
|
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !Z()) {
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2639
|
+
const M = new N(
|
|
2640
|
+
T.PLATFORM_NOT_SUPPORTED,
|
|
2577
2641
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2578
2642
|
);
|
|
2579
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2643
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: M.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: M.message } });
|
|
2580
2644
|
return;
|
|
2581
2645
|
}
|
|
2582
2646
|
const o = {
|
|
@@ -2588,18 +2652,18 @@ class on {
|
|
|
2588
2652
|
metadata: {}
|
|
2589
2653
|
};
|
|
2590
2654
|
G.setApiLoading(e, !0);
|
|
2591
|
-
const
|
|
2592
|
-
if (
|
|
2655
|
+
const l = yield z.runRequest(o);
|
|
2656
|
+
if (l.abort) {
|
|
2593
2657
|
A.warn("API 调用被拦截器中止", { api: e }), G.setApiLoading(e, !1), n.fail && n.fail({
|
|
2594
|
-
errMsg: ((p =
|
|
2658
|
+
errMsg: ((p = l.error) == null ? void 0 : p.message) || "API 调用被中止",
|
|
2595
2659
|
code: "INTERCEPTED"
|
|
2596
2660
|
}), n.complete && n.complete({ success: !1 });
|
|
2597
2661
|
return;
|
|
2598
2662
|
}
|
|
2599
|
-
const u =
|
|
2663
|
+
const u = an();
|
|
2600
2664
|
if (n.success || n.fail || n.complete) {
|
|
2601
2665
|
if (this.callbacks.set(u, m(g({}, n), {
|
|
2602
|
-
context:
|
|
2666
|
+
context: l
|
|
2603
2667
|
// 保存上下文用于响应拦截
|
|
2604
2668
|
})), window.qshWebviewCallbacks[u] = ($) => {
|
|
2605
2669
|
this.handleCallback(u, $);
|
|
@@ -2618,10 +2682,10 @@ class on {
|
|
|
2618
2682
|
}, r.timeout || this.defaultTimeout);
|
|
2619
2683
|
this.timeouts.set(u, $);
|
|
2620
2684
|
}
|
|
2621
|
-
const
|
|
2685
|
+
const _ = {
|
|
2622
2686
|
type: "qsh_api_call",
|
|
2623
2687
|
api: e,
|
|
2624
|
-
params:
|
|
2688
|
+
params: l.params,
|
|
2625
2689
|
callbackId: u,
|
|
2626
2690
|
timestamp: Date.now()
|
|
2627
2691
|
};
|
|
@@ -2630,7 +2694,7 @@ class on {
|
|
|
2630
2694
|
callbackId: u,
|
|
2631
2695
|
hasSuccess: !!n.success,
|
|
2632
2696
|
hasFail: !!n.fail
|
|
2633
|
-
}), console.log("message:", JSON.stringify(
|
|
2697
|
+
}), console.log("message:", JSON.stringify(nn(_), null, 2)), he("postMessage", _);
|
|
2634
2698
|
}
|
|
2635
2699
|
}), {
|
|
2636
2700
|
context: "WebViewBridge.callApi",
|
|
@@ -2645,18 +2709,18 @@ class on {
|
|
|
2645
2709
|
* @private
|
|
2646
2710
|
*/
|
|
2647
2711
|
handleCallback(e, r) {
|
|
2648
|
-
return
|
|
2649
|
-
return
|
|
2650
|
-
var
|
|
2712
|
+
return I(this, null, function* () {
|
|
2713
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
2714
|
+
var M, _;
|
|
2651
2715
|
const n = this.callbacks.get(e);
|
|
2652
2716
|
if (!n) {
|
|
2653
2717
|
A.warn("未找到回调函数", { callbackId: e });
|
|
2654
2718
|
return;
|
|
2655
2719
|
}
|
|
2656
|
-
const { success: i, fail: s, complete: o, context:
|
|
2720
|
+
const { success: i, fail: s, complete: o, context: l } = n;
|
|
2657
2721
|
A.debug("处理回调", { callbackId: e, result: r });
|
|
2658
|
-
const u = yield z.runResponse(r,
|
|
2659
|
-
|
|
2722
|
+
const u = yield z.runResponse(r, l);
|
|
2723
|
+
l && G.setApiResult(l.apiName, u), u.success && i ? i(u.data) : !u.success && s && s(u.error || { errMsg: "操作失败" }), o && o(u), ((_ = (M = n.context) == null ? void 0 : M.params) == null ? void 0 : _.isPersistent) ? A.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), A.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2660
2724
|
}), {
|
|
2661
2725
|
context: "WebViewBridge.handleCallback",
|
|
2662
2726
|
callbackId: e
|
|
@@ -2709,15 +2773,15 @@ class on {
|
|
|
2709
2773
|
};
|
|
2710
2774
|
}
|
|
2711
2775
|
}
|
|
2712
|
-
const pt = new
|
|
2776
|
+
const pt = new sn(), O = (t, e, r) => pt.callApi(t, e, r), ie = (t) => pt.cleanupPersistentCallbacksByApi(t);
|
|
2713
2777
|
function mt() {
|
|
2714
2778
|
return H(!0);
|
|
2715
2779
|
}
|
|
2716
|
-
function
|
|
2780
|
+
function on(t) {
|
|
2717
2781
|
return t === "offline";
|
|
2718
2782
|
}
|
|
2719
|
-
function
|
|
2720
|
-
return
|
|
2783
|
+
function cn(t = {}) {
|
|
2784
|
+
return d.safeExecute(() => {
|
|
2721
2785
|
a.debug("Call getCode through offline webview bridge", {
|
|
2722
2786
|
clientId: t.clientId
|
|
2723
2787
|
}), O(
|
|
@@ -2742,8 +2806,8 @@ function un(t = {}) {
|
|
|
2742
2806
|
platform: mt().type
|
|
2743
2807
|
});
|
|
2744
2808
|
}
|
|
2745
|
-
function
|
|
2746
|
-
return
|
|
2809
|
+
function un(t = {}) {
|
|
2810
|
+
return d.safeExecute(() => {
|
|
2747
2811
|
var n, i;
|
|
2748
2812
|
const e = mt(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2749
2813
|
if (!r) {
|
|
@@ -2754,7 +2818,7 @@ function ln(t = {}) {
|
|
|
2754
2818
|
a.error("Get code missing clientId"), (n = t.fail) == null || n.call(t, s);
|
|
2755
2819
|
return;
|
|
2756
2820
|
}
|
|
2757
|
-
if (!
|
|
2821
|
+
if (!on(e.type)) {
|
|
2758
2822
|
const s = {
|
|
2759
2823
|
errMsg: `Current environment (${e.type}) does not support getCode`,
|
|
2760
2824
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2764,7 +2828,7 @@ function ln(t = {}) {
|
|
|
2764
2828
|
}), (i = t.fail) == null || i.call(t, s);
|
|
2765
2829
|
return;
|
|
2766
2830
|
}
|
|
2767
|
-
|
|
2831
|
+
cn(m(g({}, t), {
|
|
2768
2832
|
clientId: r
|
|
2769
2833
|
}));
|
|
2770
2834
|
}, {
|
|
@@ -2776,7 +2840,7 @@ function wt() {
|
|
|
2776
2840
|
return H(!0);
|
|
2777
2841
|
}
|
|
2778
2842
|
const Xe = ["release", "trial", "develop"];
|
|
2779
|
-
function
|
|
2843
|
+
function ln(t = {}) {
|
|
2780
2844
|
const e = String((t == null ? void 0 : t.appid) || "").trim(), r = (t == null ? void 0 : t.path) == null ? "" : t.path, n = t == null ? void 0 : t.env, i = n == null || n === "" ? void 0 : String(n).trim();
|
|
2781
2845
|
if (!e)
|
|
2782
2846
|
throw {
|
|
@@ -2799,13 +2863,13 @@ function fn(t = {}) {
|
|
|
2799
2863
|
env: i
|
|
2800
2864
|
});
|
|
2801
2865
|
}
|
|
2802
|
-
function
|
|
2866
|
+
function fn() {
|
|
2803
2867
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.postMessage == "function" && typeof window.wx.miniProgram.navigateBack == "function";
|
|
2804
2868
|
}
|
|
2805
|
-
function
|
|
2806
|
-
return
|
|
2869
|
+
function dn(t = {}) {
|
|
2870
|
+
return d.safeExecute(() => {
|
|
2807
2871
|
var r;
|
|
2808
|
-
if (!
|
|
2872
|
+
if (!fn()) {
|
|
2809
2873
|
const n = {
|
|
2810
2874
|
errMsg: "wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",
|
|
2811
2875
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2839,18 +2903,18 @@ function gn(t = {}) {
|
|
|
2839
2903
|
delta: 1,
|
|
2840
2904
|
success: (o) => {
|
|
2841
2905
|
var u;
|
|
2842
|
-
const
|
|
2906
|
+
const l = m(g({}, o), {
|
|
2843
2907
|
errMsg: (o == null ? void 0 : o.errMsg) || "navigateToMiniProgram:queued"
|
|
2844
2908
|
});
|
|
2845
2909
|
a.info("Navigate to mini program request queued in weixin web-view", {
|
|
2846
2910
|
appid: t.appid,
|
|
2847
2911
|
path: t.path,
|
|
2848
2912
|
env: t.env
|
|
2849
|
-
}), (u = t.success) == null || u.call(t,
|
|
2913
|
+
}), (u = t.success) == null || u.call(t, l), n(l);
|
|
2850
2914
|
},
|
|
2851
2915
|
fail: (o) => {
|
|
2852
|
-
var
|
|
2853
|
-
a.error("Navigate back after posting mini program message failed", o), (
|
|
2916
|
+
var l;
|
|
2917
|
+
a.error("Navigate back after posting mini program message failed", o), (l = t.fail) == null || l.call(t, o), i(o);
|
|
2854
2918
|
},
|
|
2855
2919
|
complete: t.complete
|
|
2856
2920
|
});
|
|
@@ -2860,8 +2924,8 @@ function gn(t = {}) {
|
|
|
2860
2924
|
platform: "weixin"
|
|
2861
2925
|
});
|
|
2862
2926
|
}
|
|
2863
|
-
function
|
|
2864
|
-
return
|
|
2927
|
+
function gn(t = {}) {
|
|
2928
|
+
return d.safeExecute(() => (a.debug("Call navigateToMiniProgram through webview bridge", {
|
|
2865
2929
|
appid: t.appid,
|
|
2866
2930
|
path: t.path,
|
|
2867
2931
|
env: t.env
|
|
@@ -2890,13 +2954,13 @@ function hn(t = {}) {
|
|
|
2890
2954
|
platform: wt().type
|
|
2891
2955
|
});
|
|
2892
2956
|
}
|
|
2893
|
-
function
|
|
2894
|
-
return
|
|
2957
|
+
function hn(t = {}) {
|
|
2958
|
+
return d.safeExecute(() => {
|
|
2895
2959
|
var n;
|
|
2896
2960
|
const e = wt();
|
|
2897
2961
|
let r;
|
|
2898
2962
|
try {
|
|
2899
|
-
r =
|
|
2963
|
+
r = ln(t);
|
|
2900
2964
|
} catch (i) {
|
|
2901
2965
|
a.error("Navigate to mini program params validation failed", i), (n = t.fail) == null || n.call(t, i);
|
|
2902
2966
|
return;
|
|
@@ -2906,31 +2970,31 @@ function pn(t = {}) {
|
|
|
2906
2970
|
appid: r.appid,
|
|
2907
2971
|
path: r.path,
|
|
2908
2972
|
env: r.env
|
|
2909
|
-
}), e.isWeixinMiniProgram ?
|
|
2973
|
+
}), e.isWeixinMiniProgram ? dn(r) : gn(r);
|
|
2910
2974
|
}, {
|
|
2911
2975
|
context: "navigateToMiniProgram",
|
|
2912
2976
|
options: t
|
|
2913
2977
|
});
|
|
2914
2978
|
}
|
|
2915
|
-
function
|
|
2979
|
+
function pn(t = "") {
|
|
2916
2980
|
return /^https?:\/\//i.test(String(t || "").trim());
|
|
2917
2981
|
}
|
|
2918
|
-
function
|
|
2982
|
+
function mn(t) {
|
|
2919
2983
|
if (t == null || t === "") return !1;
|
|
2920
2984
|
if (typeof t == "boolean") return t;
|
|
2921
2985
|
const e = String(t).trim().toLowerCase();
|
|
2922
2986
|
return e === "true" || e === "1";
|
|
2923
2987
|
}
|
|
2924
|
-
function
|
|
2988
|
+
function wn() {
|
|
2925
2989
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.postMessage == "function" && typeof window.wx.miniProgram.navigateBack == "function";
|
|
2926
2990
|
}
|
|
2927
|
-
function
|
|
2991
|
+
function En(t = {}) {
|
|
2928
2992
|
if (!t || typeof t != "object")
|
|
2929
2993
|
throw {
|
|
2930
2994
|
errMsg: "manualShare options must be an object",
|
|
2931
2995
|
code: "PARAM_TYPE_ERROR"
|
|
2932
2996
|
};
|
|
2933
|
-
const e = String(t.title || "").trim(), r = String(t.h5Url || "").trim(), n = String(t.clientId || "").trim(), i =
|
|
2997
|
+
const e = String(t.title || "").trim(), r = String(t.h5Url || "").trim(), n = String(t.clientId || "").trim(), i = mn(t.isPublic), s = String(t.imageUrl || "").trim(), o = String(t.description || t.desc || "").trim();
|
|
2934
2998
|
if (!e)
|
|
2935
2999
|
throw {
|
|
2936
3000
|
errMsg: "manualShare: title is required",
|
|
@@ -2946,7 +3010,7 @@ function yn(t = {}) {
|
|
|
2946
3010
|
errMsg: "manualShare: clientId is required",
|
|
2947
3011
|
code: "PARAM_MISSING"
|
|
2948
3012
|
};
|
|
2949
|
-
if (r && !
|
|
3013
|
+
if (r && !pn(r))
|
|
2950
3014
|
throw {
|
|
2951
3015
|
errMsg: "manualShare: h5Url must be a valid http(s) url",
|
|
2952
3016
|
code: "PARAM_INVALID"
|
|
@@ -2963,7 +3027,7 @@ function yn(t = {}) {
|
|
|
2963
3027
|
complete: t.complete
|
|
2964
3028
|
};
|
|
2965
3029
|
}
|
|
2966
|
-
function
|
|
3030
|
+
function yn(t) {
|
|
2967
3031
|
return {
|
|
2968
3032
|
type: "qsh_api_call",
|
|
2969
3033
|
api: "manualShare",
|
|
@@ -2978,9 +3042,9 @@ function In(t) {
|
|
|
2978
3042
|
timestamp: Date.now()
|
|
2979
3043
|
};
|
|
2980
3044
|
}
|
|
2981
|
-
function
|
|
3045
|
+
function In(t) {
|
|
2982
3046
|
return new Promise((e, r) => {
|
|
2983
|
-
const n =
|
|
3047
|
+
const n = yn(t);
|
|
2984
3048
|
a.debug(
|
|
2985
3049
|
"Relay manualShare through wx.miniProgram.postMessage",
|
|
2986
3050
|
n
|
|
@@ -3014,13 +3078,13 @@ function An(t) {
|
|
|
3014
3078
|
});
|
|
3015
3079
|
}
|
|
3016
3080
|
function Et(t = {}) {
|
|
3017
|
-
return
|
|
3081
|
+
return d.safeExecute(
|
|
3018
3082
|
() => {
|
|
3019
|
-
var n, i, s, o,
|
|
3083
|
+
var n, i, s, o, l, u;
|
|
3020
3084
|
const e = H(!0);
|
|
3021
3085
|
let r;
|
|
3022
3086
|
try {
|
|
3023
|
-
r =
|
|
3087
|
+
r = En(t);
|
|
3024
3088
|
} catch (p) {
|
|
3025
3089
|
return (n = t.fail) == null || n.call(t, p), (i = t.complete) == null || i.call(t, p), Promise.reject(p);
|
|
3026
3090
|
}
|
|
@@ -3031,19 +3095,19 @@ function Et(t = {}) {
|
|
|
3031
3095
|
};
|
|
3032
3096
|
return (s = r.fail) == null || s.call(r, p), (o = r.complete) == null || o.call(r, p), Promise.reject(p);
|
|
3033
3097
|
}
|
|
3034
|
-
if (!
|
|
3098
|
+
if (!wn()) {
|
|
3035
3099
|
const p = {
|
|
3036
3100
|
errMsg: "wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",
|
|
3037
3101
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3038
3102
|
};
|
|
3039
|
-
return (
|
|
3103
|
+
return (l = r.fail) == null || l.call(r, p), (u = r.complete) == null || u.call(r, p), Promise.reject(p);
|
|
3040
3104
|
}
|
|
3041
|
-
return
|
|
3042
|
-
var
|
|
3043
|
-
return (
|
|
3105
|
+
return In(r).then((p) => {
|
|
3106
|
+
var M, _;
|
|
3107
|
+
return (M = r.success) == null || M.call(r, p), (_ = r.complete) == null || _.call(r, p), p;
|
|
3044
3108
|
}).catch((p) => {
|
|
3045
|
-
var
|
|
3046
|
-
return (
|
|
3109
|
+
var M, _;
|
|
3110
|
+
return (M = r.fail) == null || M.call(r, p), (_ = r.complete) == null || _.call(r, p), Promise.reject(p);
|
|
3047
3111
|
});
|
|
3048
3112
|
},
|
|
3049
3113
|
{
|
|
@@ -3052,7 +3116,7 @@ function Et(t = {}) {
|
|
|
3052
3116
|
}
|
|
3053
3117
|
);
|
|
3054
3118
|
}
|
|
3055
|
-
function
|
|
3119
|
+
function An(t = {}) {
|
|
3056
3120
|
return new Promise((e, r) => {
|
|
3057
3121
|
Et(m(g({}, t), {
|
|
3058
3122
|
success: e,
|
|
@@ -3060,30 +3124,30 @@ function Pn(t = {}) {
|
|
|
3060
3124
|
}));
|
|
3061
3125
|
});
|
|
3062
3126
|
}
|
|
3063
|
-
const
|
|
3127
|
+
const Ce = {
|
|
3064
3128
|
ALBUM: "album",
|
|
3065
3129
|
// 相册
|
|
3066
3130
|
CAMERA: "camera"
|
|
3067
3131
|
// 相机
|
|
3068
|
-
},
|
|
3132
|
+
}, _e = {
|
|
3069
3133
|
ORIGINAL: "original",
|
|
3070
3134
|
// 原图
|
|
3071
3135
|
COMPRESSED: "compressed"
|
|
3072
3136
|
// 压缩图
|
|
3073
|
-
},
|
|
3137
|
+
}, Pn = {
|
|
3074
3138
|
count: 9,
|
|
3075
|
-
sizeType: [
|
|
3076
|
-
sourceType: [
|
|
3139
|
+
sizeType: [_e.ORIGINAL, _e.COMPRESSED],
|
|
3140
|
+
sourceType: [Ce.ALBUM, Ce.CAMERA]
|
|
3077
3141
|
};
|
|
3078
|
-
function
|
|
3079
|
-
const e = g(g({},
|
|
3080
|
-
return Array.isArray(e.sizeType) || (e.sizeType = [e.sizeType].filter(Boolean)), Array.isArray(e.sourceType) || (e.sourceType = [e.sourceType].filter(Boolean)), e.count = Math.max(1, Math.min(9, parseInt(e.count) || 1)), e.sizeType.length === 0 && (e.sizeType = [
|
|
3142
|
+
function Cn(t = {}) {
|
|
3143
|
+
const e = g(g({}, Pn), t);
|
|
3144
|
+
return Array.isArray(e.sizeType) || (e.sizeType = [e.sizeType].filter(Boolean)), Array.isArray(e.sourceType) || (e.sourceType = [e.sourceType].filter(Boolean)), e.count = Math.max(1, Math.min(9, parseInt(e.count) || 1)), e.sizeType.length === 0 && (e.sizeType = [_e.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [Ce.ALBUM]), e;
|
|
3081
3145
|
}
|
|
3082
3146
|
function yt() {
|
|
3083
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3147
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3084
3148
|
}
|
|
3085
3149
|
function It(t) {
|
|
3086
|
-
return
|
|
3150
|
+
return d.safeExecute(() => {
|
|
3087
3151
|
var e;
|
|
3088
3152
|
if (!window.wx) {
|
|
3089
3153
|
const r = {
|
|
@@ -3119,8 +3183,8 @@ function It(t) {
|
|
|
3119
3183
|
platform: "weixin"
|
|
3120
3184
|
});
|
|
3121
3185
|
}
|
|
3122
|
-
function
|
|
3123
|
-
return
|
|
3186
|
+
function _n(t) {
|
|
3187
|
+
return d.safeExecute(() => {
|
|
3124
3188
|
a.debug("通过 WebView 桥接调用图片选择", t), O("chooseImage", m(g({}, t), { disableTimeout: !0 }), {
|
|
3125
3189
|
success: (e) => {
|
|
3126
3190
|
var r, n;
|
|
@@ -3139,34 +3203,34 @@ function Cn(t) {
|
|
|
3139
3203
|
platform: "uniapp"
|
|
3140
3204
|
});
|
|
3141
3205
|
}
|
|
3142
|
-
function
|
|
3143
|
-
return
|
|
3206
|
+
function Mn(t = {}) {
|
|
3207
|
+
return d.safeExecute(() => {
|
|
3144
3208
|
var r;
|
|
3145
3209
|
if (!yt()) {
|
|
3146
3210
|
const n = {
|
|
3147
|
-
errMsg: `当前环境 (${
|
|
3211
|
+
errMsg: `当前环境 (${f.type}) 不支持图片选择功能`,
|
|
3148
3212
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3149
3213
|
};
|
|
3150
|
-
a.error("平台不支持图片选择", { platform:
|
|
3214
|
+
a.error("平台不支持图片选择", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3151
3215
|
return;
|
|
3152
3216
|
}
|
|
3153
|
-
const e =
|
|
3217
|
+
const e = Cn(t);
|
|
3154
3218
|
a.info("开始选择图片", {
|
|
3155
|
-
platform:
|
|
3219
|
+
platform: f.type,
|
|
3156
3220
|
count: e.count,
|
|
3157
3221
|
sizeType: e.sizeType,
|
|
3158
3222
|
sourceType: e.sourceType
|
|
3159
|
-
}),
|
|
3223
|
+
}), C() ? It(e) : _n(e);
|
|
3160
3224
|
}, {
|
|
3161
3225
|
context: "chooseImage",
|
|
3162
3226
|
options: t
|
|
3163
3227
|
});
|
|
3164
3228
|
}
|
|
3165
|
-
function
|
|
3229
|
+
function Rn() {
|
|
3166
3230
|
return {
|
|
3167
3231
|
supported: yt(),
|
|
3168
|
-
environment:
|
|
3169
|
-
implementation:
|
|
3232
|
+
environment: f.type,
|
|
3233
|
+
implementation: C() ? "weixin" : "webview",
|
|
3170
3234
|
features: {
|
|
3171
3235
|
multipleSelection: !0,
|
|
3172
3236
|
// 支持多选
|
|
@@ -3188,21 +3252,21 @@ const X = {
|
|
|
3188
3252
|
// Data Matrix 码
|
|
3189
3253
|
PDF417: "pdf417"
|
|
3190
3254
|
// PDF417 条码
|
|
3191
|
-
},
|
|
3255
|
+
}, Sn = {
|
|
3192
3256
|
onlyFromCamera: !0,
|
|
3193
3257
|
// 只从相机扫码
|
|
3194
3258
|
scanType: [X.QR_CODE, X.BAR_CODE]
|
|
3195
3259
|
// 支持二维码和一维码
|
|
3196
3260
|
};
|
|
3197
|
-
function
|
|
3198
|
-
const e = g(g({},
|
|
3261
|
+
function On(t = {}) {
|
|
3262
|
+
const e = g(g({}, Sn), t);
|
|
3199
3263
|
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [X.QR_CODE, X.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
3200
3264
|
}
|
|
3201
3265
|
function At() {
|
|
3202
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3266
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3203
3267
|
}
|
|
3204
3268
|
function Pt(t) {
|
|
3205
|
-
return
|
|
3269
|
+
return d.safeExecute(() => {
|
|
3206
3270
|
var e;
|
|
3207
3271
|
if (!window.wx) {
|
|
3208
3272
|
const r = {
|
|
@@ -3229,7 +3293,7 @@ function Pt(t) {
|
|
|
3229
3293
|
const n = {
|
|
3230
3294
|
result: r.resultStr,
|
|
3231
3295
|
// 扫码内容
|
|
3232
|
-
scanType:
|
|
3296
|
+
scanType: Nn(r.resultStr),
|
|
3233
3297
|
// 推测扫码类型
|
|
3234
3298
|
charSet: "utf-8",
|
|
3235
3299
|
// 微信默认 UTF-8
|
|
@@ -3248,11 +3312,11 @@ function Pt(t) {
|
|
|
3248
3312
|
platform: "weixin"
|
|
3249
3313
|
});
|
|
3250
3314
|
}
|
|
3251
|
-
function
|
|
3315
|
+
function Nn(t) {
|
|
3252
3316
|
return t ? t.length > 50 || /[^\d]/.test(t) ? X.QR_CODE : X.BAR_CODE : "unknown";
|
|
3253
3317
|
}
|
|
3254
3318
|
function bn(t) {
|
|
3255
|
-
return
|
|
3319
|
+
return d.safeExecute(() => {
|
|
3256
3320
|
a.debug("通过 WebView 桥接调用扫码", t), O("scanCode", m(g({}, t), { disableTimeout: !0 }), {
|
|
3257
3321
|
success: (e) => {
|
|
3258
3322
|
var r;
|
|
@@ -3272,33 +3336,33 @@ function bn(t) {
|
|
|
3272
3336
|
platform: "uniapp"
|
|
3273
3337
|
});
|
|
3274
3338
|
}
|
|
3275
|
-
function
|
|
3276
|
-
return
|
|
3339
|
+
function Tn(t = {}) {
|
|
3340
|
+
return d.safeExecute(() => {
|
|
3277
3341
|
var r;
|
|
3278
3342
|
if (!At()) {
|
|
3279
3343
|
const n = {
|
|
3280
|
-
errMsg: `当前环境 (${
|
|
3344
|
+
errMsg: `当前环境 (${f.type}) 不支持扫码功能`,
|
|
3281
3345
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3282
3346
|
};
|
|
3283
|
-
a.error("平台不支持扫码", { platform:
|
|
3347
|
+
a.error("平台不支持扫码", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3284
3348
|
return;
|
|
3285
3349
|
}
|
|
3286
|
-
const e =
|
|
3350
|
+
const e = On(t);
|
|
3287
3351
|
a.info("开始扫码", {
|
|
3288
|
-
platform:
|
|
3352
|
+
platform: f.type,
|
|
3289
3353
|
onlyFromCamera: e.onlyFromCamera,
|
|
3290
3354
|
scanType: e.scanType
|
|
3291
|
-
}),
|
|
3355
|
+
}), C() ? Pt(e) : bn(e);
|
|
3292
3356
|
}, {
|
|
3293
3357
|
context: "scanCode",
|
|
3294
3358
|
options: t
|
|
3295
3359
|
});
|
|
3296
3360
|
}
|
|
3297
|
-
function
|
|
3361
|
+
function vn() {
|
|
3298
3362
|
return {
|
|
3299
3363
|
supported: At(),
|
|
3300
|
-
environment:
|
|
3301
|
-
implementation:
|
|
3364
|
+
environment: f.type,
|
|
3365
|
+
implementation: C() ? "weixin" : "webview",
|
|
3302
3366
|
features: {
|
|
3303
3367
|
onlyFromCamera: !0,
|
|
3304
3368
|
// 支持只从相机扫码
|
|
@@ -3318,23 +3382,23 @@ const ae = {
|
|
|
3318
3382
|
// 国测局坐标(火星坐标)
|
|
3319
3383
|
BD09: "bd09"
|
|
3320
3384
|
// 百度坐标
|
|
3321
|
-
},
|
|
3385
|
+
}, Ln = {
|
|
3322
3386
|
type: ae.WGS84,
|
|
3323
3387
|
altitude: !1
|
|
3324
|
-
},
|
|
3388
|
+
}, xn = {
|
|
3325
3389
|
scale: 18
|
|
3326
3390
|
// 地图缩放级别 1-28
|
|
3327
3391
|
};
|
|
3328
|
-
function
|
|
3329
|
-
const e = g(g({},
|
|
3392
|
+
function Dn(t = {}) {
|
|
3393
|
+
const e = g(g({}, Ln), t);
|
|
3330
3394
|
return Object.values(ae).includes(e.type) || (e.type = ae.WGS84), e.altitude = !!e.altitude, e;
|
|
3331
3395
|
}
|
|
3332
|
-
function
|
|
3396
|
+
function Un(t = {}) {
|
|
3333
3397
|
const e = g({}, t);
|
|
3334
3398
|
return Object.values(ae).includes(e.type) || (e.type = ae.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
3335
3399
|
}
|
|
3336
|
-
function
|
|
3337
|
-
const e = g(g({},
|
|
3400
|
+
function Wn(t = {}) {
|
|
3401
|
+
const e = g(g({}, xn), t);
|
|
3338
3402
|
if (e.latitude === void 0 || e.latitude === null)
|
|
3339
3403
|
throw {
|
|
3340
3404
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -3394,10 +3458,10 @@ function $n(t = {}) {
|
|
|
3394
3458
|
return e;
|
|
3395
3459
|
}
|
|
3396
3460
|
function $e() {
|
|
3397
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3461
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3398
3462
|
}
|
|
3399
|
-
function
|
|
3400
|
-
return
|
|
3463
|
+
function Ct(t) {
|
|
3464
|
+
return d.safeExecute(() => {
|
|
3401
3465
|
var e;
|
|
3402
3466
|
if (!window.wx) {
|
|
3403
3467
|
const r = {
|
|
@@ -3408,7 +3472,7 @@ function _t(t) {
|
|
|
3408
3472
|
return;
|
|
3409
3473
|
}
|
|
3410
3474
|
if (!oe()) {
|
|
3411
|
-
a.info("等待微信配置完成"), Q().then(() =>
|
|
3475
|
+
a.info("等待微信配置完成"), Q().then(() => Ct(t)).catch((r) => {
|
|
3412
3476
|
var n;
|
|
3413
3477
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3414
3478
|
});
|
|
@@ -3434,8 +3498,8 @@ function _t(t) {
|
|
|
3434
3498
|
platform: "weixin"
|
|
3435
3499
|
});
|
|
3436
3500
|
}
|
|
3437
|
-
function
|
|
3438
|
-
return
|
|
3501
|
+
function _t(t) {
|
|
3502
|
+
return d.safeExecute(() => {
|
|
3439
3503
|
var e;
|
|
3440
3504
|
if (!window.wx) {
|
|
3441
3505
|
const r = {
|
|
@@ -3446,7 +3510,7 @@ function Mt(t) {
|
|
|
3446
3510
|
return;
|
|
3447
3511
|
}
|
|
3448
3512
|
if (!oe()) {
|
|
3449
|
-
a.info("等待微信配置完成"), Q().then(() =>
|
|
3513
|
+
a.info("等待微信配置完成"), Q().then(() => _t(t)).catch((r) => {
|
|
3450
3514
|
var n;
|
|
3451
3515
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3452
3516
|
});
|
|
@@ -3474,8 +3538,8 @@ function Mt(t) {
|
|
|
3474
3538
|
platform: "weixin"
|
|
3475
3539
|
});
|
|
3476
3540
|
}
|
|
3477
|
-
function
|
|
3478
|
-
return
|
|
3541
|
+
function $n(t) {
|
|
3542
|
+
return d.safeExecute(() => {
|
|
3479
3543
|
a.debug("通过 WebView 桥接调用获取位置", t), O("getLocation", t, {
|
|
3480
3544
|
success: (e) => {
|
|
3481
3545
|
var r;
|
|
@@ -3495,8 +3559,8 @@ function Fn(t) {
|
|
|
3495
3559
|
platform: "uniapp"
|
|
3496
3560
|
});
|
|
3497
3561
|
}
|
|
3498
|
-
function
|
|
3499
|
-
return
|
|
3562
|
+
function Fn(t) {
|
|
3563
|
+
return d.safeExecute(() => {
|
|
3500
3564
|
a.debug("通过 WebView 桥接调用查看位置", t), O("openLocation", t, {
|
|
3501
3565
|
success: (e) => {
|
|
3502
3566
|
var r;
|
|
@@ -3514,61 +3578,61 @@ function Bn(t) {
|
|
|
3514
3578
|
});
|
|
3515
3579
|
}
|
|
3516
3580
|
function kn(t = {}) {
|
|
3517
|
-
return
|
|
3581
|
+
return d.safeExecute(() => {
|
|
3518
3582
|
var r;
|
|
3519
3583
|
if (!$e()) {
|
|
3520
3584
|
const n = {
|
|
3521
|
-
errMsg: `当前环境 (${
|
|
3585
|
+
errMsg: `当前环境 (${f.type}) 不支持定位功能`,
|
|
3522
3586
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3523
3587
|
};
|
|
3524
|
-
a.error("平台不支持定位", { platform:
|
|
3588
|
+
a.error("平台不支持定位", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3525
3589
|
return;
|
|
3526
3590
|
}
|
|
3527
|
-
const e =
|
|
3591
|
+
const e = Dn(t);
|
|
3528
3592
|
a.info("开始获取位置", {
|
|
3529
|
-
platform:
|
|
3593
|
+
platform: f.type,
|
|
3530
3594
|
type: e.type,
|
|
3531
3595
|
altitude: e.altitude
|
|
3532
|
-
}),
|
|
3596
|
+
}), C() ? Ct(e) : $n(e);
|
|
3533
3597
|
}, {
|
|
3534
3598
|
context: "getLocation",
|
|
3535
3599
|
options: t
|
|
3536
3600
|
});
|
|
3537
3601
|
}
|
|
3538
|
-
function
|
|
3539
|
-
return
|
|
3602
|
+
function Bn(t = {}) {
|
|
3603
|
+
return d.safeExecute(() => {
|
|
3540
3604
|
var r, n, i;
|
|
3541
3605
|
if (!$e()) {
|
|
3542
3606
|
const s = {
|
|
3543
|
-
errMsg: `当前环境 (${
|
|
3607
|
+
errMsg: `当前环境 (${f.type}) 不支持查看位置功能`,
|
|
3544
3608
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3545
3609
|
};
|
|
3546
|
-
a.error("平台不支持查看位置", { platform:
|
|
3610
|
+
a.error("平台不支持查看位置", { platform: f.type }), (r = t.fail) == null || r.call(t, s);
|
|
3547
3611
|
return;
|
|
3548
3612
|
}
|
|
3549
3613
|
let e;
|
|
3550
3614
|
try {
|
|
3551
|
-
e =
|
|
3615
|
+
e = Wn(t);
|
|
3552
3616
|
} catch (s) {
|
|
3553
3617
|
a.error("参数验证失败", s), (n = t.fail) == null || n.call(t, s), (i = t.complete) == null || i.call(t);
|
|
3554
3618
|
return;
|
|
3555
3619
|
}
|
|
3556
3620
|
a.info("开始查看位置", {
|
|
3557
|
-
platform:
|
|
3621
|
+
platform: f.type,
|
|
3558
3622
|
latitude: e.latitude,
|
|
3559
3623
|
longitude: e.longitude,
|
|
3560
3624
|
name: e.name
|
|
3561
|
-
}),
|
|
3625
|
+
}), C() ? _t(e) : Fn(e);
|
|
3562
3626
|
}, {
|
|
3563
3627
|
context: "openLocation",
|
|
3564
3628
|
options: t
|
|
3565
3629
|
});
|
|
3566
3630
|
}
|
|
3567
|
-
function
|
|
3568
|
-
const t =
|
|
3631
|
+
function Gn() {
|
|
3632
|
+
const t = C();
|
|
3569
3633
|
return {
|
|
3570
3634
|
supported: $e(),
|
|
3571
|
-
environment:
|
|
3635
|
+
environment: f.type,
|
|
3572
3636
|
implementation: t ? "weixin" : "webview",
|
|
3573
3637
|
features: {
|
|
3574
3638
|
getLocation: !0,
|
|
@@ -3587,27 +3651,27 @@ function Kn() {
|
|
|
3587
3651
|
};
|
|
3588
3652
|
}
|
|
3589
3653
|
const j = /* @__PURE__ */ new Set(), J = /* @__PURE__ */ new Set();
|
|
3590
|
-
function
|
|
3654
|
+
function Mt(t, e, r) {
|
|
3591
3655
|
t.forEach((n) => {
|
|
3592
3656
|
if (typeof n == "function") {
|
|
3593
|
-
|
|
3657
|
+
d.safeExecute(() => n(e), { context: r });
|
|
3594
3658
|
return;
|
|
3595
3659
|
}
|
|
3596
3660
|
a.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3597
3661
|
});
|
|
3598
3662
|
}
|
|
3599
|
-
function
|
|
3600
|
-
return
|
|
3663
|
+
function Kn(t = {}) {
|
|
3664
|
+
return d.safeExecute(() => {
|
|
3601
3665
|
var r, n;
|
|
3602
|
-
if (
|
|
3666
|
+
if (C()) {
|
|
3603
3667
|
const i = {
|
|
3604
|
-
errMsg: `当前环境 (${
|
|
3668
|
+
errMsg: `当前环境 (${f.type}) 不支持该接口`,
|
|
3605
3669
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3606
3670
|
};
|
|
3607
|
-
a.error("当前环境不支持此接口", { platform:
|
|
3671
|
+
a.error("当前环境不支持此接口", { platform: f.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3608
3672
|
return;
|
|
3609
3673
|
}
|
|
3610
|
-
const e =
|
|
3674
|
+
const e = Un(t);
|
|
3611
3675
|
a.info("正在开启定位监听"), O("startLocationUpdate", {
|
|
3612
3676
|
type: e.type,
|
|
3613
3677
|
needFullAccuracy: e.needFullAccuracy
|
|
@@ -3624,15 +3688,15 @@ function Vn(t = {}) {
|
|
|
3624
3688
|
});
|
|
3625
3689
|
}, { context: "startLocationUpdate" });
|
|
3626
3690
|
}
|
|
3627
|
-
function
|
|
3628
|
-
return
|
|
3691
|
+
function Vn(t = {}) {
|
|
3692
|
+
return d.safeExecute(() => {
|
|
3629
3693
|
var e, r;
|
|
3630
|
-
if (
|
|
3694
|
+
if (C()) {
|
|
3631
3695
|
const n = {
|
|
3632
|
-
errMsg: `当前环境 (${
|
|
3696
|
+
errMsg: `当前环境 (${f.type}) 不支持该接口`,
|
|
3633
3697
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3634
3698
|
};
|
|
3635
|
-
a.error("当前环境不支持此接口", { platform:
|
|
3699
|
+
a.error("当前环境不支持此接口", { platform: f.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3636
3700
|
return;
|
|
3637
3701
|
}
|
|
3638
3702
|
a.info("正在停止定位监听"), O("stopLocationUpdate", t, {
|
|
@@ -3648,10 +3712,10 @@ function qn(t = {}) {
|
|
|
3648
3712
|
});
|
|
3649
3713
|
}, { context: "stopLocationUpdate" });
|
|
3650
3714
|
}
|
|
3651
|
-
function
|
|
3652
|
-
return
|
|
3653
|
-
if (
|
|
3654
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3715
|
+
function qn(t) {
|
|
3716
|
+
return d.safeExecute(() => {
|
|
3717
|
+
if (C()) {
|
|
3718
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3655
3719
|
return;
|
|
3656
3720
|
}
|
|
3657
3721
|
if (typeof t != "function")
|
|
@@ -3662,7 +3726,7 @@ function jn(t) {
|
|
|
3662
3726
|
const e = j.size > 0;
|
|
3663
3727
|
j.add(t), e || (a.debug("注册实时位置变化监听器"), O("onLocationChange", { isPersistent: !0 }, {
|
|
3664
3728
|
success: (r) => {
|
|
3665
|
-
a.debug("收到实时位置推送", r),
|
|
3729
|
+
a.debug("收到实时位置推送", r), Mt(j, r, "onLocationChange");
|
|
3666
3730
|
},
|
|
3667
3731
|
fail: (r) => {
|
|
3668
3732
|
a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), j.delete(t), j.size === 0 && ie("onLocationChange");
|
|
@@ -3670,10 +3734,10 @@ function jn(t) {
|
|
|
3670
3734
|
}));
|
|
3671
3735
|
}, { context: "onLocationChange" });
|
|
3672
3736
|
}
|
|
3673
|
-
function
|
|
3674
|
-
return
|
|
3675
|
-
if (
|
|
3676
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3737
|
+
function jn(t) {
|
|
3738
|
+
return d.safeExecute(() => {
|
|
3739
|
+
if (C()) {
|
|
3740
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3677
3741
|
return;
|
|
3678
3742
|
}
|
|
3679
3743
|
if (t && typeof t != "function")
|
|
@@ -3691,10 +3755,10 @@ function Jn(t) {
|
|
|
3691
3755
|
}));
|
|
3692
3756
|
}, { context: "offLocationChange" });
|
|
3693
3757
|
}
|
|
3694
|
-
function
|
|
3695
|
-
return
|
|
3696
|
-
if (
|
|
3697
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3758
|
+
function Jn(t) {
|
|
3759
|
+
return d.safeExecute(() => {
|
|
3760
|
+
if (C()) {
|
|
3761
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3698
3762
|
return;
|
|
3699
3763
|
}
|
|
3700
3764
|
if (typeof t != "function")
|
|
@@ -3705,7 +3769,7 @@ function Hn(t) {
|
|
|
3705
3769
|
const e = J.size > 0;
|
|
3706
3770
|
J.add(t), e || (a.debug("注册位置更新错误监听器"), O("onLocationChangeError", { isPersistent: !0 }, {
|
|
3707
3771
|
success: (r) => {
|
|
3708
|
-
a.warn("持续定位发生异常", r),
|
|
3772
|
+
a.warn("持续定位发生异常", r), Mt(J, r, "onLocationChangeError");
|
|
3709
3773
|
},
|
|
3710
3774
|
fail: (r) => {
|
|
3711
3775
|
a.warn("位置更新错误监听注册失败", r), J.delete(t), J.size === 0 && ie("onLocationChangeError");
|
|
@@ -3713,10 +3777,10 @@ function Hn(t) {
|
|
|
3713
3777
|
}));
|
|
3714
3778
|
}, { context: "onLocationChangeError" });
|
|
3715
3779
|
}
|
|
3716
|
-
function
|
|
3717
|
-
return
|
|
3718
|
-
if (
|
|
3719
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3780
|
+
function Hn(t) {
|
|
3781
|
+
return d.safeExecute(() => {
|
|
3782
|
+
if (C()) {
|
|
3783
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3720
3784
|
return;
|
|
3721
3785
|
}
|
|
3722
3786
|
if (t && typeof t != "function")
|
|
@@ -3734,14 +3798,14 @@ function zn(t) {
|
|
|
3734
3798
|
}));
|
|
3735
3799
|
}, { context: "offLocationChangeError" });
|
|
3736
3800
|
}
|
|
3737
|
-
const
|
|
3801
|
+
const zn = {
|
|
3738
3802
|
latitude: null,
|
|
3739
3803
|
// 目标地纬度
|
|
3740
3804
|
longitude: null
|
|
3741
3805
|
// 目标地经度
|
|
3742
3806
|
};
|
|
3743
|
-
function
|
|
3744
|
-
const e = g(g({},
|
|
3807
|
+
function Yn(t = {}) {
|
|
3808
|
+
const e = g(g({}, zn), t);
|
|
3745
3809
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (a.warn("latitude 参数类型错误,已忽略", {
|
|
3746
3810
|
latitude: e.latitude
|
|
3747
3811
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (a.warn("latitude 超出范围,已忽略", {
|
|
@@ -3753,10 +3817,10 @@ function Xn(t = {}) {
|
|
|
3753
3817
|
}), e.longitude = null)), e;
|
|
3754
3818
|
}
|
|
3755
3819
|
function Rt() {
|
|
3756
|
-
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3820
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3757
3821
|
}
|
|
3758
|
-
function
|
|
3759
|
-
return
|
|
3822
|
+
function Xn(t) {
|
|
3823
|
+
return d.safeExecute(() => {
|
|
3760
3824
|
a.debug("通过 WebView 桥接调用位置选择", t);
|
|
3761
3825
|
const e = {
|
|
3762
3826
|
// 禁用超时清理,等待用户操作完成后才清理
|
|
@@ -3790,33 +3854,33 @@ function Zn(t) {
|
|
|
3790
3854
|
platform: "uniapp"
|
|
3791
3855
|
});
|
|
3792
3856
|
}
|
|
3793
|
-
function
|
|
3794
|
-
return
|
|
3857
|
+
function Zn(t = {}) {
|
|
3858
|
+
return d.safeExecute(() => {
|
|
3795
3859
|
var r;
|
|
3796
3860
|
if (!Rt()) {
|
|
3797
3861
|
const n = {
|
|
3798
|
-
errMsg: `当前环境 (${
|
|
3862
|
+
errMsg: `当前环境 (${f.type}) 不支持位置选择功能`,
|
|
3799
3863
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3800
3864
|
};
|
|
3801
|
-
a.error("平台不支持位置选择", { platform:
|
|
3865
|
+
a.error("平台不支持位置选择", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3802
3866
|
return;
|
|
3803
3867
|
}
|
|
3804
|
-
const e =
|
|
3868
|
+
const e = Yn(t);
|
|
3805
3869
|
a.info("开始选择位置", {
|
|
3806
|
-
platform:
|
|
3870
|
+
platform: f.type,
|
|
3807
3871
|
latitude: e.latitude,
|
|
3808
3872
|
longitude: e.longitude
|
|
3809
|
-
}),
|
|
3873
|
+
}), C() || Xn(e);
|
|
3810
3874
|
}, {
|
|
3811
3875
|
context: "chooseLocation",
|
|
3812
3876
|
options: t
|
|
3813
3877
|
});
|
|
3814
3878
|
}
|
|
3815
|
-
function
|
|
3879
|
+
function Qn() {
|
|
3816
3880
|
return {
|
|
3817
3881
|
supported: Rt(),
|
|
3818
|
-
environment:
|
|
3819
|
-
implementation:
|
|
3882
|
+
environment: f.type,
|
|
3883
|
+
implementation: C() ? "weixin" : "webview",
|
|
3820
3884
|
features: {
|
|
3821
3885
|
chooseLocation: !0,
|
|
3822
3886
|
// 支持位置选择
|
|
@@ -3828,7 +3892,7 @@ function ei() {
|
|
|
3828
3892
|
};
|
|
3829
3893
|
}
|
|
3830
3894
|
const St = "https://iafs.xjy2.cn/img/bg.143351f0.jpg";
|
|
3831
|
-
function
|
|
3895
|
+
function ei(t) {
|
|
3832
3896
|
return t === "timeline" || Number(t) === 1 ? 1 : 0;
|
|
3833
3897
|
}
|
|
3834
3898
|
function Ne(t = "", e = "targetPath") {
|
|
@@ -3845,15 +3909,15 @@ function Ot(t = "", e = "webTarget") {
|
|
|
3845
3909
|
throw { errMsg: `share: ${e} 必须是公网链接,例如 https://example.com/path?a=1`, code: "PARAM_INVALID" };
|
|
3846
3910
|
return r;
|
|
3847
3911
|
}
|
|
3848
|
-
function
|
|
3912
|
+
function ti() {
|
|
3849
3913
|
return new Promise((t, e) => {
|
|
3850
3914
|
var s, o;
|
|
3851
3915
|
const r = typeof window != "undefined" ? window : null;
|
|
3852
3916
|
if (!r) return e({ errMsg: "当前环境不支持 plus", code: "PLUS_UNAVAILABLE" });
|
|
3853
3917
|
if (r.plus) return t(r.plus);
|
|
3854
3918
|
const n = setTimeout(() => {
|
|
3855
|
-
var
|
|
3856
|
-
(u = (
|
|
3919
|
+
var l, u;
|
|
3920
|
+
(u = (l = r.document) == null ? void 0 : l.removeEventListener) == null || u.call(l, "plusready", i), e({ errMsg: "等待 plusready 超时", code: "PLUS_READY_TIMEOUT" });
|
|
3857
3921
|
}, 8e3);
|
|
3858
3922
|
function i() {
|
|
3859
3923
|
clearTimeout(n), t(r.plus);
|
|
@@ -3861,7 +3925,7 @@ function ri() {
|
|
|
3861
3925
|
(o = (s = r.document) == null ? void 0 : s.addEventListener) == null || o.call(s, "plusready", i, { once: !0 });
|
|
3862
3926
|
});
|
|
3863
3927
|
}
|
|
3864
|
-
function
|
|
3928
|
+
function ri() {
|
|
3865
3929
|
return new Promise((t, e) => {
|
|
3866
3930
|
const r = typeof window != "undefined" ? window.plus : null;
|
|
3867
3931
|
if (!r || !r.share || typeof r.share.getServices != "function")
|
|
@@ -3876,13 +3940,13 @@ function ni() {
|
|
|
3876
3940
|
);
|
|
3877
3941
|
});
|
|
3878
3942
|
}
|
|
3879
|
-
function
|
|
3943
|
+
function ni(t) {
|
|
3880
3944
|
return t.isWeixinMiniProgram ? "已同步分享内容,请点击右上角“···”选择发送给朋友或分享到朋友圈。" : "正在拉起微信分享面板,请选择聊天框或朋友圈。";
|
|
3881
3945
|
}
|
|
3882
|
-
function
|
|
3946
|
+
function ii(t = {}) {
|
|
3883
3947
|
if (!t || typeof t != "object")
|
|
3884
3948
|
throw { errMsg: "shareDirected 参数必须是对象", code: "PARAM_TYPE_ERROR" };
|
|
3885
|
-
const e = String(t.kind || "").trim(), r = t.payload || {}, n =
|
|
3949
|
+
const e = String(t.kind || "").trim(), r = t.payload || {}, n = ei(t.scene);
|
|
3886
3950
|
if (!["web", "image", "text"].includes(e))
|
|
3887
3951
|
throw { errMsg: 'shareDirected: kind 仅支持 "web"|"image"|"text"', code: "PARAM_INVALID" };
|
|
3888
3952
|
if (![0, 1].includes(n))
|
|
@@ -3904,7 +3968,7 @@ function ai(t = {}) {
|
|
|
3904
3968
|
complete: t.complete
|
|
3905
3969
|
};
|
|
3906
3970
|
}
|
|
3907
|
-
function
|
|
3971
|
+
function ai(t, e) {
|
|
3908
3972
|
const { payload: r } = t;
|
|
3909
3973
|
if (e.isWeixinMiniProgram)
|
|
3910
3974
|
try {
|
|
@@ -3914,9 +3978,9 @@ function si(t, e) {
|
|
|
3914
3978
|
throw { errMsg: (n == null ? void 0 : n.errMsg) || "shareDirected: 小程序环境下 payload.target 不合法", code: (n == null ? void 0 : n.code) || "PARAM_INVALID" };
|
|
3915
3979
|
}
|
|
3916
3980
|
if (e.isAppPlus) {
|
|
3917
|
-
const n = (o,
|
|
3981
|
+
const n = (o, l) => {
|
|
3918
3982
|
try {
|
|
3919
|
-
return Ot(o,
|
|
3983
|
+
return Ot(o, l);
|
|
3920
3984
|
} catch (u) {
|
|
3921
3985
|
return "";
|
|
3922
3986
|
}
|
|
@@ -3933,7 +3997,7 @@ function si(t, e) {
|
|
|
3933
3997
|
}
|
|
3934
3998
|
return t;
|
|
3935
3999
|
}
|
|
3936
|
-
function
|
|
4000
|
+
function si(t) {
|
|
3937
4001
|
const { kind: e, payload: r, resolvedTargetPath: n } = t, i = Ne(n || r.target, "target"), s = r.imageUrl || St;
|
|
3938
4002
|
return {
|
|
3939
4003
|
title: r.title || "分享",
|
|
@@ -3943,17 +4007,17 @@ function oi(t) {
|
|
|
3943
4007
|
custom: { kind: e, target: i.path, webTarget: r.webTarget || "", description: r.description || "" }
|
|
3944
4008
|
};
|
|
3945
4009
|
}
|
|
3946
|
-
function
|
|
4010
|
+
function oi(t) {
|
|
3947
4011
|
const { kind: e, scene: r, payload: n, resolvedWebTarget: i } = t, s = r === 1 ? "WXSceneTimeline" : "WXSceneSession", o = n.imageUrl || St;
|
|
3948
4012
|
return e === "image" ? { message: { type: "image", pictures: [n.imageUrl], extra: { scene: s } }, degradedFromText: !1 } : {
|
|
3949
4013
|
message: { type: "web", title: n.title || "分享", content: n.description || "", href: i, thumbs: [o], extra: { scene: s } },
|
|
3950
4014
|
degradedFromText: e === "text"
|
|
3951
4015
|
};
|
|
3952
4016
|
}
|
|
3953
|
-
function
|
|
3954
|
-
return
|
|
3955
|
-
yield
|
|
3956
|
-
const e = yield
|
|
4017
|
+
function ci(t) {
|
|
4018
|
+
return I(this, null, function* () {
|
|
4019
|
+
yield ti();
|
|
4020
|
+
const e = yield ri(), { message: r, degradedFromText: n } = oi(t);
|
|
3957
4021
|
return new Promise((i, s) => {
|
|
3958
4022
|
e.send(
|
|
3959
4023
|
r,
|
|
@@ -3969,10 +4033,10 @@ function Nt(t, e = "share") {
|
|
|
3969
4033
|
throw { errMsg: `当前微信小程序容器未注入 postMessage 能力,无法发起 ${e}`, code: "MINIPROGRAM_BRIDGE_UNAVAILABLE" };
|
|
3970
4034
|
r.postMessage({ data: t });
|
|
3971
4035
|
}
|
|
3972
|
-
function
|
|
3973
|
-
return { type: "qsh_api_call", api: "shareDirected", params: { miniProgramShare:
|
|
4036
|
+
function ui(t, e) {
|
|
4037
|
+
return { type: "qsh_api_call", api: "shareDirected", params: { miniProgramShare: si(t), rowCustom: e }, timestamp: Date.now() };
|
|
3974
4038
|
}
|
|
3975
|
-
function
|
|
4039
|
+
function li(t = {}) {
|
|
3976
4040
|
if (!t || typeof t != "object")
|
|
3977
4041
|
throw { errMsg: "shareMiniProgramCard 参数必须是对象", code: "PARAM_TYPE_ERROR" };
|
|
3978
4042
|
const e = t.payload || {};
|
|
@@ -3981,7 +4045,7 @@ function fi(t = {}) {
|
|
|
3981
4045
|
if (!e.targetPath) throw { errMsg: "shareMiniProgramCard: payload.targetPath 必填", code: "PARAM_MISSING" };
|
|
3982
4046
|
return Ne(e.targetPath, "targetPath"), { payload: e, success: t.success, fail: t.fail, complete: t.complete };
|
|
3983
4047
|
}
|
|
3984
|
-
function
|
|
4048
|
+
function fi(t) {
|
|
3985
4049
|
switch (String(t || "release").trim().toLowerCase()) {
|
|
3986
4050
|
case "develop":
|
|
3987
4051
|
case "development":
|
|
@@ -4000,6 +4064,24 @@ function Tt(t) {
|
|
|
4000
4064
|
}
|
|
4001
4065
|
}
|
|
4002
4066
|
function di(t) {
|
|
4067
|
+
switch (String(t || "release").trim().toLowerCase()) {
|
|
4068
|
+
case "develop":
|
|
4069
|
+
case "development":
|
|
4070
|
+
case "test":
|
|
4071
|
+
return 1;
|
|
4072
|
+
case "trial":
|
|
4073
|
+
case "preview":
|
|
4074
|
+
case "experience":
|
|
4075
|
+
return 2;
|
|
4076
|
+
case "release":
|
|
4077
|
+
case "formal":
|
|
4078
|
+
case "production":
|
|
4079
|
+
return 0;
|
|
4080
|
+
default:
|
|
4081
|
+
throw { errMsg: 'shareMiniProgramCard: payload.envVersion 仅支持 "develop"|"trial"|"release"', code: "PARAM_INVALID" };
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
function gi(t) {
|
|
4003
4085
|
const { payload: e } = t;
|
|
4004
4086
|
if (!e.appid)
|
|
4005
4087
|
throw { errMsg: "shareMiniProgramCard: App 环境下 payload.appid 必填", code: "PARAM_MISSING" };
|
|
@@ -4008,9 +4090,9 @@ function di(t) {
|
|
|
4008
4090
|
} catch (r) {
|
|
4009
4091
|
throw { errMsg: "shareMiniProgramCard: App 环境下 payload.webUrl 必填,且必须是公网链接", code: (r == null ? void 0 : r.code) || "PARAM_INVALID" };
|
|
4010
4092
|
}
|
|
4011
|
-
return
|
|
4093
|
+
return fi(e.envVersion), t;
|
|
4012
4094
|
}
|
|
4013
|
-
function
|
|
4095
|
+
function hi(t) {
|
|
4014
4096
|
const { payload: e } = t, r = Ne(e.targetPath, "targetPath");
|
|
4015
4097
|
return {
|
|
4016
4098
|
title: e.title,
|
|
@@ -4019,7 +4101,7 @@ function gi(t) {
|
|
|
4019
4101
|
imageUrl: e.imageUrl
|
|
4020
4102
|
};
|
|
4021
4103
|
}
|
|
4022
|
-
function
|
|
4104
|
+
function pi(t) {
|
|
4023
4105
|
const { payload: e } = t;
|
|
4024
4106
|
return {
|
|
4025
4107
|
provider: "weixin",
|
|
@@ -4030,54 +4112,54 @@ function hi(t) {
|
|
|
4030
4112
|
miniProgram: {
|
|
4031
4113
|
id: e.appid,
|
|
4032
4114
|
path: e.targetPath,
|
|
4033
|
-
type:
|
|
4115
|
+
type: di(e.envVersion),
|
|
4034
4116
|
webUrl: e.webUrl
|
|
4035
4117
|
}
|
|
4036
4118
|
};
|
|
4037
4119
|
}
|
|
4038
|
-
function
|
|
4039
|
-
return { type: "qsh_api_call", api: "shareMiniProgramCard", params: { miniProgramShare:
|
|
4120
|
+
function mi(t, e) {
|
|
4121
|
+
return { type: "qsh_api_call", api: "shareMiniProgramCard", params: { miniProgramShare: hi(t), rowCustom: e }, timestamp: Date.now() };
|
|
4040
4122
|
}
|
|
4041
|
-
function
|
|
4042
|
-
return
|
|
4123
|
+
function wi(t) {
|
|
4124
|
+
return I(this, null, function* () {
|
|
4043
4125
|
return new Promise((e, r) => {
|
|
4044
|
-
O("shareMiniProgramCard", { appShare:
|
|
4126
|
+
O("shareMiniProgramCard", { appShare: pi(t) }, { success: (n) => e(n || {}), fail: (n) => r(n) });
|
|
4045
4127
|
});
|
|
4046
4128
|
});
|
|
4047
4129
|
}
|
|
4048
4130
|
function bt(t = {}) {
|
|
4049
|
-
return
|
|
4131
|
+
return d.safeExecute(
|
|
4050
4132
|
() => {
|
|
4051
|
-
var s, o,
|
|
4133
|
+
var s, o, l, u, p, M, _, $, ce, R, F;
|
|
4052
4134
|
let e;
|
|
4053
4135
|
try {
|
|
4054
|
-
e =
|
|
4136
|
+
e = ii(t);
|
|
4055
4137
|
} catch (w) {
|
|
4056
4138
|
return (s = t.fail) == null || s.call(t, w), Promise.reject(w);
|
|
4057
4139
|
}
|
|
4058
4140
|
const r = H(!0);
|
|
4059
4141
|
try {
|
|
4060
|
-
e =
|
|
4142
|
+
e = ai(e, r);
|
|
4061
4143
|
} catch (w) {
|
|
4062
|
-
return (o = e.fail) == null || o.call(e, w), (
|
|
4144
|
+
return (o = e.fail) == null || o.call(e, w), (l = e.complete) == null || l.call(e, w), Promise.reject(w);
|
|
4063
4145
|
}
|
|
4064
|
-
const n =
|
|
4146
|
+
const n = ni(r);
|
|
4065
4147
|
if (r.isAppPlus)
|
|
4066
|
-
return
|
|
4148
|
+
return ci(e).then((w) => {
|
|
4067
4149
|
var ue, je;
|
|
4068
|
-
const
|
|
4069
|
-
return (ue = e.success) == null || ue.call(e,
|
|
4150
|
+
const k = m(g({}, (w == null ? void 0 : w.data) || {}), { hint: n });
|
|
4151
|
+
return (ue = e.success) == null || ue.call(e, k), (je = e.complete) == null || je.call(e, k), k;
|
|
4070
4152
|
}).catch((w) => {
|
|
4071
|
-
var
|
|
4072
|
-
return (
|
|
4153
|
+
var k, ue;
|
|
4154
|
+
return (k = e.fail) == null || k.call(e, w), (ue = e.complete) == null || ue.call(e, w), Promise.reject(w);
|
|
4073
4155
|
});
|
|
4074
4156
|
if (r.isWeixinMiniProgram)
|
|
4075
4157
|
try {
|
|
4076
|
-
Nt(
|
|
4158
|
+
Nt(ui(e, t.rowCustom), "shareDirected");
|
|
4077
4159
|
const w = { success: !0, hint: n };
|
|
4078
4160
|
return (u = e.success) == null || u.call(e, w), (p = e.complete) == null || p.call(e, w), Promise.resolve(w);
|
|
4079
4161
|
} catch (w) {
|
|
4080
|
-
return (
|
|
4162
|
+
return (M = e.fail) == null || M.call(e, w), (_ = e.complete) == null || _.call(e, w), Promise.reject(w);
|
|
4081
4163
|
}
|
|
4082
4164
|
if (r.type === "h5" && !r.isUniAppWebView && !r.isOfflineWebview) {
|
|
4083
4165
|
const w = { errMsg: "当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。", code: "NOT_IN_CONTAINER" };
|
|
@@ -4089,45 +4171,45 @@ function bt(t = {}) {
|
|
|
4089
4171
|
{ context: "shareDirected", options: t }
|
|
4090
4172
|
);
|
|
4091
4173
|
}
|
|
4092
|
-
function
|
|
4174
|
+
function Ei(t = {}) {
|
|
4093
4175
|
return new Promise((e, r) => {
|
|
4094
4176
|
bt(m(g({}, t), { success: e, fail: r }));
|
|
4095
4177
|
});
|
|
4096
4178
|
}
|
|
4097
|
-
function
|
|
4098
|
-
return
|
|
4179
|
+
function Tt(t = {}) {
|
|
4180
|
+
return d.safeExecute(
|
|
4099
4181
|
() => {
|
|
4100
|
-
var s, o,
|
|
4182
|
+
var s, o, l, u, p, M, _, $, ce;
|
|
4101
4183
|
let e;
|
|
4102
4184
|
try {
|
|
4103
|
-
e =
|
|
4185
|
+
e = li(t);
|
|
4104
4186
|
} catch (R) {
|
|
4105
4187
|
return (s = t.fail) == null || s.call(t, R), Promise.reject(R);
|
|
4106
4188
|
}
|
|
4107
4189
|
const r = H(!0);
|
|
4108
4190
|
if (r.isAppPlus)
|
|
4109
4191
|
try {
|
|
4110
|
-
e =
|
|
4192
|
+
e = gi(e);
|
|
4111
4193
|
} catch (R) {
|
|
4112
|
-
return (o = e.fail) == null || o.call(e, R), (
|
|
4194
|
+
return (o = e.fail) == null || o.call(e, R), (l = e.complete) == null || l.call(e, R), Promise.reject(R);
|
|
4113
4195
|
}
|
|
4114
4196
|
const n = r.isWeixinMiniProgram ? "已同步小程序卡片内容,请点击右上角“···”后发送给朋友。" : "正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";
|
|
4115
4197
|
if (r.isAppPlus)
|
|
4116
|
-
return
|
|
4117
|
-
var w,
|
|
4198
|
+
return wi(e).then((R) => {
|
|
4199
|
+
var w, k;
|
|
4118
4200
|
const F = m(g({}, R || {}), { hint: n });
|
|
4119
|
-
return (w = e.success) == null || w.call(e, F), (
|
|
4201
|
+
return (w = e.success) == null || w.call(e, F), (k = e.complete) == null || k.call(e, F), F;
|
|
4120
4202
|
}).catch((R) => {
|
|
4121
4203
|
var F, w;
|
|
4122
4204
|
return (F = e.fail) == null || F.call(e, R), (w = e.complete) == null || w.call(e, R), Promise.reject(R);
|
|
4123
4205
|
});
|
|
4124
4206
|
if (r.isWeixinMiniProgram)
|
|
4125
4207
|
try {
|
|
4126
|
-
Nt(
|
|
4208
|
+
Nt(mi(e, t.rowCustom), "shareMiniProgramCard");
|
|
4127
4209
|
const R = { success: !0, hint: n };
|
|
4128
4210
|
return (u = e.success) == null || u.call(e, R), (p = e.complete) == null || p.call(e, R), Promise.resolve(R);
|
|
4129
4211
|
} catch (R) {
|
|
4130
|
-
return (
|
|
4212
|
+
return (M = e.fail) == null || M.call(e, R), (_ = e.complete) == null || _.call(e, R), Promise.reject(R);
|
|
4131
4213
|
}
|
|
4132
4214
|
const i = { errMsg: "当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
|
|
4133
4215
|
return ($ = e.fail) == null || $.call(e, i), (ce = e.complete) == null || ce.call(e, i), Promise.reject(i);
|
|
@@ -4135,12 +4217,12 @@ function vt(t = {}) {
|
|
|
4135
4217
|
{ context: "shareMiniProgramCard", options: t }
|
|
4136
4218
|
);
|
|
4137
4219
|
}
|
|
4138
|
-
function
|
|
4220
|
+
function yi(t = {}) {
|
|
4139
4221
|
return new Promise((e, r) => {
|
|
4140
|
-
|
|
4222
|
+
Tt(m(g({}, t), { success: e, fail: r }));
|
|
4141
4223
|
});
|
|
4142
4224
|
}
|
|
4143
|
-
const
|
|
4225
|
+
const Ii = {
|
|
4144
4226
|
OFF: "off",
|
|
4145
4227
|
// 蓝牙关闭
|
|
4146
4228
|
ON: "on",
|
|
@@ -4149,20 +4231,20 @@ const yi = {
|
|
|
4149
4231
|
// 不支持蓝牙
|
|
4150
4232
|
UNAUTHORIZED: "unauthorized"
|
|
4151
4233
|
// 未授权
|
|
4152
|
-
},
|
|
4234
|
+
}, Ai = {
|
|
4153
4235
|
allowDuplicatesKey: !1,
|
|
4154
4236
|
// 是否允许重复上报同一设备
|
|
4155
4237
|
services: []
|
|
4156
4238
|
// 指定服务 UUID 列表
|
|
4157
4239
|
};
|
|
4158
|
-
function
|
|
4159
|
-
return g(g({},
|
|
4240
|
+
function be(t = {}) {
|
|
4241
|
+
return g(g({}, Ai), t);
|
|
4160
4242
|
}
|
|
4161
4243
|
function we() {
|
|
4162
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
4244
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
4163
4245
|
}
|
|
4164
|
-
function
|
|
4165
|
-
return
|
|
4246
|
+
function Pi(t) {
|
|
4247
|
+
return d.safeExecute(() => I(null, null, function* () {
|
|
4166
4248
|
var e;
|
|
4167
4249
|
if (!window.wx) {
|
|
4168
4250
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
@@ -4171,7 +4253,7 @@ function Ai(t) {
|
|
|
4171
4253
|
}
|
|
4172
4254
|
oe() || (a.info("等待微信配置完成"), yield Q()), wx.openBluetoothAdapter({
|
|
4173
4255
|
success: () => {
|
|
4174
|
-
a.info("微信蓝牙适配器已打开"),
|
|
4256
|
+
a.info("微信蓝牙适配器已打开"), vt(t);
|
|
4175
4257
|
},
|
|
4176
4258
|
fail: (r) => {
|
|
4177
4259
|
var n;
|
|
@@ -4180,8 +4262,8 @@ function Ai(t) {
|
|
|
4180
4262
|
});
|
|
4181
4263
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
4182
4264
|
}
|
|
4183
|
-
function
|
|
4184
|
-
return
|
|
4265
|
+
function Ci(t) {
|
|
4266
|
+
return d.safeExecute(() => {
|
|
4185
4267
|
a.debug("通过 WebView 桥接调用蓝牙功能", t), O("bluetooth", t, {
|
|
4186
4268
|
success: (e) => {
|
|
4187
4269
|
var r;
|
|
@@ -4196,7 +4278,7 @@ function Pi(t) {
|
|
|
4196
4278
|
}, { context: "bluetoothInUniApp" });
|
|
4197
4279
|
}
|
|
4198
4280
|
function _i(t) {
|
|
4199
|
-
return
|
|
4281
|
+
return d.safeExecute(() => {
|
|
4200
4282
|
var e;
|
|
4201
4283
|
a.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), O("bluetoothDevicesDiscovery", {
|
|
4202
4284
|
action: "startBluetoothDevicesDiscovery",
|
|
@@ -4219,7 +4301,7 @@ function _i(t) {
|
|
|
4219
4301
|
}
|
|
4220
4302
|
const ye = /* @__PURE__ */ new Set();
|
|
4221
4303
|
function Mi(t, e = {}) {
|
|
4222
|
-
return
|
|
4304
|
+
return d.safeExecute(() => {
|
|
4223
4305
|
var r;
|
|
4224
4306
|
return ye.add(t), ye.size === 1 && O("onBluetoothDeviceFound", {
|
|
4225
4307
|
action: "onBluetoothDeviceFound",
|
|
@@ -4231,7 +4313,7 @@ function Mi(t, e = {}) {
|
|
|
4231
4313
|
}, {
|
|
4232
4314
|
success: (n) => {
|
|
4233
4315
|
ye.forEach((i) => {
|
|
4234
|
-
typeof i == "function" ?
|
|
4316
|
+
typeof i == "function" ? d.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
4235
4317
|
});
|
|
4236
4318
|
},
|
|
4237
4319
|
fail: (n) => {
|
|
@@ -4242,8 +4324,8 @@ function Mi(t, e = {}) {
|
|
|
4242
4324
|
}), () => ye.delete(t);
|
|
4243
4325
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
4244
4326
|
}
|
|
4245
|
-
function
|
|
4246
|
-
return
|
|
4327
|
+
function Ri(t) {
|
|
4328
|
+
return d.safeExecute(() => {
|
|
4247
4329
|
var e;
|
|
4248
4330
|
a.debug("通过 WebView 桥接调用蓝牙连接功能", t), O("bluetoothConnection", {
|
|
4249
4331
|
action: "createBLEConnection",
|
|
@@ -4265,90 +4347,90 @@ function Ci(t) {
|
|
|
4265
4347
|
});
|
|
4266
4348
|
}, { context: "createBLEConnectionInUniApp" });
|
|
4267
4349
|
}
|
|
4268
|
-
function
|
|
4269
|
-
return
|
|
4350
|
+
function Si(t = {}) {
|
|
4351
|
+
return d.safeExecute(() => {
|
|
4270
4352
|
var r;
|
|
4271
4353
|
if (!we()) {
|
|
4272
4354
|
const n = {
|
|
4273
|
-
errMsg: `当前环境 (${
|
|
4355
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4274
4356
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4275
4357
|
};
|
|
4276
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4358
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
4277
4359
|
return;
|
|
4278
4360
|
}
|
|
4279
|
-
const e =
|
|
4361
|
+
const e = be(t);
|
|
4280
4362
|
a.info("开始蓝牙操作", {
|
|
4281
|
-
platform:
|
|
4363
|
+
platform: f.type,
|
|
4282
4364
|
services: e.services,
|
|
4283
4365
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
4284
|
-
}),
|
|
4366
|
+
}), C() ? Pi(e) : Ci(e);
|
|
4285
4367
|
}, { context: "openBluetoothAdapter", options: t });
|
|
4286
4368
|
}
|
|
4287
|
-
function
|
|
4288
|
-
return
|
|
4369
|
+
function Oi(t = {}) {
|
|
4370
|
+
return d.safeExecute(() => {
|
|
4289
4371
|
var r, n;
|
|
4290
4372
|
if (!we()) {
|
|
4291
4373
|
const i = {
|
|
4292
|
-
errMsg: `当前环境 (${
|
|
4374
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4293
4375
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4294
4376
|
};
|
|
4295
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4377
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
4296
4378
|
return;
|
|
4297
4379
|
}
|
|
4298
|
-
const e =
|
|
4380
|
+
const e = be(t);
|
|
4299
4381
|
a.info("开始搜索蓝牙设备", {
|
|
4300
|
-
platform:
|
|
4382
|
+
platform: f.type,
|
|
4301
4383
|
services: e.services,
|
|
4302
4384
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
4303
|
-
}),
|
|
4385
|
+
}), C() ? startBluetoothDevicesDiscoveryInWeixin(e) : _i(e);
|
|
4304
4386
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
4305
4387
|
}
|
|
4306
|
-
function
|
|
4307
|
-
return
|
|
4388
|
+
function vt(t, e = {}) {
|
|
4389
|
+
return d.safeExecute(() => {
|
|
4308
4390
|
var n, i;
|
|
4309
4391
|
if (!we()) {
|
|
4310
4392
|
const s = {
|
|
4311
|
-
errMsg: `当前环境 (${
|
|
4393
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4312
4394
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4313
4395
|
};
|
|
4314
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4396
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (n = e.fail) == null || n.call(e, s), (i = e.complete) == null || i.call(e, s);
|
|
4315
4397
|
return;
|
|
4316
4398
|
}
|
|
4317
|
-
const r =
|
|
4318
|
-
a.info("注册蓝牙设备发现监听", { platform:
|
|
4399
|
+
const r = be(e);
|
|
4400
|
+
a.info("注册蓝牙设备发现监听", { platform: f.type }), C() ? onBluetoothDeviceFoundInWeixin(r) : Mi(t, r);
|
|
4319
4401
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
4320
4402
|
}
|
|
4321
|
-
function
|
|
4322
|
-
return
|
|
4323
|
-
var s, o,
|
|
4403
|
+
function Ni(t = {}) {
|
|
4404
|
+
return d.safeExecute(() => {
|
|
4405
|
+
var s, o, l, u;
|
|
4324
4406
|
if (!we()) {
|
|
4325
4407
|
const p = {
|
|
4326
|
-
errMsg: `当前环境 (${
|
|
4408
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4327
4409
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4328
4410
|
};
|
|
4329
|
-
a.error("平台不支持蓝牙连接", { platform:
|
|
4411
|
+
a.error("平台不支持蓝牙连接", { platform: f.type }), (s = t.fail) == null || s.call(t, p), (o = t.complete) == null || o.call(t, p);
|
|
4330
4412
|
return;
|
|
4331
4413
|
}
|
|
4332
|
-
const e =
|
|
4414
|
+
const e = be(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
4333
4415
|
if (!n) {
|
|
4334
4416
|
const p = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
4335
|
-
(
|
|
4417
|
+
(l = t.fail) == null || l.call(t, p), (u = t.complete) == null || u.call(t, p);
|
|
4336
4418
|
return;
|
|
4337
4419
|
}
|
|
4338
|
-
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform:
|
|
4420
|
+
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: f.type }), C() ? uni.createBLEConnection({
|
|
4339
4421
|
deviceId: n,
|
|
4340
4422
|
autoConnect: i,
|
|
4341
4423
|
success: t.success,
|
|
4342
4424
|
fail: t.fail,
|
|
4343
4425
|
complete: t.complete
|
|
4344
|
-
}) :
|
|
4426
|
+
}) : Ri(e);
|
|
4345
4427
|
}, { context: "createBLEConnection", options: t });
|
|
4346
4428
|
}
|
|
4347
|
-
function
|
|
4429
|
+
function bi() {
|
|
4348
4430
|
return {
|
|
4349
4431
|
supported: we(),
|
|
4350
|
-
environment:
|
|
4351
|
-
implementation:
|
|
4432
|
+
environment: f.type,
|
|
4433
|
+
implementation: C() ? "weixin" : "webview",
|
|
4352
4434
|
features: {
|
|
4353
4435
|
discovery: !0,
|
|
4354
4436
|
connect: !0,
|
|
@@ -4361,14 +4443,14 @@ function Ni() {
|
|
|
4361
4443
|
const Ti = {
|
|
4362
4444
|
// TODO: 添加更多默认配置
|
|
4363
4445
|
};
|
|
4364
|
-
function
|
|
4446
|
+
function vi(t = {}) {
|
|
4365
4447
|
return g(g({}, Ti), t);
|
|
4366
4448
|
}
|
|
4367
|
-
function
|
|
4368
|
-
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
4449
|
+
function Lt() {
|
|
4450
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
4369
4451
|
}
|
|
4370
|
-
function
|
|
4371
|
-
return
|
|
4452
|
+
function Li(t) {
|
|
4453
|
+
return d.safeExecute(() => {
|
|
4372
4454
|
a.debug("通过 WebView 桥接调用打印PDF", t), O("printPdf", m(g({}, t), {
|
|
4373
4455
|
isPersistent: !0
|
|
4374
4456
|
// 强制禁用超时自动清理
|
|
@@ -4388,28 +4470,28 @@ function vi(t) {
|
|
|
4388
4470
|
platform: "uniapp"
|
|
4389
4471
|
});
|
|
4390
4472
|
}
|
|
4391
|
-
function
|
|
4392
|
-
return
|
|
4473
|
+
function xi(t = {}) {
|
|
4474
|
+
return d.safeExecute(() => {
|
|
4393
4475
|
var r;
|
|
4394
|
-
if (!
|
|
4476
|
+
if (!Lt()) {
|
|
4395
4477
|
const n = {
|
|
4396
|
-
errMsg: `当前环境 (${
|
|
4478
|
+
errMsg: `当前环境 (${f.type}) 不支持打印PDF功能`,
|
|
4397
4479
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4398
4480
|
};
|
|
4399
|
-
a.error("平台不支持打印PDF", { platform:
|
|
4481
|
+
a.error("平台不支持打印PDF", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
4400
4482
|
return;
|
|
4401
4483
|
}
|
|
4402
|
-
const e =
|
|
4403
|
-
a.info("开始打印PDF", { platform:
|
|
4484
|
+
const e = vi(t);
|
|
4485
|
+
a.info("开始打印PDF", { platform: f.type }), Li(e);
|
|
4404
4486
|
}, {
|
|
4405
4487
|
context: "printPdf",
|
|
4406
4488
|
options: t
|
|
4407
4489
|
});
|
|
4408
4490
|
}
|
|
4409
|
-
function
|
|
4491
|
+
function Di() {
|
|
4410
4492
|
return {
|
|
4411
|
-
supported:
|
|
4412
|
-
environment:
|
|
4493
|
+
supported: Lt(),
|
|
4494
|
+
environment: f.type,
|
|
4413
4495
|
implementation: "uniapp",
|
|
4414
4496
|
features: {
|
|
4415
4497
|
asyncSupport: !0
|
|
@@ -4417,7 +4499,7 @@ function xi() {
|
|
|
4417
4499
|
};
|
|
4418
4500
|
}
|
|
4419
4501
|
const xe = "/pages/face/index";
|
|
4420
|
-
function
|
|
4502
|
+
function Ui(t = {}) {
|
|
4421
4503
|
const e = g({}, t);
|
|
4422
4504
|
if (!e.name || typeof e.name != "string" || !e.name.trim())
|
|
4423
4505
|
throw {
|
|
@@ -4431,26 +4513,26 @@ function Di(t = {}) {
|
|
|
4431
4513
|
};
|
|
4432
4514
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
4433
4515
|
}
|
|
4434
|
-
function
|
|
4435
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
4516
|
+
function xt() {
|
|
4517
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(f.type);
|
|
4436
4518
|
}
|
|
4437
|
-
function
|
|
4519
|
+
function Wi() {
|
|
4438
4520
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
4439
4521
|
}
|
|
4440
|
-
function
|
|
4522
|
+
function $i(t) {
|
|
4441
4523
|
const e = m(g({}, t), {
|
|
4442
4524
|
title: document.title || "",
|
|
4443
4525
|
url: window.location.href || ""
|
|
4444
4526
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
4445
4527
|
return r ? `${xe}?${r}` : xe;
|
|
4446
4528
|
}
|
|
4447
|
-
function
|
|
4448
|
-
return
|
|
4449
|
-
if (!
|
|
4529
|
+
function Fi(t) {
|
|
4530
|
+
return d.safeExecute(() => {
|
|
4531
|
+
if (!Wi()) {
|
|
4450
4532
|
a.error("微信小程序导航API不可用");
|
|
4451
4533
|
return;
|
|
4452
4534
|
}
|
|
4453
|
-
const e =
|
|
4535
|
+
const e = $i(t);
|
|
4454
4536
|
a.debug("跳转宿主人脸识别页面", {
|
|
4455
4537
|
name: t.name,
|
|
4456
4538
|
targetUrl: e
|
|
@@ -4468,10 +4550,10 @@ function $i(t) {
|
|
|
4468
4550
|
platform: "weixin"
|
|
4469
4551
|
});
|
|
4470
4552
|
}
|
|
4471
|
-
function
|
|
4472
|
-
return
|
|
4553
|
+
function ki(t) {
|
|
4554
|
+
return d.safeExecute(() => {
|
|
4473
4555
|
a.debug("通过 WebView 桥接调用人脸识别", {
|
|
4474
|
-
platform:
|
|
4556
|
+
platform: f.type,
|
|
4475
4557
|
name: t.name
|
|
4476
4558
|
}), O("faceVerify", g({}, t), {
|
|
4477
4559
|
success: (e) => {
|
|
@@ -4487,62 +4569,62 @@ function Fi(t) {
|
|
|
4487
4569
|
});
|
|
4488
4570
|
}
|
|
4489
4571
|
function Bi(t = {}) {
|
|
4490
|
-
return
|
|
4491
|
-
if (!
|
|
4492
|
-
a.error("平台不支持人脸识别", { platform:
|
|
4572
|
+
return d.safeExecute(() => {
|
|
4573
|
+
if (!xt()) {
|
|
4574
|
+
a.error("平台不支持人脸识别", { platform: f.type });
|
|
4493
4575
|
return;
|
|
4494
4576
|
}
|
|
4495
4577
|
let e;
|
|
4496
4578
|
try {
|
|
4497
|
-
e =
|
|
4579
|
+
e = Ui(t);
|
|
4498
4580
|
} catch (r) {
|
|
4499
4581
|
a.error("人脸识别参数校验失败", r);
|
|
4500
4582
|
return;
|
|
4501
4583
|
}
|
|
4502
4584
|
if (a.info("开始人脸识别", {
|
|
4503
|
-
platform:
|
|
4585
|
+
platform: f.type,
|
|
4504
4586
|
name: e.name,
|
|
4505
4587
|
pagePath: xe
|
|
4506
|
-
}),
|
|
4507
|
-
|
|
4588
|
+
}), C()) {
|
|
4589
|
+
Fi(e);
|
|
4508
4590
|
return;
|
|
4509
4591
|
}
|
|
4510
|
-
|
|
4592
|
+
ki(e);
|
|
4511
4593
|
}, {
|
|
4512
4594
|
context: "faceVerify",
|
|
4513
4595
|
options: t
|
|
4514
4596
|
});
|
|
4515
4597
|
}
|
|
4516
|
-
function
|
|
4598
|
+
function Gi() {
|
|
4517
4599
|
let t = "weixin";
|
|
4518
|
-
return
|
|
4519
|
-
supported:
|
|
4520
|
-
environment:
|
|
4600
|
+
return f.type === "UniApp" && (t = "uniapp"), {
|
|
4601
|
+
supported: xt(),
|
|
4602
|
+
environment: f.type,
|
|
4521
4603
|
implementation: t,
|
|
4522
4604
|
features: {
|
|
4523
4605
|
asyncSupport: !0,
|
|
4524
|
-
hostPageNavigation:
|
|
4525
|
-
hostBridge:
|
|
4606
|
+
hostPageNavigation: C(),
|
|
4607
|
+
hostBridge: f.type === "UniApp"
|
|
4526
4608
|
}
|
|
4527
4609
|
};
|
|
4528
4610
|
}
|
|
4529
|
-
const
|
|
4530
|
-
function
|
|
4611
|
+
const Dt = H();
|
|
4612
|
+
function Ki() {
|
|
4531
4613
|
if (typeof window == "undefined" || !H(!0).isWeixinMiniProgram)
|
|
4532
4614
|
return !1;
|
|
4533
4615
|
const e = ve().getRuntimeConfig();
|
|
4534
4616
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4535
4617
|
}
|
|
4536
|
-
function
|
|
4537
|
-
return
|
|
4538
|
-
yield
|
|
4618
|
+
function Vi() {
|
|
4619
|
+
return I(this, null, function* () {
|
|
4620
|
+
yield or(), Ki() && (yield Q());
|
|
4539
4621
|
});
|
|
4540
4622
|
}
|
|
4541
4623
|
z.useResponse(ct.response, { priority: 1e3 });
|
|
4542
4624
|
let Ze = !1;
|
|
4543
4625
|
function Qe() {
|
|
4544
4626
|
if (Ze) return;
|
|
4545
|
-
Ze = !0,
|
|
4627
|
+
Ze = !0, Or([
|
|
4546
4628
|
{ name: "load-weixin-sdk", run: at, timeoutMs: 8e3 },
|
|
4547
4629
|
{ name: "init-bridge", run: nt, timeoutMs: 8e3 }
|
|
4548
4630
|
], {
|
|
@@ -4552,19 +4634,19 @@ function Qe() {
|
|
|
4552
4634
|
});
|
|
4553
4635
|
}
|
|
4554
4636
|
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(Qe, 0) : document.addEventListener("DOMContentLoaded", Qe));
|
|
4555
|
-
function
|
|
4637
|
+
function y(t, { apiName: e } = {}) {
|
|
4556
4638
|
return function(r = {}, ...n) {
|
|
4557
4639
|
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), s = r && typeof r == "object" ? r : {}, o = () => i ? t(s, ...n) : new Promise((u, p) => {
|
|
4558
|
-
const
|
|
4559
|
-
success: (
|
|
4560
|
-
typeof s.success == "function" && s.success(
|
|
4640
|
+
const M = m(g({}, s), {
|
|
4641
|
+
success: (_) => {
|
|
4642
|
+
typeof s.success == "function" && s.success(_), u(_);
|
|
4561
4643
|
},
|
|
4562
|
-
fail: (
|
|
4563
|
-
typeof s.fail == "function" && s.fail(
|
|
4644
|
+
fail: (_) => {
|
|
4645
|
+
typeof s.fail == "function" && s.fail(_), p(_);
|
|
4564
4646
|
},
|
|
4565
4647
|
complete: s.complete
|
|
4566
4648
|
});
|
|
4567
|
-
t(
|
|
4649
|
+
t(M, ...n);
|
|
4568
4650
|
});
|
|
4569
4651
|
return (typeof window == "undefined" ? Promise.resolve() : rt()).then(() => o()).catch((u) => {
|
|
4570
4652
|
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, u), u;
|
|
@@ -4574,13 +4656,13 @@ function E(t, { apiName: e } = {}) {
|
|
|
4574
4656
|
function Ie(t) {
|
|
4575
4657
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4576
4658
|
}
|
|
4577
|
-
const Wt =
|
|
4578
|
-
function
|
|
4579
|
-
const e = () =>
|
|
4659
|
+
const Ut = y(Yr), Wt = y(Xr), $t = y(Zr), Ft = y(Qr), kt = y(en), Bt = y(tn);
|
|
4660
|
+
function Gt(t) {
|
|
4661
|
+
const e = () => rn(t);
|
|
4580
4662
|
return (typeof window == "undefined" ? Promise.resolve() : rt()).then(() => e());
|
|
4581
4663
|
}
|
|
4582
|
-
const Fe =
|
|
4583
|
-
function
|
|
4664
|
+
const Fe = y(un, { apiName: "getCode" });
|
|
4665
|
+
function qi(t = {}) {
|
|
4584
4666
|
return new Promise((e, r) => {
|
|
4585
4667
|
Fe(m(g({}, t), {
|
|
4586
4668
|
success: e,
|
|
@@ -4588,37 +4670,37 @@ function Vi(t = {}) {
|
|
|
4588
4670
|
}));
|
|
4589
4671
|
});
|
|
4590
4672
|
}
|
|
4591
|
-
const
|
|
4673
|
+
const ke = y(hn, {
|
|
4592
4674
|
apiName: "navigateToMiniProgram"
|
|
4593
4675
|
});
|
|
4594
|
-
function
|
|
4676
|
+
function ji(t = {}) {
|
|
4595
4677
|
return new Promise((e, r) => {
|
|
4596
|
-
|
|
4678
|
+
ke(m(g({}, t), {
|
|
4597
4679
|
success: e,
|
|
4598
4680
|
fail: r
|
|
4599
4681
|
}));
|
|
4600
4682
|
});
|
|
4601
4683
|
}
|
|
4602
|
-
const
|
|
4603
|
-
function
|
|
4684
|
+
const Be = y(Mn);
|
|
4685
|
+
function Ji(t = {}) {
|
|
4604
4686
|
return new Promise((e, r) => {
|
|
4605
|
-
|
|
4687
|
+
Be(m(g({}, t), {
|
|
4606
4688
|
success: e,
|
|
4607
4689
|
fail: r
|
|
4608
4690
|
}));
|
|
4609
4691
|
});
|
|
4610
4692
|
}
|
|
4611
|
-
const
|
|
4612
|
-
function
|
|
4693
|
+
const Kt = y(xi);
|
|
4694
|
+
function Hi(t = {}) {
|
|
4613
4695
|
return new Promise((e, r) => {
|
|
4614
|
-
|
|
4696
|
+
Kt(m(g({}, t), {
|
|
4615
4697
|
success: e,
|
|
4616
4698
|
fail: r
|
|
4617
4699
|
}));
|
|
4618
4700
|
});
|
|
4619
4701
|
}
|
|
4620
|
-
const Ge =
|
|
4621
|
-
function
|
|
4702
|
+
const Ge = y(Tn), zi = y(Bi);
|
|
4703
|
+
function Yi(t = {}) {
|
|
4622
4704
|
return new Promise((e, r) => {
|
|
4623
4705
|
Ge(m(g({}, t), {
|
|
4624
4706
|
success: e,
|
|
@@ -4626,8 +4708,8 @@ function zi(t = {}) {
|
|
|
4626
4708
|
}));
|
|
4627
4709
|
});
|
|
4628
4710
|
}
|
|
4629
|
-
const
|
|
4630
|
-
function
|
|
4711
|
+
const Xi = y(bt, { apiName: "shareDirected" }), Zi = y(Ei, { apiName: "shareDirectedAsync" }), Qi = y(Et, { apiName: "manualShare" }), ea = y(An, { apiName: "manualShareAsync" }), Ke = y(kn);
|
|
4712
|
+
function ta(t = {}) {
|
|
4631
4713
|
return new Promise((e, r) => {
|
|
4632
4714
|
Ke(m(g({}, t), {
|
|
4633
4715
|
success: e,
|
|
@@ -4635,8 +4717,8 @@ function ea(t = {}) {
|
|
|
4635
4717
|
}));
|
|
4636
4718
|
});
|
|
4637
4719
|
}
|
|
4638
|
-
const Ve =
|
|
4639
|
-
function
|
|
4720
|
+
const Ve = y(Bn);
|
|
4721
|
+
function ra(t = {}) {
|
|
4640
4722
|
return new Promise((e, r) => {
|
|
4641
4723
|
Ve(m(g({}, t), {
|
|
4642
4724
|
success: e,
|
|
@@ -4644,8 +4726,8 @@ function ta(t = {}) {
|
|
|
4644
4726
|
}));
|
|
4645
4727
|
});
|
|
4646
4728
|
}
|
|
4647
|
-
const qe =
|
|
4648
|
-
function
|
|
4729
|
+
const qe = y(Zn);
|
|
4730
|
+
function na(t = {}) {
|
|
4649
4731
|
return new Promise((e, r) => {
|
|
4650
4732
|
qe(m(g({}, t), {
|
|
4651
4733
|
success: e,
|
|
@@ -4653,78 +4735,78 @@ function ra(t = {}) {
|
|
|
4653
4735
|
}));
|
|
4654
4736
|
});
|
|
4655
4737
|
}
|
|
4656
|
-
const
|
|
4657
|
-
function
|
|
4738
|
+
const Vt = y(Si);
|
|
4739
|
+
function ia(t = {}) {
|
|
4658
4740
|
return new Promise((e, r) => {
|
|
4659
|
-
|
|
4741
|
+
Vt(m(g({}, t), {
|
|
4660
4742
|
success: e,
|
|
4661
4743
|
fail: r
|
|
4662
4744
|
}));
|
|
4663
4745
|
});
|
|
4664
4746
|
}
|
|
4665
|
-
const
|
|
4666
|
-
function
|
|
4747
|
+
const qt = y(Oi);
|
|
4748
|
+
function aa(t = {}) {
|
|
4667
4749
|
return new Promise((e, r) => {
|
|
4668
|
-
|
|
4750
|
+
qt(m(g({}, t), {
|
|
4669
4751
|
success: e,
|
|
4670
4752
|
fail: r
|
|
4671
4753
|
}));
|
|
4672
4754
|
});
|
|
4673
4755
|
}
|
|
4674
|
-
const
|
|
4675
|
-
function
|
|
4756
|
+
const jt = y(vt);
|
|
4757
|
+
function sa(t = {}) {
|
|
4676
4758
|
return new Promise((e, r) => {
|
|
4677
|
-
|
|
4759
|
+
jt(m(g({}, t), {
|
|
4678
4760
|
success: e,
|
|
4679
4761
|
fail: r
|
|
4680
4762
|
}));
|
|
4681
4763
|
});
|
|
4682
4764
|
}
|
|
4683
|
-
const
|
|
4684
|
-
function
|
|
4765
|
+
const Jt = y(Ni);
|
|
4766
|
+
function oa(t = {}) {
|
|
4685
4767
|
return new Promise((e, r) => {
|
|
4686
|
-
|
|
4768
|
+
Jt(m(g({}, t), {
|
|
4687
4769
|
success: e,
|
|
4688
4770
|
fail: r
|
|
4689
4771
|
}));
|
|
4690
4772
|
});
|
|
4691
4773
|
}
|
|
4692
|
-
const
|
|
4774
|
+
const ca = y(Tt, { apiName: "shareMiniProgramCard" }), ua = y(yi, { apiName: "shareMiniProgramCardAsync" }), se = {
|
|
4693
4775
|
// 导航 API
|
|
4694
|
-
navigateTo:
|
|
4695
|
-
navigateBack:
|
|
4696
|
-
switchTab:
|
|
4697
|
-
reLaunch:
|
|
4776
|
+
navigateTo: Ut,
|
|
4777
|
+
navigateBack: Wt,
|
|
4778
|
+
switchTab: $t,
|
|
4779
|
+
reLaunch: Ft,
|
|
4698
4780
|
redirectTo: kt,
|
|
4699
4781
|
// 消息 API
|
|
4700
|
-
postMessage:
|
|
4701
|
-
getEnv:
|
|
4782
|
+
postMessage: Bt,
|
|
4783
|
+
getEnv: Gt,
|
|
4702
4784
|
getCode: Fe,
|
|
4703
|
-
getCodeAsync:
|
|
4704
|
-
navigateToMiniProgram:
|
|
4705
|
-
navigateToMiniProgramAsync:
|
|
4785
|
+
getCodeAsync: qi,
|
|
4786
|
+
navigateToMiniProgram: ke,
|
|
4787
|
+
navigateToMiniProgramAsync: ji,
|
|
4706
4788
|
// 图片 API
|
|
4707
|
-
chooseImage:
|
|
4708
|
-
chooseImageAsync:
|
|
4789
|
+
chooseImage: Be,
|
|
4790
|
+
chooseImageAsync: Ji,
|
|
4709
4791
|
// 扫码 API
|
|
4710
4792
|
scanCode: Ge,
|
|
4711
|
-
scanCodeAsync:
|
|
4793
|
+
scanCodeAsync: Yi,
|
|
4712
4794
|
// 位置 API
|
|
4713
4795
|
getLocation: Ke,
|
|
4714
|
-
getLocationAsync:
|
|
4796
|
+
getLocationAsync: ta,
|
|
4715
4797
|
openLocation: Ve,
|
|
4716
|
-
openLocationAsync:
|
|
4798
|
+
openLocationAsync: ra,
|
|
4717
4799
|
chooseLocation: qe,
|
|
4718
|
-
chooseLocationAsync:
|
|
4800
|
+
chooseLocationAsync: na,
|
|
4719
4801
|
// 位置监听 API(保留回调签名)
|
|
4720
|
-
onLocationChange: (t) =>
|
|
4721
|
-
offLocationChange: (t) =>
|
|
4722
|
-
onLocationChangeError: (t) =>
|
|
4723
|
-
offLocationChangeError: (t) =>
|
|
4724
|
-
startLocationUpdate:
|
|
4725
|
-
stopLocationUpdate:
|
|
4802
|
+
onLocationChange: (t) => y((e = {}) => qn(e.success), { apiName: "onLocationChange" })(Ie(t)),
|
|
4803
|
+
offLocationChange: (t) => y((e = {}) => jn(e.success), { apiName: "offLocationChange" })(Ie(t)),
|
|
4804
|
+
onLocationChangeError: (t) => y((e = {}) => Jn(e.success), { apiName: "onLocationChangeError" })(Ie(t)),
|
|
4805
|
+
offLocationChangeError: (t) => y((e = {}) => Hn(e.success), { apiName: "offLocationChangeError" })(Ie(t)),
|
|
4806
|
+
startLocationUpdate: y(Kn, { apiName: "startLocationUpdate" }),
|
|
4807
|
+
stopLocationUpdate: y(Vn, { apiName: "stopLocationUpdate" }),
|
|
4726
4808
|
// 环境信息
|
|
4727
|
-
environment:
|
|
4809
|
+
environment: Dt,
|
|
4728
4810
|
/**
|
|
4729
4811
|
* Wait for SDK readiness.
|
|
4730
4812
|
* In Weixin mini-program web-view, if qsh.config({ clientId }) was called,
|
|
@@ -4734,7 +4816,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4734
4816
|
* await qsh.ready()
|
|
4735
4817
|
* @since 2.0.0
|
|
4736
4818
|
*/
|
|
4737
|
-
ready:
|
|
4819
|
+
ready: Vi,
|
|
4738
4820
|
/**
|
|
4739
4821
|
* 手动初始化 JSBridge
|
|
4740
4822
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -4751,7 +4833,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4751
4833
|
* if (qsh.isReady()) { console.log('ready') }
|
|
4752
4834
|
* @since 2.0.0
|
|
4753
4835
|
*/
|
|
4754
|
-
isReady:
|
|
4836
|
+
isReady: tr,
|
|
4755
4837
|
/**
|
|
4756
4838
|
* 获取当前 SDK 状态
|
|
4757
4839
|
* @returns {string}
|
|
@@ -4759,7 +4841,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4759
4841
|
* console.log(qsh.getState()) // 'ready'
|
|
4760
4842
|
* @since 2.0.0
|
|
4761
4843
|
*/
|
|
4762
|
-
getState:
|
|
4844
|
+
getState: rr,
|
|
4763
4845
|
config: He,
|
|
4764
4846
|
// 微信配置 API
|
|
4765
4847
|
weixin: {
|
|
@@ -4787,7 +4869,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4787
4869
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
4788
4870
|
* @since 2.0.0
|
|
4789
4871
|
*/
|
|
4790
|
-
getConfigState:
|
|
4872
|
+
getConfigState: dr,
|
|
4791
4873
|
/**
|
|
4792
4874
|
* 手动重试微信配置
|
|
4793
4875
|
* @returns {Promise<void>}
|
|
@@ -4795,13 +4877,13 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4795
4877
|
* await qsh.weixin.retryConfig()
|
|
4796
4878
|
* @since 2.0.0
|
|
4797
4879
|
*/
|
|
4798
|
-
retryConfig:
|
|
4880
|
+
retryConfig: gr
|
|
4799
4881
|
},
|
|
4800
4882
|
// WebView 对象(兼容旧版本)
|
|
4801
4883
|
webView: null,
|
|
4802
4884
|
// 图片相关常量
|
|
4803
|
-
ImageSourceTypes:
|
|
4804
|
-
ImageSizeTypes:
|
|
4885
|
+
ImageSourceTypes: Ce,
|
|
4886
|
+
ImageSizeTypes: _e,
|
|
4805
4887
|
/**
|
|
4806
4888
|
* 获取图片功能能力信息
|
|
4807
4889
|
* @returns {Object} 能力信息对象
|
|
@@ -4810,7 +4892,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4810
4892
|
* console.log('是否支持:', capabilities.supported)
|
|
4811
4893
|
* @since 2.0.0
|
|
4812
4894
|
*/
|
|
4813
|
-
getImageCapabilities:
|
|
4895
|
+
getImageCapabilities: Rn,
|
|
4814
4896
|
// 扫码相关常量
|
|
4815
4897
|
ScanTypes: X,
|
|
4816
4898
|
/**
|
|
@@ -4821,7 +4903,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4821
4903
|
* console.log('是否支持:', capabilities.supported)
|
|
4822
4904
|
* @since 2.1.0
|
|
4823
4905
|
*/
|
|
4824
|
-
getScanCapabilities:
|
|
4906
|
+
getScanCapabilities: vn,
|
|
4825
4907
|
// 位置相关常量
|
|
4826
4908
|
CoordinateTypes: ae,
|
|
4827
4909
|
/**
|
|
@@ -4832,7 +4914,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4832
4914
|
* console.log('是否支持:', capabilities.supported)
|
|
4833
4915
|
* @since 2.1.0
|
|
4834
4916
|
*/
|
|
4835
|
-
getLocationCapabilities:
|
|
4917
|
+
getLocationCapabilities: Gn,
|
|
4836
4918
|
/**
|
|
4837
4919
|
* 获取位置选择功能能力信息
|
|
4838
4920
|
* @returns {Object} 能力信息对象
|
|
@@ -4841,28 +4923,28 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4841
4923
|
* console.log('是否支持:', capabilities.supported)
|
|
4842
4924
|
* @since 2.1.0
|
|
4843
4925
|
*/
|
|
4844
|
-
getChooseLocationCapabilities:
|
|
4926
|
+
getChooseLocationCapabilities: Qn,
|
|
4845
4927
|
// 蓝牙 API
|
|
4846
|
-
openBluetoothAdapter:
|
|
4847
|
-
openBluetoothAdapterAsync:
|
|
4848
|
-
startBluetoothDevicesDiscovery:
|
|
4849
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
4850
|
-
onBluetoothDeviceFound:
|
|
4851
|
-
onBluetoothDeviceFoundAsync:
|
|
4852
|
-
createBLEConnection:
|
|
4853
|
-
createBLEConnectionAsync:
|
|
4928
|
+
openBluetoothAdapter: Vt,
|
|
4929
|
+
openBluetoothAdapterAsync: ia,
|
|
4930
|
+
startBluetoothDevicesDiscovery: qt,
|
|
4931
|
+
startBluetoothDevicesDiscoveryAsync: aa,
|
|
4932
|
+
onBluetoothDeviceFound: jt,
|
|
4933
|
+
onBluetoothDeviceFoundAsync: sa,
|
|
4934
|
+
createBLEConnection: Jt,
|
|
4935
|
+
createBLEConnectionAsync: oa,
|
|
4854
4936
|
// 蓝牙相关常量
|
|
4855
|
-
BluetoothStates:
|
|
4937
|
+
BluetoothStates: Ii,
|
|
4856
4938
|
//微信分享(定向模块)
|
|
4857
4939
|
/** 定向分享模块:仅 H5->宿主 WebView,图文/文字/图片到微信会话/朋友圈 */
|
|
4858
|
-
shareDirected:
|
|
4859
|
-
shareDirectedAsync:
|
|
4940
|
+
shareDirected: Xi,
|
|
4941
|
+
shareDirectedAsync: Zi,
|
|
4860
4942
|
/** 手动分享预览:仅微信小程序 web-view,通过 postMessage + navigateBack 触发宿主弹窗 */
|
|
4861
|
-
manualShare:
|
|
4862
|
-
manualShareAsync:
|
|
4943
|
+
manualShare: Qi,
|
|
4944
|
+
manualShareAsync: ea,
|
|
4863
4945
|
/** 微信小程序卡片:仅发送给朋友,不改现有 shareDirected */
|
|
4864
|
-
shareMiniProgramCard:
|
|
4865
|
-
shareMiniProgramCardAsync:
|
|
4946
|
+
shareMiniProgramCard: ca,
|
|
4947
|
+
shareMiniProgramCardAsync: ua,
|
|
4866
4948
|
/**
|
|
4867
4949
|
* 获取蓝牙功能能力信息
|
|
4868
4950
|
* @returns {Object} 能力信息对象
|
|
@@ -4870,10 +4952,10 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4870
4952
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
4871
4953
|
* console.log('是否支持:', capabilities.supported)
|
|
4872
4954
|
*/
|
|
4873
|
-
getBluetoothCapabilities:
|
|
4955
|
+
getBluetoothCapabilities: bi,
|
|
4874
4956
|
// 打印PDF API
|
|
4875
|
-
printPdf:
|
|
4876
|
-
printPdfAsync:
|
|
4957
|
+
printPdf: Kt,
|
|
4958
|
+
printPdfAsync: Hi,
|
|
4877
4959
|
/**
|
|
4878
4960
|
* 获取打印PDF功能能力信息
|
|
4879
4961
|
* @returns {Object} 能力信息对象
|
|
@@ -4881,10 +4963,10 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4881
4963
|
* const capabilities = qsh.getPrintCapabilities()
|
|
4882
4964
|
* console.log('是否支持:', capabilities.supported)
|
|
4883
4965
|
*/
|
|
4884
|
-
getPrintCapabilities:
|
|
4966
|
+
getPrintCapabilities: Di,
|
|
4885
4967
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4886
|
-
faceVerify:
|
|
4887
|
-
getFaceCapabilities:
|
|
4968
|
+
faceVerify: zi,
|
|
4969
|
+
getFaceCapabilities: Gi,
|
|
4888
4970
|
// 插件系统
|
|
4889
4971
|
plugins: {
|
|
4890
4972
|
/**
|
|
@@ -4949,10 +5031,10 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4949
5031
|
* 内置拦截器
|
|
4950
5032
|
*/
|
|
4951
5033
|
builtin: {
|
|
4952
|
-
logging:
|
|
5034
|
+
logging: mr,
|
|
4953
5035
|
performance: q,
|
|
4954
|
-
createRetry:
|
|
4955
|
-
createValidation:
|
|
5036
|
+
createRetry: wr,
|
|
5037
|
+
createValidation: Er,
|
|
4956
5038
|
errorNormalizer: ct
|
|
4957
5039
|
}
|
|
4958
5040
|
},
|
|
@@ -4998,7 +5080,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4998
5080
|
* @example
|
|
4999
5081
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
5000
5082
|
*/
|
|
5001
|
-
create:
|
|
5083
|
+
create: Mr,
|
|
5002
5084
|
/**
|
|
5003
5085
|
* 判断是否为标准错误
|
|
5004
5086
|
* @param {any} error - 错误对象
|
|
@@ -5006,7 +5088,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5006
5088
|
* @example
|
|
5007
5089
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
5008
5090
|
*/
|
|
5009
|
-
isStandard:
|
|
5091
|
+
isStandard: Rr
|
|
5010
5092
|
},
|
|
5011
5093
|
// 状态管理
|
|
5012
5094
|
store: {
|
|
@@ -5054,15 +5136,15 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5054
5136
|
/**
|
|
5055
5137
|
* 日志记录器
|
|
5056
5138
|
*/
|
|
5057
|
-
logger:
|
|
5139
|
+
logger: L,
|
|
5058
5140
|
/**
|
|
5059
5141
|
* 设置外部日志 reporter,便于对接埋点/观测
|
|
5060
5142
|
*/
|
|
5061
|
-
setLogReporter: (t) =>
|
|
5143
|
+
setLogReporter: (t) => L.setReporter(t),
|
|
5062
5144
|
/**
|
|
5063
5145
|
* 错误处理器
|
|
5064
5146
|
*/
|
|
5065
|
-
errorHandler:
|
|
5147
|
+
errorHandler: d,
|
|
5066
5148
|
/**
|
|
5067
5149
|
* 状态管理器
|
|
5068
5150
|
*/
|
|
@@ -5072,7 +5154,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5072
5154
|
* @example
|
|
5073
5155
|
* qsh.debug.enableDevMode()
|
|
5074
5156
|
*/
|
|
5075
|
-
enableDevMode: () =>
|
|
5157
|
+
enableDevMode: () => L.enableDevMode(),
|
|
5076
5158
|
/**
|
|
5077
5159
|
* 获取日志历史
|
|
5078
5160
|
* @param {number} [count] - 获取条数
|
|
@@ -5080,7 +5162,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5080
5162
|
* @example
|
|
5081
5163
|
* console.log(qsh.debug.getLogs(10))
|
|
5082
5164
|
*/
|
|
5083
|
-
getLogs: (t) =>
|
|
5165
|
+
getLogs: (t) => L.getHistory(t),
|
|
5084
5166
|
/**
|
|
5085
5167
|
* 获取 SDK 统计信息
|
|
5086
5168
|
* @returns {Object} 统计信息
|
|
@@ -5088,7 +5170,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5088
5170
|
* console.log(qsh.debug.getStats())
|
|
5089
5171
|
*/
|
|
5090
5172
|
getStats: () => ({
|
|
5091
|
-
logger:
|
|
5173
|
+
logger: L.getStats(),
|
|
5092
5174
|
state: Y.getStats(),
|
|
5093
5175
|
weixinConfig: ve().getStats(),
|
|
5094
5176
|
plugins: fe.getStats(),
|
|
@@ -5108,20 +5190,20 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5108
5190
|
* @example
|
|
5109
5191
|
* console.log(qsh.debug.exportDebugInfo())
|
|
5110
5192
|
*/
|
|
5111
|
-
exportDebugInfo: () =>
|
|
5193
|
+
exportDebugInfo: () => L.exportToJSON()
|
|
5112
5194
|
}
|
|
5113
5195
|
};
|
|
5114
|
-
|
|
5115
|
-
navigateTo:
|
|
5116
|
-
navigateBack:
|
|
5117
|
-
switchTab:
|
|
5118
|
-
reLaunch:
|
|
5196
|
+
Dt.isWeixinMiniProgram ? se.webView = window.wx && window.wx.miniProgram : se.webView = {
|
|
5197
|
+
navigateTo: Ut,
|
|
5198
|
+
navigateBack: Wt,
|
|
5199
|
+
switchTab: $t,
|
|
5200
|
+
reLaunch: Ft,
|
|
5119
5201
|
redirectTo: kt,
|
|
5120
|
-
postMessage:
|
|
5121
|
-
getEnv:
|
|
5202
|
+
postMessage: Bt,
|
|
5203
|
+
getEnv: Gt,
|
|
5122
5204
|
getCode: Fe,
|
|
5123
|
-
navigateToMiniProgram:
|
|
5124
|
-
chooseImage:
|
|
5205
|
+
navigateToMiniProgram: ke,
|
|
5206
|
+
chooseImage: Be,
|
|
5125
5207
|
scanCode: Ge,
|
|
5126
5208
|
getLocation: Ke,
|
|
5127
5209
|
openLocation: Ve,
|