crh-jssdk 1.0.12 → 1.0.14
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.
|
@@ -133,23 +133,31 @@ exports.default = {
|
|
|
133
133
|
*/
|
|
134
134
|
goWebview: function (params) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
var url, _a, needTitle, pageId, gotoUrl, error_3;
|
|
137
|
-
return __generator(this, function (
|
|
138
|
-
switch (
|
|
136
|
+
var url, _a, needTitle, _b, isWt, pageId, gotoUrl, error_3;
|
|
137
|
+
return __generator(this, function (_c) {
|
|
138
|
+
switch (_c.label) {
|
|
139
139
|
case 0:
|
|
140
|
-
url = params.url, _a = params.needTitle, needTitle = _a === void 0 ? true : _a;
|
|
141
|
-
|
|
140
|
+
url = params.url, _a = params.needTitle, needTitle = _a === void 0 ? true : _a, _b = params.isWt, isWt = _b === void 0 ? false : _b;
|
|
141
|
+
_c.label = 1;
|
|
142
142
|
case 1:
|
|
143
|
-
|
|
143
|
+
_c.trys.push([1, 3, , 4]);
|
|
144
144
|
pageId = utils_1.ios ? "5032" : "2804";
|
|
145
145
|
gotoUrl = "client.html?action=ymtz^webid=".concat(pageId, "^url=").concat(url, "^isHiddenNavigationBar=").concat(needTitle ? 1 : 0, "^isHiddenBottomBar=1^isNeedWtLogin=1");
|
|
146
|
+
if (isWt) {
|
|
147
|
+
gotoUrl = url;
|
|
148
|
+
}
|
|
149
|
+
if (utils_1.ios) {
|
|
150
|
+
window.location.href = gotoUrl;
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
}
|
|
153
|
+
console.log("goWebview入参", params);
|
|
146
154
|
console.log("金圆统一调用gotoNextPage,参数:", gotoUrl);
|
|
147
155
|
return [4 /*yield*/, utils_1.jyBridge.bridgeCallHandler("Promise", "gotoNextPage", {
|
|
148
156
|
url: gotoUrl,
|
|
149
157
|
})];
|
|
150
|
-
case 2: return [2 /*return*/,
|
|
158
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
151
159
|
case 3:
|
|
152
|
-
error_3 =
|
|
160
|
+
error_3 = _c.sent();
|
|
153
161
|
console.error("金圆统一跳转客户端页面失败:", error_3);
|
|
154
162
|
// 降级方案:使用 goWebview
|
|
155
163
|
return [2 /*return*/, { success: false }];
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.JYClientTHS = exports.jyBridge = exports.globalBridge = exports.Bridge = exports.JYBridge = void 0;
|
|
10
|
+
// 在脚本加载时立即初始化 WVJBCallbacks 数组
|
|
11
|
+
// 确保 native WebViewJavascriptBridge 在注入完成并调用 _callWVJBCallbacks 时,WVJBCallbacks 始终存在
|
|
12
|
+
// 避免 "TypeError: undefined is not an object (evaluating 'callbacks.length')" 错误
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
window.WVJBCallbacks = window.WVJBCallbacks || [];
|
|
15
|
+
}
|
|
10
16
|
/**
|
|
11
17
|
* ClientTHS全局桥接对象
|
|
12
18
|
* 实现同花顺客户端提供的ClientTHS SDK方式
|
|
@@ -37,7 +43,8 @@ var JYClientTHS = {
|
|
|
37
43
|
},
|
|
38
44
|
/**
|
|
39
45
|
* 连接WebViewJavascriptBridge
|
|
40
|
-
*
|
|
46
|
+
* 仅依赖 WebViewJavascriptBridgeReady 事件,不使用 iframe 注入方式
|
|
47
|
+
* 原因:WVJBCallbacks 已在脚本顶层立即初始化,确保 native _callWVJBCallbacks 调用时数组始终存在
|
|
41
48
|
*/
|
|
42
49
|
connectWebViewJavascriptBridge: function (callback) {
|
|
43
50
|
// 如果Bridge已存在,直接使用
|
|
@@ -45,27 +52,18 @@ var JYClientTHS = {
|
|
|
45
52
|
callback(window.WebViewJavascriptBridge);
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
48
|
-
// iOS设备:监听BridgeReady
|
|
49
|
-
// 与ClientTemplate.js保持一致的实现
|
|
55
|
+
// iOS设备:监听BridgeReady事件,不再使用iframe触发
|
|
50
56
|
if (!/Android/.test(navigator.userAgent)) {
|
|
51
57
|
// 监听BridgeReady事件
|
|
52
58
|
document.addEventListener('WebViewJavascriptBridgeReady', function () {
|
|
53
59
|
callback(window.WebViewJavascriptBridge);
|
|
54
60
|
}, false);
|
|
55
|
-
//
|
|
61
|
+
// WVJBCallbacks 已在脚本顶层初始化,此处直接 push 即可
|
|
56
62
|
if (window.WVJBCallbacks) {
|
|
57
63
|
window.WVJBCallbacks.push(callback);
|
|
58
64
|
}
|
|
59
65
|
else {
|
|
60
|
-
// 创建回调队列并通过iframe触发Bridge加载
|
|
61
66
|
window.WVJBCallbacks = [callback];
|
|
62
|
-
var iframe_1 = document.createElement('iframe');
|
|
63
|
-
iframe_1.style.display = 'none';
|
|
64
|
-
iframe_1.src = 'wvjbscheme://__BRIDGE_LOADED__';
|
|
65
|
-
document.documentElement.appendChild(iframe_1);
|
|
66
|
-
setTimeout(function () {
|
|
67
|
-
document.documentElement.removeChild(iframe_1);
|
|
68
|
-
}, 0);
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
},
|