crh-jssdk 0.10.22 → 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.
Files changed (45) hide show
  1. package/declare.d.ts +1 -0
  2. package/package.json +2 -5
  3. package/tsconfig.json +1 -1
  4. package/yalc.lock +1 -1
  5. package/.yalc/crh-jssdk/business/assets/cx_share.png +0 -0
  6. package/.yalc/crh-jssdk/business/base/crh-app-sdk-cxzq.ts +0 -468
  7. package/.yalc/crh-jssdk/business/base/index.ts +0 -47
  8. package/.yalc/crh-jssdk/business/index.ts +0 -210
  9. package/.yalc/crh-jssdk/business/profession/crh-app-sdk-cxzq.ts +0 -351
  10. package/.yalc/crh-jssdk/business/profession/index.ts +0 -53
  11. package/.yalc/crh-jssdk/business/user/crh-app-sdk-cxzq.ts +0 -192
  12. package/.yalc/crh-jssdk/business/user/crh-app-sdk-cy.ts +0 -46
  13. package/.yalc/crh-jssdk/business/user/index.ts +0 -45
  14. package/.yalc/crh-jssdk/business/utils/index.ts +0 -122
  15. package/.yalc/crh-jssdk/declare.d.ts +0 -46
  16. package/.yalc/crh-jssdk/images.d.ts +0 -7
  17. package/.yalc/crh-jssdk/index.ts +0 -17
  18. package/.yalc/crh-jssdk/package.json +0 -21
  19. package/.yalc/crh-jssdk/tsconfig.json +0 -72
  20. package/.yalc/crh-jssdk/yalc.lock +0 -9
  21. package/.yalc/crh-jssdk/yalc.sig +0 -1
  22. package/business/assets/cx_share.png +0 -0
  23. package/business/base/crh-app-sdk-cxzq.js +0 -501
  24. package/business/base/crh-app-sdk-cxzq.ts +0 -468
  25. package/business/base/index.js +0 -50
  26. package/business/base/index.ts +0 -47
  27. package/business/common/utils.js +0 -117
  28. package/business/index.js +0 -271
  29. package/business/index.ts +0 -210
  30. package/business/mall/crh-app-sdk-cxzq.js +0 -758
  31. package/business/mall/crh-app-sdk.js +0 -164
  32. package/business/mall/index.js +0 -208
  33. package/business/profession/crh-app-sdk-cxzq.js +0 -421
  34. package/business/profession/crh-app-sdk-cxzq.ts +0 -351
  35. package/business/profession/index.js +0 -51
  36. package/business/profession/index.ts +0 -53
  37. package/business/user/crh-app-sdk-cxzq.js +0 -276
  38. package/business/user/crh-app-sdk-cxzq.ts +0 -192
  39. package/business/user/crh-app-sdk-cy.js +0 -39
  40. package/business/user/crh-app-sdk-cy.ts +0 -46
  41. package/business/user/index.js +0 -52
  42. package/business/user/index.ts +0 -45
  43. package/business/utils/index.js +0 -165
  44. package/business/utils/index.ts +0 -122
  45. /package/{.yalc/crh-jssdk → dist}/index.js +0 -0
package/declare.d.ts CHANGED
@@ -42,5 +42,6 @@ declare interface Window {
42
42
  getTradeLoginTokenCB: any;
43
43
  communityLoginCB: any;
44
44
  callAfterFavor: any;
45
+ getUserInfoByRsa: any;
45
46
  [key: string]: any;
46
47
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "crh-jssdk",
3
- "version": "0.10.22",
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,8 +16,5 @@
16
16
  "license": "ISC",
17
17
  "devDependencies": {
18
18
  "typescript": "^5.5.2"
19
- },
20
- "dependencies": {
21
- "crh-jssdk": "file:.yalc/crh-jssdk"
22
19
  }
23
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
- // "outDir": "./", /* Redirect output structure to the directory. */
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
@@ -2,7 +2,7 @@
2
2
  "version": "v1",
3
3
  "packages": {
4
4
  "crh-jssdk": {
5
- "signature": "4326f5afa894ad80a0d2970a68cf224e",
5
+ "signature": "2f8ad2040e033105296601018ebe2685",
6
6
  "file": true
7
7
  }
8
8
  }
@@ -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 += `&param=${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&param=${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
- };
@@ -1,47 +0,0 @@
1
- import { ios, checkIsHarmonyOS, harmonyCallJsHandler } from "../utils";
2
-
3
- export default {
4
- // 拦截Android物理返回键事件,并回调给前端 --- 仅安卓 鸿蒙
5
- interceptBack(callback: Function) {
6
- if (checkIsHarmonyOS()) {
7
- harmonyCallJsHandler("interceptBack", {
8
- callback: "interceptBackCallBack",
9
- });
10
- } else {
11
- window.jtoJHandle.interceptBack('interceptBackCallBack')
12
- }
13
-
14
- window.interceptBackCallBack = function (e: any) {
15
- callback && callback(e)
16
- }
17
- },
18
-
19
- // 关闭页面 closeSJKH
20
- callQuit() {
21
- if (ios) {
22
- window.location.href = "objc://callIOSQuit";
23
- } else if (checkIsHarmonyOS()) {
24
- harmonyCallJsHandler("closeSJKH", '');
25
- } else {
26
- window.jtoJHandle.interceptBack('closeSJKH')
27
- }
28
- },
29
-
30
- goWebview(title: string, url: string, callback: Function) {
31
- const params = {
32
- title: title,
33
- url: url,
34
- callback: 'openOwnPageCallBack'
35
- }
36
- if (ios) {
37
- window.location.href = `objc://openOwnPage/$?${JSON.stringify(params)}"`;
38
- } else if (checkIsHarmonyOS()) {
39
- harmonyCallJsHandler("openOwnPage", params);
40
- } else {
41
- window.jtoJHandle.openOwnPage(JSON.stringify(params))
42
- }
43
- window.openOwnPageCallBack = function (e: any) {
44
- callback && callback(e)
45
- }
46
- }
47
- };