crh-jssdk 0.10.23 → 0.10.24
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/declare.d.ts +1 -0
- package/dist/index.js +34 -0
- package/package.json +2 -4
- package/tsconfig.json +1 -1
- package/yalc.lock +1 -1
- package/business/assets/cx_share.png +0 -0
- package/business/base/crh-app-sdk-cxzq.js +0 -501
- package/business/base/crh-app-sdk-cxzq.ts +0 -468
- package/business/base/index.js +0 -50
- package/business/base/index.ts +0 -47
- package/business/common/utils.js +0 -117
- package/business/index.js +0 -271
- package/business/index.ts +0 -210
- package/business/mall/crh-app-sdk-cxzq.js +0 -758
- package/business/mall/crh-app-sdk.js +0 -164
- package/business/mall/index.js +0 -208
- package/business/profession/crh-app-sdk-cxzq.js +0 -421
- package/business/profession/crh-app-sdk-cxzq.ts +0 -351
- package/business/profession/index.js +0 -51
- package/business/profession/index.ts +0 -53
- package/business/user/crh-app-sdk-cxzq.js +0 -276
- package/business/user/crh-app-sdk-cxzq.ts +0 -192
- package/business/user/crh-app-sdk-cy.js +0 -39
- package/business/user/crh-app-sdk-cy.ts +0 -46
- package/business/user/index.js +0 -52
- package/business/user/index.ts +0 -45
- package/business/utils/index.js +0 -165
- package/business/utils/index.ts +0 -122
package/declare.d.ts
CHANGED
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var index_1 = __importDefault(require("./business/index"));
|
|
22
|
+
function JSSDK(sdkType) {
|
|
23
|
+
var System = index_1.default;
|
|
24
|
+
return /** @class */ (function (_super) {
|
|
25
|
+
__extends(class_1, _super);
|
|
26
|
+
function class_1(option) {
|
|
27
|
+
var _this = _super.call(this, option) || this;
|
|
28
|
+
_this.sdkType = sdkType;
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
return class_1;
|
|
32
|
+
}(System));
|
|
33
|
+
}
|
|
34
|
+
exports.default = JSSDK;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crh-jssdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.24",
|
|
4
4
|
"description": "crh-jssdk",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc"
|
|
8
8
|
},
|
|
@@ -16,7 +16,5 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"typescript": "^5.5.2"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
19
|
}
|
|
22
20
|
}
|
package/tsconfig.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
16
16
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
17
17
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
18
|
-
|
|
18
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
19
19
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
20
20
|
// "composite": true, /* Enable project compilation */
|
|
21
21
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
package/yalc.lock
CHANGED
|
Binary file
|
|
@@ -1,501 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var utils_1 = require("../utils");
|
|
54
|
-
var cx_share_png_1 = __importDefault(require("../assets/cx_share.png"));
|
|
55
|
-
var crh_app_sdk_cxzq_1 = __importDefault(require("../profession/crh-app-sdk-cxzq"));
|
|
56
|
-
/**
|
|
57
|
-
* @name 版本号比较
|
|
58
|
-
* @param {string} version1 版本号1
|
|
59
|
-
* @param {string} version2 版本号2
|
|
60
|
-
* @returns 1: 版本1大于版本2 | -1: 版本1小于版本2 | 0: 版本相等
|
|
61
|
-
*/
|
|
62
|
-
var compareVersion = function (version1, version2) {
|
|
63
|
-
version1 = version1.split(".");
|
|
64
|
-
version2 = version2.split(".");
|
|
65
|
-
var n = Math.max(version1.length, version2.length);
|
|
66
|
-
for (var i = 0; i < n; i++) {
|
|
67
|
-
var code1 = version1[i] === undefined ? 0 : parseInt(version1[i], 10);
|
|
68
|
-
var code2 = version2[i] === undefined ? 0 : parseInt(version2[i], 10);
|
|
69
|
-
if (code1 > code2) {
|
|
70
|
-
return 1;
|
|
71
|
-
}
|
|
72
|
-
if (code1 < code2) {
|
|
73
|
-
return -1;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return 0;
|
|
77
|
-
};
|
|
78
|
-
// webview类型
|
|
79
|
-
var webviewType = (function () {
|
|
80
|
-
var ua = navigator.userAgent;
|
|
81
|
-
var isWTSDK = ua.includes("cxzqwtsdk");
|
|
82
|
-
return {
|
|
83
|
-
isWTSDK: isWTSDK,
|
|
84
|
-
// 新乐赚
|
|
85
|
-
isNewLeZhuan: !isWTSDK && ua.toLowerCase().includes("lezhuan"),
|
|
86
|
-
// 新聚财
|
|
87
|
-
isNewJuCai: !isWTSDK &&
|
|
88
|
-
!ua.includes("crhsdk") &&
|
|
89
|
-
(ua.includes("Android_CFZQ_JUCAI") || ua.includes("iOS_CFZQ_JUCAI")),
|
|
90
|
-
// 老聚财
|
|
91
|
-
isOldJuCai: ua.includes("crhsdk") && !ua.includes("cfzqsdk"),
|
|
92
|
-
isLeZhuan: (!isWTSDK && ua.toLowerCase().includes("lezhuan")) ||
|
|
93
|
-
ua.includes("cfzqsdk"),
|
|
94
|
-
isCRH: ua.includes("crhsdk") || ua.includes("crhapp"),
|
|
95
|
-
};
|
|
96
|
-
})();
|
|
97
|
-
var actionMap = {
|
|
98
|
-
// 财信处理action地址方法
|
|
99
|
-
onJsOverrideUrlLoading: function (str) {
|
|
100
|
-
var _a, _b, _c;
|
|
101
|
-
if (utils_1.ios && ((_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.lzforward)) {
|
|
102
|
-
(_c = window.webkit.messageHandlers.lzforward) === null || _c === void 0 ? void 0 : _c.postMessage(str);
|
|
103
|
-
}
|
|
104
|
-
else if (window.MyWebView && window.MyWebView.onJsOverrideUrlLoading) {
|
|
105
|
-
window.MyWebView.onJsOverrideUrlLoading(str);
|
|
106
|
-
}
|
|
107
|
-
else if (window.HarmonyOS && window.HarmonyOS.onJsOverrideUrlLoading) {
|
|
108
|
-
window.HarmonyOS.onJsOverrideUrlLoading(str);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
window.location.href = str;
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
// 财信调用action路径
|
|
115
|
-
callAction: function (actionId, param, cbFunName) {
|
|
116
|
-
var url = "http://action:".concat(actionId, "/?target=2");
|
|
117
|
-
if (param) {
|
|
118
|
-
var paramStr = JSON.stringify(param);
|
|
119
|
-
url += "¶m=".concat(encodeURIComponent(paramStr));
|
|
120
|
-
}
|
|
121
|
-
if (cbFunName) {
|
|
122
|
-
url += "&callback=".concat(cbFunName);
|
|
123
|
-
}
|
|
124
|
-
console.log("callAction:", url);
|
|
125
|
-
this.onJsOverrideUrlLoading(url);
|
|
126
|
-
},
|
|
127
|
-
// 财信聚财通过js bridge调用app接口
|
|
128
|
-
setupWebViewJavascriptBridge: function (callback) {
|
|
129
|
-
if (window.WebViewJavascriptBridge) {
|
|
130
|
-
callback(window.WebViewJavascriptBridge);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
document.addEventListener("WebViewJavascriptBridgeReady", function () {
|
|
134
|
-
callback(window.WebViewJavascriptBridge);
|
|
135
|
-
}, false);
|
|
136
|
-
if (!/android/gi.test(navigator.userAgent)) {
|
|
137
|
-
if (window.WebViewJavascriptBridge) {
|
|
138
|
-
callback(window.WebViewJavascriptBridge);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (window.WVJBCallbacks) {
|
|
142
|
-
window.WVJBCallbacks.push(callback);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
window.WVJBCallbacks = [callback];
|
|
146
|
-
var WVJBIframe_1 = document.createElement("iframe");
|
|
147
|
-
WVJBIframe_1.style.display = "none";
|
|
148
|
-
WVJBIframe_1.src = "wvjbscheme://__BRIDGE_LOADED__";
|
|
149
|
-
document.documentElement.appendChild(WVJBIframe_1);
|
|
150
|
-
setTimeout(function () {
|
|
151
|
-
document.documentElement.removeChild(WVJBIframe_1);
|
|
152
|
-
}, 0);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
// 聚财Android调用app接口
|
|
157
|
-
callAndroidActionOfJvCai: function (param) {
|
|
158
|
-
var paramStr = JSON.stringify(param);
|
|
159
|
-
if (window.mobile) {
|
|
160
|
-
window.mobile.onActionEvent(paramStr);
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
// 财信调用聚财方法
|
|
164
|
-
callJuCaiAction: function (funName, data, callback) {
|
|
165
|
-
console.log("callJuCaiAction:", funName, data, callback);
|
|
166
|
-
if (utils_1.ios) {
|
|
167
|
-
this.setupWebViewJavascriptBridge(function (bridge) {
|
|
168
|
-
bridge.callHandler(funName, data, window[callback]);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
var param = {
|
|
173
|
-
funName: funName,
|
|
174
|
-
callbackFunName: callback,
|
|
175
|
-
};
|
|
176
|
-
if (data) {
|
|
177
|
-
param.data = data;
|
|
178
|
-
}
|
|
179
|
-
this.callAndroidActionOfJvCai(param);
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
/**
|
|
183
|
-
* iOS客户端方法加载函数(老乐赚老聚财)
|
|
184
|
-
* @param {string} url
|
|
185
|
-
*/
|
|
186
|
-
loadIOSNative: function (url) {
|
|
187
|
-
var iFrame = "";
|
|
188
|
-
iFrame = document.createElement("iframe");
|
|
189
|
-
iFrame.setAttribute("src", url);
|
|
190
|
-
iFrame.setAttribute("style", "display:none;");
|
|
191
|
-
iFrame.setAttribute("height", "0px");
|
|
192
|
-
iFrame.setAttribute("width", "0px");
|
|
193
|
-
iFrame.setAttribute("frameborder", "0");
|
|
194
|
-
document.body.appendChild(iFrame);
|
|
195
|
-
iFrame.parentNode.removeChild(iFrame);
|
|
196
|
-
iFrame = null;
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
try {
|
|
200
|
-
if (!utils_1.ios && webviewType.isNewJuCai) {
|
|
201
|
-
actionMap.setupWebViewJavascriptBridge(function (bridge) {
|
|
202
|
-
bridge.init();
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
catch (e) {
|
|
207
|
-
console.log("初始化失败");
|
|
208
|
-
}
|
|
209
|
-
exports.default = {
|
|
210
|
-
compareVersion: compareVersion,
|
|
211
|
-
actionMap: actionMap,
|
|
212
|
-
webviewType: function () {
|
|
213
|
-
return webviewType;
|
|
214
|
-
},
|
|
215
|
-
//是否在app内
|
|
216
|
-
isApp: function () {
|
|
217
|
-
var ua = navigator.userAgent;
|
|
218
|
-
var isAppFlags = [
|
|
219
|
-
"crhsdk",
|
|
220
|
-
"crhapp",
|
|
221
|
-
"cfzqsdk",
|
|
222
|
-
"LeZhuan",
|
|
223
|
-
"LEZHUAN",
|
|
224
|
-
"lezhuan",
|
|
225
|
-
"Android_CFZQ_JUCAI",
|
|
226
|
-
"iOS_CFZQ_JUCAI",
|
|
227
|
-
];
|
|
228
|
-
return isAppFlags.some(function (flag) { return ua.includes(flag); });
|
|
229
|
-
},
|
|
230
|
-
// 拦截Android物理返回键事件,并回调给前端 --- 仅安卓
|
|
231
|
-
interceptBack: function (callback) {
|
|
232
|
-
window.jtoJHandle.interceptBack("interceptBackCallBack");
|
|
233
|
-
window.interceptBackCallBack = function (e) {
|
|
234
|
-
callback && callback(e);
|
|
235
|
-
};
|
|
236
|
-
},
|
|
237
|
-
// 关闭页面 closeSJKH
|
|
238
|
-
closeSJKH: function () {
|
|
239
|
-
if (webviewType.isNewLeZhuan) {
|
|
240
|
-
actionMap.callAction(3);
|
|
241
|
-
}
|
|
242
|
-
else if (webviewType.isNewJuCai) {
|
|
243
|
-
// iphone
|
|
244
|
-
actionMap.callJuCaiAction("closePage", {});
|
|
245
|
-
}
|
|
246
|
-
else if (utils_1.ios) {
|
|
247
|
-
// iphone
|
|
248
|
-
window.location.href = "objc://callIOSQuit/";
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
window.jtoJHandle.closeSJKH();
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
/**
|
|
255
|
-
* 跳转个股详情页
|
|
256
|
-
*/
|
|
257
|
-
goStockDetail: function (params) {
|
|
258
|
-
var code = params.code, market = params.market;
|
|
259
|
-
if (webviewType.isNewLeZhuan) {
|
|
260
|
-
actionMap.callAction(923, {
|
|
261
|
-
code: code,
|
|
262
|
-
market: market,
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
/**
|
|
267
|
-
* 通过pageId打开新的webview打开外部链接
|
|
268
|
-
*/
|
|
269
|
-
goWebview: function (params) {
|
|
270
|
-
var sdk = params.sdk, h5 = params.h5, _a = params.h5url, h5url = _a === void 0 ? "" : _a, productCode = params.productCode;
|
|
271
|
-
var jsonObj = {
|
|
272
|
-
indexUrl: h5,
|
|
273
|
-
uploadPicUrl: "",
|
|
274
|
-
cookieDomain: "",
|
|
275
|
-
closeBusiness: "closeCallBack",
|
|
276
|
-
module: "",
|
|
277
|
-
identifier: "zt",
|
|
278
|
-
};
|
|
279
|
-
var jsonStr = JSON.stringify(jsonObj);
|
|
280
|
-
if (!this.isApp()) {
|
|
281
|
-
window.location.href = h5url;
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (webviewType.isNewLeZhuan) {
|
|
285
|
-
actionMap.callAction(207, __assign({ pageId: sdk || "1", needLogin: "0" }, (productCode ? { param: { productCode: productCode } } : {})));
|
|
286
|
-
}
|
|
287
|
-
else if (webviewType.isNewJuCai) {
|
|
288
|
-
actionMap.callJuCaiAction("gotoClientPage", __assign({ pageId: utils_1.ios ? String(sdk) : sdk, needLogin: "0" }, (productCode ? { param: { productCode: productCode } } : {})));
|
|
289
|
-
}
|
|
290
|
-
else if (utils_1.ios) {
|
|
291
|
-
// iphone
|
|
292
|
-
actionMap.loadIOSNative("objc://openNewBusiness/$?".concat(jsonStr));
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
window.jtoJHandle.openNewBusiness(jsonStr);
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
/**
|
|
299
|
-
* 通过打开新的webview打开外部链接
|
|
300
|
-
* @param {string} url 跳转地址
|
|
301
|
-
* @param {boolean} needTitle 打开新webview是否需要页头1需要0不需要
|
|
302
|
-
*/
|
|
303
|
-
goWebview2: function (_a) {
|
|
304
|
-
var _b, _c;
|
|
305
|
-
var _d = _a.url, url = _d === void 0 ? "" : _d, _e = _a.needTitle, needTitle = _e === void 0 ? false : _e, _f = _a.noNewWebView, noNewWebView = _f === void 0 ? false : _f;
|
|
306
|
-
var targetUrl = url === null || url === void 0 ? void 0 : url.trim();
|
|
307
|
-
if (!targetUrl) {
|
|
308
|
-
console.log("targetUrl不能为空");
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
var urlParams = {};
|
|
312
|
-
var prefix = "";
|
|
313
|
-
if (targetUrl.includes("#")) {
|
|
314
|
-
prefix = targetUrl.split("#")[1].includes("?") ? "&" : "?";
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
prefix = targetUrl.includes("?") ? "&" : "?";
|
|
318
|
-
}
|
|
319
|
-
var from = "";
|
|
320
|
-
if (!targetUrl.includes("from=")) {
|
|
321
|
-
from = "from=newMall";
|
|
322
|
-
urlParams.from = "newMall";
|
|
323
|
-
}
|
|
324
|
-
var currentPage = window.location.hash
|
|
325
|
-
? (_b = window.location.hash.match(/#([^?]*)/)) === null || _b === void 0 ? void 0 : _b[1]
|
|
326
|
-
: "/";
|
|
327
|
-
urlParams.fromPage = currentPage;
|
|
328
|
-
if (!noNewWebView) {
|
|
329
|
-
// 新开webview
|
|
330
|
-
urlParams.opentype = "newpage";
|
|
331
|
-
}
|
|
332
|
-
if (webviewType.isNewJuCai) {
|
|
333
|
-
delete urlParams.opentype;
|
|
334
|
-
}
|
|
335
|
-
if (!needTitle && !targetUrl.includes("needtitle=")) {
|
|
336
|
-
// 不显示原生标题栏
|
|
337
|
-
urlParams.needtitle = "0";
|
|
338
|
-
}
|
|
339
|
-
if (targetUrl.includes("#") &&
|
|
340
|
-
(urlParams.opentype || urlParams.needtitle)) {
|
|
341
|
-
// opentype和needtitle处理,需在#号前加
|
|
342
|
-
var tempUrl = targetUrl.split("#");
|
|
343
|
-
var preParams = {};
|
|
344
|
-
if (urlParams.opentype && !tempUrl[0].includes("opentype=")) {
|
|
345
|
-
preParams.opentype = urlParams.opentype;
|
|
346
|
-
}
|
|
347
|
-
if (urlParams.needtitle && !tempUrl[0].includes("needtitle=")) {
|
|
348
|
-
preParams.needtitle = urlParams.needtitle;
|
|
349
|
-
}
|
|
350
|
-
var fromAppTab = sessionStorage.getItem("fromAppTab") || "";
|
|
351
|
-
if (+fromAppTab === 1 && !tempUrl[0].includes("fromAppTab=")) {
|
|
352
|
-
preParams.fromAppTab = "1";
|
|
353
|
-
}
|
|
354
|
-
var urlParamsStr_1 = new URLSearchParams(preParams).toString();
|
|
355
|
-
targetUrl = "".concat(tempUrl[0]).concat(tempUrl[0].includes("?") ? "&" : "?").concat(urlParamsStr_1, "#").concat(tempUrl[1]);
|
|
356
|
-
}
|
|
357
|
-
if (urlParams.opentype) {
|
|
358
|
-
// 新开标识
|
|
359
|
-
urlParams.isInNewWebView = "1";
|
|
360
|
-
}
|
|
361
|
-
/* if (+getSessionStore('fromAppTab') === 1) {
|
|
362
|
-
urlParams.fromAppTab = '1';
|
|
363
|
-
} */
|
|
364
|
-
var urlParamsStr = new URLSearchParams(urlParams).toString();
|
|
365
|
-
var mregeUrl = "".concat(targetUrl).concat(prefix).concat(urlParamsStr);
|
|
366
|
-
console.log("goWebView:", mregeUrl);
|
|
367
|
-
if (webviewType.isNewLeZhuan) {
|
|
368
|
-
window.location.href = mregeUrl;
|
|
369
|
-
}
|
|
370
|
-
else if (webviewType.isNewJuCai) {
|
|
371
|
-
if (urlParams.opentype) {
|
|
372
|
-
if (utils_1.ios) {
|
|
373
|
-
actionMap.setupWebViewJavascriptBridge(function (bridge) {
|
|
374
|
-
bridge.callHandler("gotoNextPage", {
|
|
375
|
-
needtitle: needTitle ? "1" : "0",
|
|
376
|
-
url: url,
|
|
377
|
-
}, function (data) {
|
|
378
|
-
console.log("goWebview:", data);
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
// {“pageId”: “2804”, “needLogin”: “true”, “title”: “网页标题”, “url”: “http://www.baidu.com”}
|
|
384
|
-
// pageId=2804表示跳转客户端默认webview,pageId=5002跳转客户端无标题webview;needLogin=1表示需要先登录委托,未登录委托情况下会先跳转客户端委托登录
|
|
385
|
-
actionMap.callJuCaiAction("goWebViewPage", {
|
|
386
|
-
pageId: needTitle ? "2804" : "5002",
|
|
387
|
-
url: url,
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
// 聚财新开webview体验有问题,因此统一走location.href
|
|
393
|
-
window.location.href = url;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
var paramsObj = {
|
|
398
|
-
indexUrl: url,
|
|
399
|
-
};
|
|
400
|
-
paramsObj = JSON.stringify(paramsObj);
|
|
401
|
-
if (utils_1.ios) {
|
|
402
|
-
actionMap.loadIOSNative("objc://openNewBusiness/$?".concat(paramsObj));
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
(_c = window.jtoJHandle) === null || _c === void 0 ? void 0 : _c.openNewBusiness(paramsObj);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
/**
|
|
410
|
-
* 获取客户端版本号
|
|
411
|
-
*/
|
|
412
|
-
getVersion: function () {
|
|
413
|
-
var ua = navigator.userAgent.toLowerCase();
|
|
414
|
-
var regex = "";
|
|
415
|
-
if (webviewType.isNewLeZhuan) {
|
|
416
|
-
regex = utils_1.ios || (0, utils_1.checkIsHarmonyOS)() ? /cfzq_lezhuan_([\d.]+)/ : /cfzq_lezhuan([\d.]+)/;
|
|
417
|
-
}
|
|
418
|
-
else if (webviewType.isNewJuCai) {
|
|
419
|
-
regex = /cfzq_jucai_([\d.]+)/;
|
|
420
|
-
}
|
|
421
|
-
var match = ua.match(regex);
|
|
422
|
-
console.log(match, "===match===");
|
|
423
|
-
if (match) {
|
|
424
|
-
var version = match[1];
|
|
425
|
-
return version;
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
console.warn("version没有找到匹配项");
|
|
429
|
-
return "0.0.0";
|
|
430
|
-
}
|
|
431
|
-
},
|
|
432
|
-
/**
|
|
433
|
-
* 设置原生状态栏颜色(乐赚客户端)
|
|
434
|
-
* @param {object} params
|
|
435
|
-
* @param {string} params.color 状态栏背景颜色,如#ff0000
|
|
436
|
-
* @param {string} params.wordColorStyle 状态栏文字颜色,0 白色,1 黑色
|
|
437
|
-
*/
|
|
438
|
-
setStatusBar: function (params) {
|
|
439
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
-
var data;
|
|
441
|
-
return __generator(this, function (_a) {
|
|
442
|
-
if (webviewType.isNewLeZhuan) {
|
|
443
|
-
if (compareVersion("6.1.0", this.getVersion()) === 1) {
|
|
444
|
-
console.log("---版本号低,无法设置状态栏颜色---");
|
|
445
|
-
return [2 /*return*/];
|
|
446
|
-
}
|
|
447
|
-
data = {
|
|
448
|
-
statusColor: params.color,
|
|
449
|
-
isDark: params.wordColorStyle === "1",
|
|
450
|
-
};
|
|
451
|
-
actionMap.callAction(933, data);
|
|
452
|
-
}
|
|
453
|
-
else if (webviewType.isCRH) {
|
|
454
|
-
if (utils_1.ios) {
|
|
455
|
-
actionMap.loadIOSNative("objc://setAppBackgroundColor/$?".concat(params.color));
|
|
456
|
-
}
|
|
457
|
-
else if (window.jtoJHandle) {
|
|
458
|
-
window.jtoJHandle.setAppBackgroundColor(params.color);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return [2 /*return*/];
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
},
|
|
465
|
-
/**
|
|
466
|
-
* 分享
|
|
467
|
-
* @param {object} params
|
|
468
|
-
* @param {string} params.img_url 分享展示的图片
|
|
469
|
-
* @param {string} params.url 分享链接
|
|
470
|
-
* @param {string} params.title 标题
|
|
471
|
-
* @param {string} params.message 内容
|
|
472
|
-
*/
|
|
473
|
-
share: function (params) {
|
|
474
|
-
var _this = this;
|
|
475
|
-
if (webviewType.isLeZhuan) {
|
|
476
|
-
var shareParam = {
|
|
477
|
-
img_url: params.img_url || cx_share_png_1.default,
|
|
478
|
-
url: params.url,
|
|
479
|
-
title: params.title,
|
|
480
|
-
message: params.message,
|
|
481
|
-
};
|
|
482
|
-
if (webviewType.isNewLeZhuan) {
|
|
483
|
-
actionMap.callAction(900, shareParam, "");
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
crh_app_sdk_cxzq_1.default.businessAlertView("http://action:900/?target=2¶m=".concat(encodeURIComponent(JSON.stringify(shareParam))));
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
491
|
-
return __generator(this, function (_a) {
|
|
492
|
-
resolve({
|
|
493
|
-
error_no: "-3",
|
|
494
|
-
error_info: "当前APP不支持分享",
|
|
495
|
-
});
|
|
496
|
-
return [2 /*return*/];
|
|
497
|
-
});
|
|
498
|
-
}); });
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
};
|