crh-jssdk 0.10.28 → 0.10.30
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/dist/business/base/crh-app-sdk-lczq.js +31 -0
- package/dist/business/index.js +7 -0
- package/package.json +5 -2
- package/build.js +0 -66
- package/business/assets/cx_share.png +0 -0
- package/business/base/crh-app-sdk-cxzq.ts +0 -468
- package/business/base/crh-app-sdk-lczq.ts +0 -211
- package/business/base/index.ts +0 -47
- package/business/common/utils.js +0 -117
- package/business/index.js +0 -308
- package/business/index.ts +0 -249
- 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/crh-app-sdk-lczq.js +0 -376
- package/business/profession/crh-app-sdk-lczq.ts +0 -18
- 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/crh-app-sdk-lczq.js +0 -212
- package/business/user/crh-app-sdk-lczq.ts +0 -152
- package/business/user/index.js +0 -52
- package/business/user/index.ts +0 -45
- package/business/utils/bridge.js +0 -138
- package/business/utils/bridge.ts +0 -153
- package/business/utils/index.js +0 -169
- package/business/utils/index.ts +0 -125
- package/declare.d.ts +0 -47
- package/images.d.ts +0 -7
- package/index.js +0 -34
- package/index.ts +0 -17
- package/tsconfig.json +0 -72
- package/yalc.lock +0 -9
|
@@ -282,6 +282,37 @@ exports.default = {
|
|
|
282
282
|
return "0.0.0";
|
|
283
283
|
}
|
|
284
284
|
},
|
|
285
|
+
/**
|
|
286
|
+
* 关注公众号
|
|
287
|
+
* @param appid 公众号的appid,默认为wxf45c81345f5ea70e
|
|
288
|
+
*/
|
|
289
|
+
followOfficialAccount: function () {
|
|
290
|
+
return __awaiter(this, arguments, void 0, function (appid) {
|
|
291
|
+
var params, result, error_6;
|
|
292
|
+
if (appid === void 0) { appid = "wxf45c81345f5ea70e"; }
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
switch (_a.label) {
|
|
295
|
+
case 0:
|
|
296
|
+
_a.trys.push([0, 2, , 3]);
|
|
297
|
+
params = {
|
|
298
|
+
jumptype: "1",
|
|
299
|
+
downloadurl: "weixin://dl/officialaccounts?appid=".concat(appid),
|
|
300
|
+
};
|
|
301
|
+
console.log("调用关注公众号,参数:", params);
|
|
302
|
+
return [4 /*yield*/, utils_1.globalBridge.bridgeCallHandler("", "startApplication", params)];
|
|
303
|
+
case 1:
|
|
304
|
+
result = _a.sent();
|
|
305
|
+
console.log("关注公众号调用成功:", result);
|
|
306
|
+
return [2 /*return*/, result];
|
|
307
|
+
case 2:
|
|
308
|
+
error_6 = _a.sent();
|
|
309
|
+
console.error("关注公众号失败:", error_6);
|
|
310
|
+
throw error_6;
|
|
311
|
+
case 3: return [2 /*return*/];
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
},
|
|
285
316
|
/**
|
|
286
317
|
* 获取Bridge实例(供其他模块使用)
|
|
287
318
|
*/
|
package/dist/business/index.js
CHANGED
|
@@ -303,6 +303,13 @@ var BUSINESS = /** @class */ (function () {
|
|
|
303
303
|
}
|
|
304
304
|
return this.sdkObj.goBack();
|
|
305
305
|
};
|
|
306
|
+
//关注公众号
|
|
307
|
+
BUSINESS.prototype.followOfficialAccount = function (appid) {
|
|
308
|
+
if (!this.sdkObj.followOfficialAccount) {
|
|
309
|
+
return (0, utils_1.empty)("followOfficialAccount");
|
|
310
|
+
}
|
|
311
|
+
return this.sdkObj.followOfficialAccount(appid);
|
|
312
|
+
};
|
|
306
313
|
return BUSINESS;
|
|
307
314
|
}());
|
|
308
315
|
exports.default = BUSINESS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crh-jssdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.30",
|
|
4
4
|
"description": "crh-jssdk",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,5 +16,8 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"typescript": "^5.5.2"
|
|
19
|
-
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
]
|
|
20
23
|
}
|
package/build.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 构建脚本 - 编译 TypeScript 并复制资源文件
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const { execSync } = require('child_process');
|
|
10
|
-
|
|
11
|
-
console.log('🚀 开始构建...');
|
|
12
|
-
|
|
13
|
-
// 清理 dist 目录
|
|
14
|
-
console.log('🧹 清理 dist 目录...');
|
|
15
|
-
if (fs.existsSync('dist')) {
|
|
16
|
-
execSync('rm -rf dist', { stdio: 'inherit' });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// 编译 TypeScript
|
|
20
|
-
console.log('📦 编译 TypeScript...');
|
|
21
|
-
try {
|
|
22
|
-
execSync('tsc', { stdio: 'inherit' });
|
|
23
|
-
console.log('✅ TypeScript 编译完成');
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error('❌ TypeScript 编译失败:', error.message);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 复制资源文件
|
|
30
|
-
console.log('📁 复制资源文件...');
|
|
31
|
-
const assetsSource = 'business/assets';
|
|
32
|
-
const assetsTarget = 'dist/business/assets';
|
|
33
|
-
|
|
34
|
-
if (fs.existsSync(assetsSource)) {
|
|
35
|
-
// 确保目标目录存在
|
|
36
|
-
if (!fs.existsSync(path.dirname(assetsTarget))) {
|
|
37
|
-
fs.mkdirSync(path.dirname(assetsTarget), { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 复制整个 assets 目录
|
|
41
|
-
execSync(`cp -r ${assetsSource} ${path.dirname(assetsTarget)}/`, { stdio: 'inherit' });
|
|
42
|
-
console.log('✅ 资源文件复制完成');
|
|
43
|
-
} else {
|
|
44
|
-
console.log('⚠️ 未找到 assets 目录,跳过复制');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 复制其他可能需要复制的文件
|
|
48
|
-
const filesToCopy = [
|
|
49
|
-
'package.json',
|
|
50
|
-
'README.md'
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
filesToCopy.forEach(file => {
|
|
54
|
-
if (fs.existsSync(file)) {
|
|
55
|
-
// 确保目标目录存在
|
|
56
|
-
const targetDir = path.dirname(`dist/${file}`);
|
|
57
|
-
if (!fs.existsSync(targetDir)) {
|
|
58
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
59
|
-
}
|
|
60
|
-
fs.copyFileSync(file, `dist/${file}`);
|
|
61
|
-
console.log(`✅ 复制 ${file}`);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
console.log('🎉 构建完成!');
|
|
66
|
-
console.log('📂 输出目录: dist/');
|
|
Binary file
|
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
import { ios, checkIsHarmonyOS } from "../utils";
|
|
2
|
-
import ShareImg from "../assets/cx_share.png";
|
|
3
|
-
import ProfessionModel from "../profession/crh-app-sdk-cxzq";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @name 版本号比较
|
|
7
|
-
* @param {string} version1 版本号1
|
|
8
|
-
* @param {string} version2 版本号2
|
|
9
|
-
* @returns 1: 版本1大于版本2 | -1: 版本1小于版本2 | 0: 版本相等
|
|
10
|
-
*/
|
|
11
|
-
const compareVersion = (version1: any, version2: any) => {
|
|
12
|
-
version1 = version1.split(".");
|
|
13
|
-
version2 = version2.split(".");
|
|
14
|
-
const n = Math.max(version1.length, version2.length);
|
|
15
|
-
for (let i = 0; i < n; i++) {
|
|
16
|
-
const code1 = version1[i] === undefined ? 0 : parseInt(version1[i], 10);
|
|
17
|
-
const code2 = version2[i] === undefined ? 0 : parseInt(version2[i], 10);
|
|
18
|
-
if (code1 > code2) {
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
if (code1 < code2) {
|
|
22
|
-
return -1;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return 0;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// webview类型
|
|
29
|
-
const webviewType = (() => {
|
|
30
|
-
const ua = navigator.userAgent;
|
|
31
|
-
const isWTSDK = ua.includes("cxzqwtsdk");
|
|
32
|
-
return {
|
|
33
|
-
isWTSDK,
|
|
34
|
-
// 新乐赚
|
|
35
|
-
isNewLeZhuan: !isWTSDK && ua.toLowerCase().includes("lezhuan"),
|
|
36
|
-
// 新聚财
|
|
37
|
-
isNewJuCai:
|
|
38
|
-
!isWTSDK &&
|
|
39
|
-
!ua.includes("crhsdk") &&
|
|
40
|
-
(ua.includes("Android_CFZQ_JUCAI") || ua.includes("iOS_CFZQ_JUCAI")),
|
|
41
|
-
// 老聚财
|
|
42
|
-
isOldJuCai: ua.includes("crhsdk") && !ua.includes("cfzqsdk"),
|
|
43
|
-
isLeZhuan:
|
|
44
|
-
(!isWTSDK && ua.toLowerCase().includes("lezhuan")) ||
|
|
45
|
-
ua.includes("cfzqsdk"),
|
|
46
|
-
isCRH: ua.includes("crhsdk") || ua.includes("crhapp"),
|
|
47
|
-
};
|
|
48
|
-
})();
|
|
49
|
-
|
|
50
|
-
const actionMap = {
|
|
51
|
-
// 财信处理action地址方法
|
|
52
|
-
onJsOverrideUrlLoading(str: string) {
|
|
53
|
-
if (ios && window.webkit?.messageHandlers?.lzforward) {
|
|
54
|
-
window.webkit.messageHandlers.lzforward?.postMessage(str);
|
|
55
|
-
} else if (window.MyWebView && window.MyWebView.onJsOverrideUrlLoading) {
|
|
56
|
-
window.MyWebView.onJsOverrideUrlLoading(str);
|
|
57
|
-
} else if (window.HarmonyOS && window.HarmonyOS.onJsOverrideUrlLoading) {
|
|
58
|
-
window.HarmonyOS.onJsOverrideUrlLoading(str);
|
|
59
|
-
} else {
|
|
60
|
-
window.location.href = str;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
// 财信调用action路径
|
|
64
|
-
callAction(actionId: string | number, param?: any, cbFunName?: any) {
|
|
65
|
-
let url = `http://action:${actionId}/?target=2`;
|
|
66
|
-
if (param) {
|
|
67
|
-
const paramStr = JSON.stringify(param);
|
|
68
|
-
url += `¶m=${encodeURIComponent(paramStr)}`;
|
|
69
|
-
}
|
|
70
|
-
if (cbFunName) {
|
|
71
|
-
url += `&callback=${cbFunName}`;
|
|
72
|
-
}
|
|
73
|
-
console.log("callAction:", url);
|
|
74
|
-
this.onJsOverrideUrlLoading(url);
|
|
75
|
-
},
|
|
76
|
-
// 财信聚财通过js bridge调用app接口
|
|
77
|
-
setupWebViewJavascriptBridge(callback: any) {
|
|
78
|
-
if (window.WebViewJavascriptBridge) {
|
|
79
|
-
callback(window.WebViewJavascriptBridge);
|
|
80
|
-
} else {
|
|
81
|
-
document.addEventListener(
|
|
82
|
-
"WebViewJavascriptBridgeReady",
|
|
83
|
-
() => {
|
|
84
|
-
callback(window.WebViewJavascriptBridge);
|
|
85
|
-
},
|
|
86
|
-
false
|
|
87
|
-
);
|
|
88
|
-
if (!/android/gi.test(navigator.userAgent)) {
|
|
89
|
-
if (window.WebViewJavascriptBridge) {
|
|
90
|
-
callback(window.WebViewJavascriptBridge);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (window.WVJBCallbacks) {
|
|
94
|
-
window.WVJBCallbacks.push(callback);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
window.WVJBCallbacks = [callback];
|
|
98
|
-
const WVJBIframe = document.createElement("iframe");
|
|
99
|
-
WVJBIframe.style.display = "none";
|
|
100
|
-
WVJBIframe.src = "wvjbscheme://__BRIDGE_LOADED__";
|
|
101
|
-
document.documentElement.appendChild(WVJBIframe);
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
document.documentElement.removeChild(WVJBIframe);
|
|
104
|
-
}, 0);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
// 聚财Android调用app接口
|
|
109
|
-
callAndroidActionOfJvCai(param: any) {
|
|
110
|
-
const paramStr = JSON.stringify(param);
|
|
111
|
-
if (window.mobile) {
|
|
112
|
-
window.mobile.onActionEvent(paramStr);
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
// 财信调用聚财方法
|
|
116
|
-
callJuCaiAction(funName: any, data?: any, callback?: any) {
|
|
117
|
-
console.log("callJuCaiAction:", funName, data, callback);
|
|
118
|
-
if (ios) {
|
|
119
|
-
this.setupWebViewJavascriptBridge((bridge: any) => {
|
|
120
|
-
bridge.callHandler(funName, data, window[callback]);
|
|
121
|
-
});
|
|
122
|
-
} else {
|
|
123
|
-
const param: any = {
|
|
124
|
-
funName,
|
|
125
|
-
callbackFunName: callback,
|
|
126
|
-
};
|
|
127
|
-
if (data) {
|
|
128
|
-
param.data = data;
|
|
129
|
-
}
|
|
130
|
-
this.callAndroidActionOfJvCai(param);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* iOS客户端方法加载函数(老乐赚老聚财)
|
|
135
|
-
* @param {string} url
|
|
136
|
-
*/
|
|
137
|
-
loadIOSNative(url: string) {
|
|
138
|
-
let iFrame: any = "";
|
|
139
|
-
iFrame = document.createElement("iframe");
|
|
140
|
-
iFrame.setAttribute("src", url);
|
|
141
|
-
iFrame.setAttribute("style", "display:none;");
|
|
142
|
-
iFrame.setAttribute("height", "0px");
|
|
143
|
-
iFrame.setAttribute("width", "0px");
|
|
144
|
-
iFrame.setAttribute("frameborder", "0");
|
|
145
|
-
document.body.appendChild(iFrame);
|
|
146
|
-
iFrame.parentNode.removeChild(iFrame);
|
|
147
|
-
iFrame = null;
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
if (!ios && webviewType.isNewJuCai) {
|
|
153
|
-
actionMap.setupWebViewJavascriptBridge((bridge: any) => {
|
|
154
|
-
bridge.init();
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
} catch (e) {
|
|
158
|
-
console.log("初始化失败");
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export default {
|
|
162
|
-
compareVersion,
|
|
163
|
-
actionMap,
|
|
164
|
-
webviewType() {
|
|
165
|
-
return webviewType;
|
|
166
|
-
},
|
|
167
|
-
//是否在app内
|
|
168
|
-
isApp() {
|
|
169
|
-
const ua = navigator.userAgent;
|
|
170
|
-
const isAppFlags = [
|
|
171
|
-
"crhsdk",
|
|
172
|
-
"crhapp",
|
|
173
|
-
"cfzqsdk",
|
|
174
|
-
"LeZhuan",
|
|
175
|
-
"LEZHUAN",
|
|
176
|
-
"lezhuan",
|
|
177
|
-
"Android_CFZQ_JUCAI",
|
|
178
|
-
"iOS_CFZQ_JUCAI",
|
|
179
|
-
];
|
|
180
|
-
return isAppFlags.some((flag) => ua.includes(flag));
|
|
181
|
-
},
|
|
182
|
-
// 拦截Android物理返回键事件,并回调给前端 --- 仅安卓
|
|
183
|
-
interceptBack(callback: Function) {
|
|
184
|
-
window.jtoJHandle.interceptBack("interceptBackCallBack");
|
|
185
|
-
window.interceptBackCallBack = function (e: any) {
|
|
186
|
-
callback && callback(e);
|
|
187
|
-
};
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
// 关闭页面 closeSJKH
|
|
191
|
-
closeSJKH() {
|
|
192
|
-
if (webviewType.isNewLeZhuan) {
|
|
193
|
-
actionMap.callAction(3);
|
|
194
|
-
} else if (webviewType.isNewJuCai) {
|
|
195
|
-
// iphone
|
|
196
|
-
actionMap.callJuCaiAction("closePage", {});
|
|
197
|
-
} else if (ios) {
|
|
198
|
-
// iphone
|
|
199
|
-
window.location.href = "objc://callIOSQuit/";
|
|
200
|
-
} else {
|
|
201
|
-
window.jtoJHandle.closeSJKH();
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
/**
|
|
205
|
-
* 跳转个股详情页
|
|
206
|
-
*/
|
|
207
|
-
goStockDetail(params: {
|
|
208
|
-
code?: string,
|
|
209
|
-
market?:string
|
|
210
|
-
}) {
|
|
211
|
-
const { code, market } = params;
|
|
212
|
-
if (webviewType.isNewLeZhuan) {
|
|
213
|
-
actionMap.callAction(923, {
|
|
214
|
-
code,
|
|
215
|
-
market,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
/**
|
|
220
|
-
* 通过pageId打开新的webview打开外部链接
|
|
221
|
-
*/
|
|
222
|
-
goWebview(params: {
|
|
223
|
-
sdk?: string;
|
|
224
|
-
h5?: string;
|
|
225
|
-
h5url?: string;
|
|
226
|
-
token_sn?: string;
|
|
227
|
-
thirdChannel?: string;
|
|
228
|
-
productCode?: string;
|
|
229
|
-
}) {
|
|
230
|
-
const { sdk, h5, h5url = "", productCode } = params;
|
|
231
|
-
const jsonObj = {
|
|
232
|
-
indexUrl: h5,
|
|
233
|
-
uploadPicUrl: "",
|
|
234
|
-
cookieDomain: "",
|
|
235
|
-
closeBusiness: "closeCallBack",
|
|
236
|
-
module: "",
|
|
237
|
-
identifier: "zt",
|
|
238
|
-
};
|
|
239
|
-
const jsonStr = JSON.stringify(jsonObj);
|
|
240
|
-
if (!this.isApp()) {
|
|
241
|
-
window.location.href = h5url;
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
if (webviewType.isNewLeZhuan) {
|
|
245
|
-
actionMap.callAction(207, {
|
|
246
|
-
pageId: sdk || "1",
|
|
247
|
-
needLogin: "0",
|
|
248
|
-
...(productCode ? { param: { productCode } } : {}),
|
|
249
|
-
});
|
|
250
|
-
} else if (webviewType.isNewJuCai) {
|
|
251
|
-
actionMap.callJuCaiAction("gotoClientPage", {
|
|
252
|
-
pageId: ios ? String(sdk) : sdk,
|
|
253
|
-
needLogin: "0",
|
|
254
|
-
...(productCode ? { param: { productCode } } : {}),
|
|
255
|
-
});
|
|
256
|
-
} else if (ios) {
|
|
257
|
-
// iphone
|
|
258
|
-
actionMap.loadIOSNative(`objc://openNewBusiness/$?${jsonStr}`);
|
|
259
|
-
} else {
|
|
260
|
-
window.jtoJHandle.openNewBusiness(jsonStr);
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
/**
|
|
264
|
-
* 通过打开新的webview打开外部链接
|
|
265
|
-
* @param {string} url 跳转地址
|
|
266
|
-
* @param {boolean} needTitle 打开新webview是否需要页头1需要0不需要
|
|
267
|
-
*/
|
|
268
|
-
goWebview2({ url = "", needTitle = false, noNewWebView = false }) {
|
|
269
|
-
let targetUrl = url?.trim();
|
|
270
|
-
if (!targetUrl) {
|
|
271
|
-
console.log("targetUrl不能为空");
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const urlParams: {
|
|
275
|
-
[key: string]: string;
|
|
276
|
-
} = {};
|
|
277
|
-
let prefix = "";
|
|
278
|
-
if (targetUrl.includes("#")) {
|
|
279
|
-
prefix = targetUrl.split("#")[1].includes("?") ? "&" : "?";
|
|
280
|
-
} else {
|
|
281
|
-
prefix = targetUrl.includes("?") ? "&" : "?";
|
|
282
|
-
}
|
|
283
|
-
let from = "";
|
|
284
|
-
if (!targetUrl.includes("from=")) {
|
|
285
|
-
from = "from=newMall";
|
|
286
|
-
urlParams.from = "newMall";
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const currentPage: any = window.location.hash
|
|
290
|
-
? window.location.hash.match(/#([^?]*)/)?.[1]
|
|
291
|
-
: "/";
|
|
292
|
-
urlParams.fromPage = currentPage;
|
|
293
|
-
if (!noNewWebView) {
|
|
294
|
-
// 新开webview
|
|
295
|
-
urlParams.opentype = "newpage";
|
|
296
|
-
}
|
|
297
|
-
if (webviewType.isNewJuCai) {
|
|
298
|
-
delete urlParams.opentype;
|
|
299
|
-
}
|
|
300
|
-
if (!needTitle && !targetUrl.includes("needtitle=")) {
|
|
301
|
-
// 不显示原生标题栏
|
|
302
|
-
urlParams.needtitle = "0";
|
|
303
|
-
}
|
|
304
|
-
if (
|
|
305
|
-
targetUrl.includes("#") &&
|
|
306
|
-
(urlParams.opentype || urlParams.needtitle)
|
|
307
|
-
) {
|
|
308
|
-
// opentype和needtitle处理,需在#号前加
|
|
309
|
-
const tempUrl = targetUrl.split("#");
|
|
310
|
-
const preParams: {
|
|
311
|
-
[key: string]: string;
|
|
312
|
-
} = {};
|
|
313
|
-
if (urlParams.opentype && !tempUrl[0].includes("opentype=")) {
|
|
314
|
-
preParams.opentype = urlParams.opentype;
|
|
315
|
-
}
|
|
316
|
-
if (urlParams.needtitle && !tempUrl[0].includes("needtitle=")) {
|
|
317
|
-
preParams.needtitle = urlParams.needtitle;
|
|
318
|
-
}
|
|
319
|
-
const fromAppTab = sessionStorage.getItem("fromAppTab") || "";
|
|
320
|
-
if (+fromAppTab === 1 && !tempUrl[0].includes("fromAppTab=")) {
|
|
321
|
-
preParams.fromAppTab = "1";
|
|
322
|
-
}
|
|
323
|
-
const urlParamsStr = new URLSearchParams(preParams).toString();
|
|
324
|
-
targetUrl = `${tempUrl[0]}${
|
|
325
|
-
tempUrl[0].includes("?") ? "&" : "?"
|
|
326
|
-
}${urlParamsStr}#${tempUrl[1]}`;
|
|
327
|
-
}
|
|
328
|
-
if (urlParams.opentype) {
|
|
329
|
-
// 新开标识
|
|
330
|
-
urlParams.isInNewWebView = "1";
|
|
331
|
-
}
|
|
332
|
-
/* if (+getSessionStore('fromAppTab') === 1) {
|
|
333
|
-
urlParams.fromAppTab = '1';
|
|
334
|
-
} */
|
|
335
|
-
const urlParamsStr = new URLSearchParams(urlParams).toString();
|
|
336
|
-
const mregeUrl = `${targetUrl}${prefix}${urlParamsStr}`;
|
|
337
|
-
console.log("goWebView:", mregeUrl);
|
|
338
|
-
if (webviewType.isNewLeZhuan) {
|
|
339
|
-
window.location.href = mregeUrl;
|
|
340
|
-
} else if (webviewType.isNewJuCai) {
|
|
341
|
-
if (urlParams.opentype) {
|
|
342
|
-
if (ios) {
|
|
343
|
-
actionMap.setupWebViewJavascriptBridge((bridge: any) => {
|
|
344
|
-
bridge.callHandler(
|
|
345
|
-
"gotoNextPage",
|
|
346
|
-
{
|
|
347
|
-
needtitle: needTitle ? "1" : "0",
|
|
348
|
-
url,
|
|
349
|
-
},
|
|
350
|
-
(data: any) => {
|
|
351
|
-
console.log("goWebview:", data);
|
|
352
|
-
}
|
|
353
|
-
);
|
|
354
|
-
});
|
|
355
|
-
} else {
|
|
356
|
-
// {“pageId”: “2804”, “needLogin”: “true”, “title”: “网页标题”, “url”: “http://www.baidu.com”}
|
|
357
|
-
// pageId=2804表示跳转客户端默认webview,pageId=5002跳转客户端无标题webview;needLogin=1表示需要先登录委托,未登录委托情况下会先跳转客户端委托登录
|
|
358
|
-
actionMap.callJuCaiAction("goWebViewPage", {
|
|
359
|
-
pageId: needTitle ? "2804" : "5002",
|
|
360
|
-
url,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
} else {
|
|
364
|
-
// 聚财新开webview体验有问题,因此统一走location.href
|
|
365
|
-
window.location.href = url;
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
let paramsObj: any = {
|
|
369
|
-
indexUrl: url,
|
|
370
|
-
};
|
|
371
|
-
paramsObj = JSON.stringify(paramsObj);
|
|
372
|
-
if (ios) {
|
|
373
|
-
actionMap.loadIOSNative(`objc://openNewBusiness/$?${paramsObj}`);
|
|
374
|
-
} else {
|
|
375
|
-
window.jtoJHandle?.openNewBusiness(paramsObj);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
},
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* 获取客户端版本号
|
|
382
|
-
*/
|
|
383
|
-
getVersion() {
|
|
384
|
-
const ua = navigator.userAgent.toLowerCase();
|
|
385
|
-
let regex: any = "";
|
|
386
|
-
if (webviewType.isNewLeZhuan) {
|
|
387
|
-
regex = ios || checkIsHarmonyOS() ? /cfzq_lezhuan_([\d.]+)/ : /cfzq_lezhuan([\d.]+)/;
|
|
388
|
-
} else if (webviewType.isNewJuCai) {
|
|
389
|
-
regex = /cfzq_jucai_([\d.]+)/;
|
|
390
|
-
}
|
|
391
|
-
const match = ua.match(regex);
|
|
392
|
-
console.log(match, "===match===");
|
|
393
|
-
if (match) {
|
|
394
|
-
const version = match[1];
|
|
395
|
-
return version;
|
|
396
|
-
} else {
|
|
397
|
-
console.warn("version没有找到匹配项");
|
|
398
|
-
return "0.0.0";
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
/**
|
|
402
|
-
* 设置原生状态栏颜色(乐赚客户端)
|
|
403
|
-
* @param {object} params
|
|
404
|
-
* @param {string} params.color 状态栏背景颜色,如#ff0000
|
|
405
|
-
* @param {string} params.wordColorStyle 状态栏文字颜色,0 白色,1 黑色
|
|
406
|
-
*/
|
|
407
|
-
async setStatusBar(params: any) {
|
|
408
|
-
if (webviewType.isNewLeZhuan) {
|
|
409
|
-
if (compareVersion("6.1.0", this.getVersion()) === 1) {
|
|
410
|
-
console.log("---版本号低,无法设置状态栏颜色---");
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
let data = {
|
|
414
|
-
statusColor: params.color,
|
|
415
|
-
isDark: params.wordColorStyle === "1",
|
|
416
|
-
};
|
|
417
|
-
actionMap.callAction(933, data);
|
|
418
|
-
} else if (webviewType.isCRH) {
|
|
419
|
-
if (ios) {
|
|
420
|
-
actionMap.loadIOSNative(
|
|
421
|
-
`objc://setAppBackgroundColor/$?${params.color}`
|
|
422
|
-
);
|
|
423
|
-
} else if (window.jtoJHandle) {
|
|
424
|
-
window.jtoJHandle.setAppBackgroundColor(params.color);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* 分享
|
|
431
|
-
* @param {object} params
|
|
432
|
-
* @param {string} params.img_url 分享展示的图片
|
|
433
|
-
* @param {string} params.url 分享链接
|
|
434
|
-
* @param {string} params.title 标题
|
|
435
|
-
* @param {string} params.message 内容
|
|
436
|
-
*/
|
|
437
|
-
share(params: {
|
|
438
|
-
img_url?: any;
|
|
439
|
-
url?: string;
|
|
440
|
-
title?: string;
|
|
441
|
-
message?: string;
|
|
442
|
-
}) {
|
|
443
|
-
if (webviewType.isLeZhuan) {
|
|
444
|
-
const shareParam = {
|
|
445
|
-
img_url: params.img_url || ShareImg,
|
|
446
|
-
url: params.url,
|
|
447
|
-
title: params.title,
|
|
448
|
-
message: params.message,
|
|
449
|
-
};
|
|
450
|
-
if (webviewType.isNewLeZhuan) {
|
|
451
|
-
actionMap.callAction(900, shareParam, "");
|
|
452
|
-
} else {
|
|
453
|
-
ProfessionModel.businessAlertView(
|
|
454
|
-
`http://action:900/?target=2¶m=${encodeURIComponent(
|
|
455
|
-
JSON.stringify(shareParam)
|
|
456
|
-
)}`
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
} else {
|
|
460
|
-
return new Promise(async (resolve) => {
|
|
461
|
-
resolve({
|
|
462
|
-
error_no: "-3",
|
|
463
|
-
error_info: "当前APP不支持分享",
|
|
464
|
-
});
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
},
|
|
468
|
-
};
|