@conecli/cone-render 0.10.1-shop-beta.5 → 0.10.1-shop3.1

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 (37) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/common/index.jd.ts +1 -1
  5. package/dist/common/index.ts +1 -1
  6. package/dist/common/index.weapp.ts +1 -1
  7. package/dist/common/pageType.ts +1 -1
  8. package/dist/common/sgmCustomCode.ts +1 -1
  9. package/dist/components/base/CustomVideo/common.ts +1 -0
  10. package/dist/components/base/CustomVideo/index.tsx +1 -1
  11. package/dist/components/base/LazyLoadImage/index.h5.module.scss +8 -4
  12. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  13. package/dist/components/base/Price/Base/index.tsx +1 -1
  14. package/dist/components/base/Price/Double/index.tsx +1 -1
  15. package/dist/components/floorItem.tsx +1 -1
  16. package/dist/components/isv/Floor/index.tsx +1 -1
  17. package/dist/interface/component.ts +1 -1
  18. package/dist/interface/jumpEventReport.ts +1 -1
  19. package/dist/interface/service.ts +1 -1
  20. package/dist/jumpEventReport/index.weapp.ts +1 -1
  21. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  22. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  23. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  24. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  25. package/dist/open/api/util.ts +1 -1
  26. package/dist/service/http/colorSign.ts +1 -1
  27. package/dist/service/http/h5Http.ts +1 -0
  28. package/dist/service/http/index.h5.ts +1 -0
  29. package/dist/service/requestServer.h5.ts +1 -0
  30. package/dist/service/requestServer.ts +1 -1
  31. package/dist/utils/connectNativeJsBridge.ts +1 -1
  32. package/dist/utils/h5Utils.ts +1 -1
  33. package/dist/utils/index.h5.ts +1 -1
  34. package/dist/utils/index.ts +1 -1
  35. package/dist/utils/index.weapp.ts +1 -1
  36. package/dist/utils/utils.ts +1 -1
  37. package/package.json +35 -29
@@ -1 +1 @@
1
- import Taro from "@tarojs/taro";
2
1
  isIosDevice,
3
2
  isAndroidDevice,
4
3
  isJdAndHarmonyDevice,
5
4
  isJdAndAndroidDevice,
6
5
  jdAppVersion,
7
6
  jdAppVersionStr,
8
7
  isString,
9
8
  isObject,
10
9
  serialize,
11
10
  urlCookie,
12
11
  dealNativePixelToCssPixel,
13
12
  isPc,
14
13
  BUSINESS_TYPE,
15
14
  SECTION_HOME_TAB_NAME_TYPE,
16
15
  SECTION_HOME_TAB_TYPE,
17
16
  WXAPP_BIZ_KEY,
18
17
  WX_BUSINESS_TYPE,
19
18
  MPAAS_CONFIG_APP_VERSION,
20
19
  MPAAS_CONFIG_APP_LOW_VERSION,
21
20
  WXAPP_BIZ_SHOP_LIGHT_KEY,
22
21
  LoadJsInitLoadEnvType,
23
22
  LoadJsInitLoadType,
24
23
  LoadJsInitTriggerType,
25
24
  loginState: false,
26
25
  cookiesStr: "",
27
26
  userInfo: userPinKey,
28
27
  isJingGouMiniViewState: false,
29
28
  isJingxiMiniViewState: false,
30
29
  pageInfo: {
31
30
  wxBusinessType: WX_BUSINESS_TYPE.NO,
32
31
  address: "",
33
32
  addressCommaStr: "",
34
33
  un_area: "",
35
34
  vapptype: "1",
36
35
  pageType: "home",
37
36
  isExposureState: false,
38
37
  moduleId: "",
39
38
  entrance: "",
40
39
  dataType: BUSINESS_TYPE.ONLINE,
41
40
  floorExposureInfo: {},
42
41
  floorVideInfo: {},
43
42
  productVideInfo: {},
44
43
  tabsLoadAllDataInfo: {
45
44
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]:
46
45
  false,
47
46
  },
48
47
  updateShopInfosAllState: false,
49
48
  isVipShop: false,
50
49
  isJdShowNativeImmersivePlayer: false,
51
50
  ...shopConfig,
52
51
  pageScrollTop: 0,
53
52
  pageIdxHeightInfo: {
54
53
  list: [],
55
54
  },
56
55
  shopNavBarHeight: 0,
57
56
  },
58
57
  defaultQueryLogInfo: {
59
58
  sourceType: "JDshop",
60
59
  sourceValue: "",
61
60
  moduleId: "none",
62
61
  entrance: "none",
63
62
  },
64
63
  sysInfo: {
65
64
  windowWidth: isPc ? 375 : 0,
66
65
  containerWidth: isPc ? 375 : 0,
67
66
  windowHeight: 0,
68
67
  netWorkType: "4g",
69
68
  jdBottomBarHeight: 0,
70
69
  jdNativeHeaderHeight: 0,
71
70
  },
72
71
  queryInfo: {},
73
72
  shopInfo: {},
74
73
  openAppData: {},
75
74
  public info: CommonInterFace.BaseConfigInfo;
76
75
  public config: {
77
76
  [key: string]: any;
78
77
  };
79
78
  public lazyContainer: CommonInterFace.lazyContainer;
80
79
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
81
80
  public rootEleNode: HTMLElement | null;
82
81
  public checkStatusAndLoginPromise: object | null;
83
82
  private jmfeRegisterStatePromise: Promise<any> | null;
84
83
  private jmfeRegisterState: boolean;
85
84
  public loadJsSdkList: Array<any>;
86
85
  public loadJsSdkListCachePromise: any;
87
86
  constructor(opt) {
88
87
  this.info = this._getConfig(opt);
89
88
  this.config = {};
90
89
  this.loadJsSdkList = [];
91
90
  this.loadJsSdkListCachePromise = {};
92
91
  this.lazyContainer = {
93
92
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
94
93
  appLazyContainerList: [],
95
94
  appLazyFinishContainerList: [],
96
95
  },
97
96
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
98
97
  appLazyContainerList: [],
99
98
  appLazyFinishContainerList: [],
100
99
  },
101
100
  };
102
101
  this.renderedIsvComponents = {};
103
102
  this.rootEleNode = document.querySelector("body");
104
103
  this.checkStatusAndLoginPromise = null;
105
104
  this.jmfeRegisterStatePromise = null;
106
105
  this.loadOtherSdk();
107
106
  isJdApp && this.jmfeReayPromise();
108
107
  }
109
108
  _getConfig(opt) {
110
109
  return Object.assign({}, DefaultConfig, opt);
111
110
  }
112
111
 
113
112
  jmfeReayPromise(): Promise<any> {
114
113
  if (isJdApp) {
115
114
  if (this.jmfeRegisterState) {
116
115
  return Promise.resolve(true);
117
116
  } else {
118
117
  !this.jmfeRegisterStatePromise &&
119
118
  (this.jmfeRegisterStatePromise = new Promise((resolve, reject) => {
120
119
  ready("jmfe", 3000)
121
120
  .then(() => {
122
121
  window?.jmfe &&
123
122
  window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE);
124
123
  this.jmfeRegisterState = true;
125
124
  resolve(true);
126
125
  console.log("松果app内初始化注册jmfe认证完成");
127
126
  })
128
127
  .catch(() => {
129
128
  reject(false);
130
129
  });
131
130
  }));
132
131
  return this.jmfeRegisterStatePromise;
133
132
  }
134
133
  } else {
135
134
  return Promise.reject(false);
136
135
  }
137
136
  }
138
137
 
139
138
  updateBusinessDomainAndApi(domain, api) {
140
139
  }
141
140
 
142
141
  formatNativeScreenPageData(action) {
143
142
  let getChangePageInfo: any = null;
144
143
  try {
145
144
  const getNativeScreenPageInfoStr = window.XWebView?._callNative(
146
145
  JSON.stringify({
147
146
  plugin: "JDHybridScreenPlugin",
148
147
  action,
149
148
  sync: "1",
150
149
  })
151
150
  );
152
151
  const getChangePageInfoData =
153
152
  typeof getNativeScreenPageInfoStr === "string"
154
153
  ? JSON.parse(getNativeScreenPageInfoStr)
155
154
  : null;
156
155
  if (getChangePageInfoData && typeof getChangePageInfoData === "object") {
157
156
  const { code, data } = getChangePageInfoData;
158
157
  getChangePageInfo = code && code === "0" ? data : null;
159
158
  }
160
159
  } catch (e) {
161
160
  console.log("JDHybridScreenPlugin转换异常", e);
162
161
  }
163
162
  return getChangePageInfo;
164
163
  }
165
164
 
166
165
  isAndroidFoldScreen() {
167
166
  return this.formatNativeScreenPageData("isFoldScreen") === "1";
168
167
  }
169
168
 
170
169
  getJdAndroidPageChangeScreenInfo() {
171
170
  const getPageScreenInfo = this.formatNativeScreenPageData("getScreenSize");
172
171
  if (
173
172
  getPageScreenInfo &&
174
173
  getPageScreenInfo?.pageWidth &&
175
174
  getPageScreenInfo?.pageHeight
176
175
  ) {
177
176
  const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
178
177
  pageWidth: getPageScreenInfo.pageWidth,
179
178
  pageHeight: getPageScreenInfo.pageHeight,
180
179
  });
181
180
  getPageScreenInfo.pageWidth = pageWidth;
182
181
  getPageScreenInfo.pageHeight = pageHeight;
183
182
  }
184
183
  return getPageScreenInfo;
185
184
  }
186
185
 
187
186
  getSystemInfo(params) {
188
187
  let info: UtilsInterFace.taroGetSystemInfoSyncRes | {} = isPc
189
188
  ? {}
190
189
  : getSystemInfos(params);
191
190
  if (isJdAndAndroidDevice && window.innerWidth <= 0) {
192
191
  const isfoldScreen = this.isAndroidFoldScreen();
193
192
  if (isfoldScreen) {
194
193
  const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo();
195
194
  getJdAndroidPageInfo && (info = getSystemInfos(getJdAndroidPageInfo));
196
195
  console.info(
197
196
  "安卓松果app折叠屏获取webview宽度为0,那么通过内部方法重置获取",
198
197
  getJdAndroidPageInfo
199
198
  );
200
199
  }
201
200
  }
202
201
  this.info.sysInfo = {
203
202
  actualNavBarHeight: 0,
204
203
  ...this.info.sysInfo,
205
204
  ...info,
206
205
  safeContentHeight: info?.screenHeight,
207
206
  headerHeight: 0,
208
207
  tabBarHeight: 0,
209
208
  };
210
209
  if (isJdApp) {
211
210
  this.info.sysInfo["hostVersionName"] = jdAppVersionStr;
212
211
  this.info.sysInfo["hostAppVersion"] = jdAppVersion;
213
212
  this.getAddressCachePromise();
214
213
  this.getElderModePromise();
215
214
  this.getJDAppearanceStatePromise();
216
215
  this.createJdAndroidRquestEventForTouchStart();
217
216
  }
218
217
  this.getWifiVideoAutoPlayAsync();
219
218
  this.getMPaasConfigAsync();
220
219
  this.getNetWorkType();
221
220
  }
222
221
 
223
222
  taskTimeoutPromise(callBack, timeout = 2000) {
224
223
  return new Promise((resolve) => {
225
224
  setTimeout(() => {
226
225
  const getCallBackRes = typeof callBack === "function" && callBack();
227
226
  return resolve(getCallBackRes || false);
228
227
  }, timeout);
229
228
  });
230
229
  }
231
230
 
232
231
  getElderModePromise() {
233
232
  if (this.info.sysInfo.hasOwnProperty("jdAppModeType")) {
234
233
  return Promise.resolve(this.info.sysInfo.jdAppModeType);
235
234
  } else {
236
235
  if (isJdAndAndroidDevice) {
237
236
  this.info.sysInfo.jdAppModeType = "0";
238
237
  return Promise.resolve(this.info.sysInfo.jdAppModeType);
239
238
  } else {
240
239
  return Promise.race([
241
240
  this.taskTimeoutPromise(() => {
242
241
  this.info.sysInfo.jdAppModeType = "0";
243
242
  return this.info.sysInfo.jdAppModeType;
244
243
  }),
245
244
  new Promise((resolve) => {
246
245
  const getCallBackName = `getJdCurrentModeType${Date.now()}`;
247
246
  if (!window[getCallBackName]) {
248
247
  window[getCallBackName] = (res) => {
249
248
  try {
250
249
  const getResJson =
251
250
  typeof res === "string" ? JSON.parse(res) : res;
252
251
  const { status, data, msg } = getResJson;
253
252
  console.log(`获取松果app展示模式成功,返回结果${data}`);
254
253
  if (status === "0") {
255
254
  this.info.sysInfo.jdAppModeType = data;
256
255
  resolve(data);
257
256
  } else {
258
257
  resolve("0");
259
258
  }
260
259
  } catch (e) {
261
260
  resolve("0");
262
261
  }
263
262
  window[getCallBackName] = null;
264
263
  };
265
264
  }
266
265
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
267
266
  method: "callSyncRouterModuleWithParams",
268
267
  params: JSON.stringify({
269
268
  routerURL: "router://JDBModeModule/getCurrentMode",
270
269
  routerParam: {},
271
270
  callBackName: `window.${getCallBackName}`,
272
271
  callBackId: `${getCallBackName}Ios`,
273
272
  }),
274
273
  });
275
274
  }),
276
275
  ]);
277
276
  }
278
277
  }
279
278
  }
280
279
 
281
280
  getJDAppearanceStatePromise() {
282
281
  if (this.info.sysInfo.hasOwnProperty("jdAppearanceState")) {
283
282
  return Promise.resolve(this.info.sysInfo.jdAppearanceState);
284
283
  } else {
285
284
  return Promise.race([
286
285
  this.taskTimeoutPromise(() => {
287
286
  this.info.sysInfo.jdAppearanceState = "0";
288
287
  return this.info.sysInfo.jdAppearanceState;
289
288
  }),
290
289
  new Promise((resolve) => {
291
290
  const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`;
292
291
  if (!window[getCallBackName]) {
293
292
  window[getCallBackName] = (res) => {
294
293
  try {
295
294
  console.log("getJDAppearanceStatePromise", res);
296
295
  const getResJson =
297
296
  typeof res === "string" ? JSON.parse(res) : res;
298
297
  const { status, data, msg } = getResJson;
299
298
  console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`);
300
299
  if (status === "0") {
301
300
  this.info.sysInfo.jdAppearanceState = data;
302
301
  resolve(data);
303
302
  } else {
304
303
  resolve("0");
305
304
  }
306
305
  } catch (e) {
307
306
  resolve("0");
308
307
  }
309
308
  window[getCallBackName] = null;
310
309
  };
311
310
  }
312
311
  if (isAndroidDevice) {
313
312
  const jsonString = JSON.stringify({
314
313
  callBackName: `window.${getCallBackName}`,
315
314
  });
316
315
  console.log("window.JDAppearance", window.JDAppearance);
317
316
  window.JDAppearance && window.JDAppearance.getUiState(jsonString);
318
317
  } else {
319
318
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
320
319
  method: "callSyncRouterModuleWithParams",
321
320
  params: JSON.stringify({
322
321
  routerURL:
323
322
  "router://JDWebViewBusinessModule/getJDAppearanceState",
324
323
  routerParam: {},
325
324
  callBackName: `window.${getCallBackName}`,
326
325
  callBackId: `${getCallBackName}Ios`,
327
326
  }),
328
327
  });
329
328
  }
330
329
  }),
331
330
  ]);
332
331
  }
333
332
  }
334
333
 
335
334
  createJdAndroidRquestEventForTouchStart() {
336
335
  if (isJdAndAndroidDevice && window.JdAndroid) {
337
336
  const rootEleNode = document.querySelector("body");
338
337
  if (rootEleNode) {
339
338
  rootEleNode.addEventListener(
340
339
  "touchstart",
341
340
  this.jdAndroidAddEventListenerTouchStart,
342
341
  false
343
342
  );
344
343
  }
345
344
  }
346
345
  }
347
346
  jdAndroidAddEventListenerTouchStart(e) {
348
347
  const isH5SwiperCustomEle = e?.target?.closest(".J_h5SwiperCustom");
349
348
  if (!isH5SwiperCustomEle) {
350
349
  const hasCustomEle = e
351
350
  ? e?.target?.closest(".J_customScroll") ||
352
351
  e?.target?.closest(".J_customLayout")
353
352
  : false;
354
353
  if (!hasCustomEle) {
355
354
  window.JdAndroid.requestEvent(false);
356
355
  console.log(
357
356
  "createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false"
358
357
  );
359
358
  }
360
359
  }
361
360
  }
362
361
  removeJdAndroidRquestEventForTouchStart() {
363
362
  if (isJdAndAndroidDevice && window.JdAndroid) {
364
363
  const rootEleNode = document.querySelector("body");
365
364
  if (rootEleNode) {
366
365
  rootEleNode.removeEventListener(
367
366
  "touchstart",
368
367
  this.jdAndroidAddEventListenerTouchStart,
369
368
  false
370
369
  );
371
370
  }
372
371
  }
373
372
  }
374
373
 
375
374
  getNetWorkType() {
376
375
  if (isJdApp) {
377
376
  this.jmfeReayPromise().then(() => {
378
377
  window.jmfe
379
378
  .getNetworkStatus()
380
379
  .then(({ status, data }) => {
381
380
  console.log(
382
381
  "在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====",
383
382
  data
384
383
  );
385
384
  if (status === "0") {
386
385
  this.info.sysInfo["netWorkType"] = data;
387
386
  } else {
388
387
  this._taroGetNetworkType();
389
388
  }
390
389
  })
391
390
  .catch((err) => {
392
391
  console.log("在app内初始化通过jmfe对象获取网络状态异常====", err);
393
392
  this._taroGetNetworkType();
394
393
  });
395
394
  });
396
395
  } else {
397
396
  this._taroGetNetworkType();
398
397
  }
399
398
  }
400
399
  _taroGetNetworkType() {
401
400
  Taro.getNetworkType().then((getRes) => {
402
401
  if (getRes && getRes.networkType) {
403
402
  this.info.sysInfo["netWorkType"] = getRes.networkType;
404
403
  console.log(
405
404
  "在app内通过taro对象获取网络状态完成,当前网络状态",
406
405
  this.info.sysInfo["netWorkType"]
407
406
  );
408
407
  }
409
408
  });
410
409
  }
411
410
 
412
411
  getCacheAddressRouter() {
413
412
  if (!window.jmfe) return;
414
413
  if (isAndroidDevice) {
415
414
  return window.jmfe.callRouter({
416
415
  jdRouter: "1",
417
416
  routerURL: "router://JDAddressModule/getCacheAddress",
418
417
  routerParam: { sceneId: "basicShoppingProcess" },
419
418
  });
420
419
  } else if (isIosDevice) {
421
420
  return window.jmfe.callRouter({
422
421
  jdRouter: "1",
423
422
  routerURL: "router://JDBAddressCacheManagerModule/getCacheAddress",
424
423
  routerParam: { sceneId: "basicShoppingProcess" },
425
424
  });
426
425
  } else if (isJdAndHarmonyDevice) {
427
426
  return new Promise((resolve) => {
428
427
  resolve({});
429
428
  });
430
429
  } else {
431
430
  throw Error(
432
431
  "Unknown device type cannot obtain the address information through the route!"
433
432
  );
434
433
  }
435
434
  }
436
435
 
437
436
  getAddressCachePromise() {
438
437
  return new Promise((resolve) => {
439
438
  if (
440
439
  this?.info?.sysInfo?.lat &&
441
440
  this?.info?.sysInfo?.lng &&
442
441
  this?.info?.sysInfo?.area
443
442
  ) {
444
443
  resolve({
445
444
  lat: this.info.sysInfo.lat,
446
445
  lng: this.info.sysInfo.lng,
447
446
  area: this?.info?.sysInfo?.area,
448
447
  });
449
448
  } else {
450
449
  this.jmfeReayPromise().then(() => {
451
450
  this.getCacheAddressRouter()
452
451
  .then(({ status, data }) => {
453
452
  if (status === "0" && data) {
454
453
  const {
455
454
  lat,
456
455
  latitude,
457
456
  lng,
458
457
  longitude,
459
458
  provinceId,
460
459
  cityId,
461
460
  countyId,
462
461
  townId,
463
462
  } = data || {};
464
463
  let area = "";
465
464
  this.info.sysInfo["lat"] = `${lat || latitude || ""}`;
466
465
  this.info.sysInfo["lng"] = `${lng || longitude || ""}`;
467
466
  if (provinceId) {
468
467
  area = `${provinceId}_${cityId || 0}_${countyId || 0}_${
469
468
  townId || 0
470
469
  }`;
471
470
  this.info.pageInfo["address"] = area;
472
471
  this.info.pageInfo["addressCommaStr"] = area.replace(
473
472
  /_/g,
474
473
  ","
475
474
  );
476
475
  }
477
476
  resolve({
478
477
  lat: this.info.sysInfo["lat"],
479
478
  lng: this.info.sysInfo["lng"],
480
479
  area: area,
481
480
  });
482
481
  } else {
483
482
  resolve({ lat: "", lng: "", area: "" });
484
483
  }
485
484
  })
486
485
  .catch((e) => {
487
486
  console.log(" ~~ file: index.h5.ts:518 ~~ .catch ~~ e:", e);
488
487
  resolve({ lat: "", lng: "", area: "" });
489
488
  console.log("判断jmfe不存在,获取经纬度信息异常");
490
489
  });
491
490
  });
492
491
  }
493
492
  });
494
493
  }
495
494
 
496
495
  async updateMPaasConfigAsync(isBeforePageReady: boolean) {
497
496
  console.log("updateMPaasConfigAsync isBeforePageReady:", isBeforePageReady);
498
497
  if (!isJdApp) {
499
498
  return;
500
499
  }
501
500
  const avifSwitch = await getMPaasConfigByBussinessKey(
502
501
  "avifSwitch",
503
502
  isBeforePageReady
504
503
  );
505
504
  this.info.sysInfo.dynamicConfig["avifSwitch"] = avifSwitch;
506
505
  const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
507
506
  "isFollowAppVideoPlayStatus",
508
507
  isBeforePageReady
509
508
  );
510
509
  console.log(
511
510
  "isBeforePageReady:",
512
511
  isBeforePageReady,
513
512
  "isFollowAppVideoPlayStatus:",
514
513
  isFollowAppVideoPlayStatus
515
514
  );
516
515
  if (
517
516
  isFollowAppVideoPlayStatus === true ||
518
517
  isFollowAppVideoPlayStatus === "true"
519
518
  ) {
520
519
  this.info.sysInfo.dynamicConfig["isFollowAppVideoPlayStatus"] = true;
521
520
  }
522
521
  }
523
522
 
524
523
  async getWifiVideoAutoPlayAsync() {
525
524
  this.info.sysInfo["wifiVideoAutoPlay"] = false;
526
525
  if (!isJdApp) {
527
526
  return;
528
527
  }
529
528
  const videoPlayStatus = await getWifiVideoAutoPlay().catch((e) => {
530
529
  return 0;
531
530
  });
532
531
  if (Number(videoPlayStatus) === 1) {
533
532
  this.info.sysInfo["wifiVideoAutoPlay"] = true;
534
533
  }
535
534
  }
536
535
 
537
536
  async getMPaasConfigAsync() {
538
537
  this.info.sysInfo.dynamicConfig = {};
539
538
  this.info.sysInfo.dynamicConfig["avifSwitch"] = {};
540
539
  this.info.sysInfo.dynamicConfig["isFollowAppVideoPlayStatus"] = false;
541
540
  return this.updateMPaasConfigAsync(true);
542
541
  }
543
542
 
544
543
  getDynamicConfig(key: string) {
545
544
  return this.info.sysInfo.dynamicConfig[key];
546
545
  }
547
546
  async updateMPaasConfig() {
548
547
  console.log("updateMPaasConfig");
549
548
  if (
550
549
  isIosDevice &&
551
550
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
552
551
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
553
552
  ) {
554
553
  try {
555
554
  await this.updateMPaasConfigAsync(false);
556
555
  } catch (e) {
557
556
  console.log("updateMPaasConfigAsync:", e);
558
557
  }
559
558
  }
560
559
  }
561
560
 
562
561
  toLogin(options) {
563
562
  return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
564
563
  ? this.toWxAppLogin(options)
565
564
  : this.toWebLogin(options);
566
565
  }
567
566
 
568
567
  doLogin(options) {
569
568
  return this.toLogin(options);
570
569
  }
571
570
 
572
571
  doLoginForJdPin(options = {}) {
573
572
  return this.doLogin({
574
573
  loginColor: {
575
574
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
576
575
  dpin: 0,
577
576
  },
578
577
  ...options,
579
578
  });
580
579
  }
581
580
 
582
581
  toWebLogin(options) {
583
582
  let params: {
584
583
  returnurl: string;
585
584
  } = {
586
585
  returnurl: "",
587
586
  };
588
587
  const loginUrl = isPc
589
588
  ? `//passport.jd.com/new/login.aspx`
590
589
  : `${domain.mobileLogin}/user/login.action`;
591
590
  const defaultParams = {
592
591
  appid: "100",
593
592
  returnurl: window.location.href,
594
593
  };
595
594
  if (isString(options)) {
596
595
  params = Object.assign({}, defaultParams, {
597
596
  returnurl: options,
598
597
  });
599
598
  } else if (isObject(options)) {
600
599
  const { loginColor, ...otherOptions } = options;
601
600
  params = Object.assign({}, defaultParams, otherOptions);
602
601
  } else {
603
602
  params = defaultParams;
604
603
  }
605
604
  params.returnurl = encodeURIComponent(params.returnurl);
606
605
  let getFullUrl = loginUrl + "?" + serialize(params);
607
606
  if (isPc) {
608
607
  getFullUrl = getFullUrl.replace(/returnurl/, "ReturnUrl");
609
608
  }
610
609
  return Promise.resolve({
611
610
  h5ToUrl: true,
612
611
  url: getFullUrl,
613
612
  }).then(() => {
614
613
  window.location.href = getFullUrl;
615
614
  });
616
615
  }
617
616
 
618
617
  toWxAppLogin(options = {}) {
619
618
  console.log("微信京购小程序中h5登录跳转", options);
620
619
  return Promise.resolve(true).then(() => {
621
620
  const { loginColor } = Object.assign(
622
621
  {},
623
622
  {
624
623
  loginColor: {
625
624
  biz: WXAPP_BIZ_KEY,
626
625
  dpin: 1,
627
626
  },
628
627
  },
629
628
  options
630
629
  );
631
630
  window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
632
631
  loginColor.biz
633
632
  }&url=${encodeURIComponent(window.location.href)}`;
634
633
  });
635
634
  }
636
635
 
637
636
  getLoginCookie() {
638
637
  return Promise.resolve({
639
638
  pin: cookie.get("pin") || "",
640
639
  });
641
640
  }
642
641
 
643
642
  clearLoginCookie() {
644
643
  cookie.remove("pin");
645
644
  }
646
645
 
647
646
  checkStatusAndLogin(options = {}) {
648
647
  if (!this.checkStatusAndLoginPromise) {
649
648
  this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
650
649
  try {
651
650
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(
652
651
  options
653
652
  );
654
653
  if (getLoginState) {
655
654
  resolve(true);
656
655
  } else {
657
656
  this.toLogin(options);
658
657
  reject(false);
659
658
  }
660
659
  } catch (e) {
661
660
  this.toLogin(options);
662
661
  reject(false);
663
662
  }
664
663
  });
665
664
  return this.checkStatusAndLoginPromise;
666
665
  } else {
667
666
  return this.checkStatusAndLoginPromise
668
667
  .then(() => {
669
668
  return Promise.resolve(true);
670
669
  })
671
670
  .catch(() => {
672
671
  this.toLogin(options);
673
672
  return Promise.reject(true);
674
673
  });
675
674
  }
676
675
  }
677
676
 
678
677
  checkJdStatusAndLogin(
679
678
  options = {
680
679
  loginColor: {
681
680
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
682
681
  dpin: 0,
683
682
  },
684
683
  }
685
684
  ) {
686
685
  return this.checkStatusAndLogin(options);
687
686
  }
688
687
 
689
688
  doCheckLoginStateAndForApiCheck(options) {
690
689
  if (this.info.loginState) {
691
690
  return Promise.resolve(true);
692
691
  } else {
693
692
  return new Promise((resolve, reject) => {
694
693
  if (
695
694
  this.info.isJingGouMiniViewState ||
696
695
  this.info.isJingxiMiniViewState
697
696
  ) {
698
697
  const getWqAuthToken = cookie.get("wq_auth_token");
699
698
  const getWqSkey = cookie.get("wq_skey");
700
699
  const getWqUin = cookie.get("wq_uin");
701
700
  const isLoginState =
702
701
  options?.loginColor?.dpin === 0
703
702
  ? getWqAuthToken
704
703
  : getWqSkey && getWqUin;
705
704
  if (isLoginState) {
706
705
  this.info.loginState = true;
707
706
  resolve(true);
708
707
  } else {
709
708
  reject(false);
710
709
  }
711
710
  } else {
712
711
  Taro.request({
713
712
  url: api.isLogin,
714
713
  jsonp: true,
715
714
  timeout: 3000,
716
715
  success: (res) => {
717
716
  const { statusCode, data } = res;
718
717
  if (
719
718
  statusCode === 200 &&
720
719
  data?.islogin &&
721
720
  Number(data.islogin) === 1
722
721
  ) {
723
722
  this.info.loginState = true;
724
723
  resolve(true);
725
724
  } else {
726
725
  reject(false);
727
726
  }
728
727
  },
729
728
  fail: (err) => {
730
729
  console.log("登录检查异常", err);
731
730
  reject(false);
732
731
  },
733
732
  });
734
733
  }
735
734
  });
736
735
  }
737
736
  }
738
737
 
739
738
  checkLoginStatus(options) {
740
739
  return new Promise(async (resolve, reject) => {
741
740
  try {
742
741
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(
743
742
  options
744
743
  );
745
744
  if (getLoginState) {
746
745
  const { pin } = await this.getLoginCookie();
747
746
  this.info.userInfo = {
748
747
  pin,
749
748
  encodePin: encodeURIComponent(pin),
750
749
  ptkey: "",
751
750
  };
752
751
  resolve(true);
753
752
  } else {
754
753
  reject(false);
755
754
  }
756
755
  } catch (e) {
757
756
  reject(false);
758
757
  }
759
758
  });
760
759
  }
761
760
 
762
761
  updatePageAndLogInfo(updateQuery = {}) {
763
762
  const createUpdateQueryInfo: {
764
763
  query: {
765
764
  shopId?: string | number;
766
765
  venderId?: string | number;
767
766
  };
768
767
  updateShopInfoState: boolean;
769
768
  } = Object.assign(
770
769
  {},
771
770
  {
772
771
  query: {},
773
772
  updateShopInfoState: false,
774
773
  },
775
774
  updateQuery
776
775
  );
777
776
  console.log(
778
777
  "获取当前下发的店铺查询参数",
779
778
  updateQuery,
780
779
  "获取之前保存的shopInfo店铺查询参数",
781
780
  this.info?.shopInfo
782
781
  );
783
782
  const { query, updateShopInfoState } = createUpdateQueryInfo;
784
783
  const { shopId, venderId, un_area } = query;
785
784
  if (updateShopInfoState) {
786
785
  this.info.queryInfo = {
787
786
  ...this.info.queryInfo,
788
787
  ...query,
789
788
  };
790
789
  if (shopId && venderId) {
791
790
  this.info.shopInfo = {
792
791
  shopId: `${shopId}`,
793
792
  venderId: `${venderId}`,
794
793
  };
795
794
  }
796
795
  } else {
797
796
  this.info.queryInfo = {
798
797
  ...query,
799
798
  };
800
799
  if (
801
800
  this.info.shopInfo?.shopId &&
802
801
  this.info.shopInfo?.venderId &&
803
802
  (this.info.shopInfo.shopId == shopId ||
804
803
  this.info.shopInfo.venderId == venderId)
805
804
  ) {
806
805
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
807
806
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
808
807
  console.log(
809
808
  "当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数",
810
809
  this.info.queryInfo
811
810
  );
812
811
  }
813
812
  }
814
813
  this.info.queryInfo["shopId"] &&
815
814
  (this.info.queryInfo["shopId"] = `${this.info.queryInfo["shopId"]}`);
816
815
  this.info.queryInfo["venderId"] &&
817
816
  (this.info.queryInfo["venderId"] = `${this.info.queryInfo["venderId"]}`);
818
817
  console.log(
819
818
  "h5==获取店铺下发查询参数\n",
820
819
  query,
821
820
  "\n获取店铺最后查询参数\n",
822
821
  this.info.queryInfo,
823
822
  "\n是否为更新店铺状态\n",
824
823
  updateShopInfoState
825
824
  );
826
825
  const changeArea =
827
826
  un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : "";
828
827
  if (changeArea) {
829
828
  this.info.pageInfo.address = changeArea;
830
829
  this.info.pageInfo.un_area = changeArea;
831
830
  this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ",");
832
831
  }
833
832
  }
834
833
 
835
834
  dealLoadSdkList() {
836
835
  const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
837
836
  const businessLoadJsList =
838
837
  window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? [];
839
838
  const concatLoadJsList = [].concat(globalLoadJsList, businessLoadJsList);
840
839
  let mergeLoadJsList = globalLoadJsList;
841
840
  try {
842
841
  mergeLoadJsList = concatLoadJsList.reduce(
843
842
  (accArr: any[], current: any) => {
844
843
  const getFindIndex = accArr.findIndex(
845
844
  (item) => item?.fileName === current?.fileName
846
845
  );
847
846
  getFindIndex !== -1
848
847
  ? (accArr[getFindIndex] = { ...accArr[getFindIndex], ...current })
849
848
  : accArr.push(current);
850
849
  return accArr;
851
850
  },
852
851
  []
853
852
  );
854
853
  } catch (e) {
855
854
  console.log("LoadJsList合并错误", e);
856
855
  }
857
856
  console.log(
858
857
  "globalLoadJsList",
859
858
  globalLoadJsList,
860
859
  "businessLoadJsList",
861
860
  businessLoadJsList,
862
861
  "两个加载jsList集合合并完成",
863
862
  mergeLoadJsList
864
863
  );
865
864
  this.loadJsSdkList = mergeLoadJsList;
866
865
  return this.loadJsSdkList;
867
866
  }
868
867
 
869
868
  renderNextTickLoadSdk() {
870
869
  Taro.nextTick(() => {
871
870
  console.log(
872
871
  "页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s======="
873
872
  );
874
873
  setTimeout(() => {
875
874
  this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK, this.loadJsSdkList);
876
875
  }, 1000);
877
876
  });
878
877
  }
879
878
 
880
879
  loadOtherSdk(
881
880
  triggerType = LoadJsInitTriggerType.NOW,
882
881
  loadJsList: any[] = []
883
882
  ) {
884
883
  const getLoadJsList =
885
884
  Array.isArray(loadJsList) && loadJsList.length > 0
886
885
  ? loadJsList
887
886
  : this.dealLoadSdkList();
888
887
  const getLoadFilterList = getLoadJsList.filter((item) => {
889
888
  const getInitLoadEnvType =
890
889
  item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL;
891
890
  let getLoastLoadEventState = true;
892
891
  if (getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP) {
893
892
  getLoastLoadEventState = isJdApp;
894
893
  }
895
894
  else if (getInitLoadEnvType === LoadJsInitLoadEnvType.M) {
896
895
  getLoastLoadEventState = !isJdApp;
897
896
  }
898
897
  const getInitTriggerType =
899
898
  isJdApp && item?.initJdAppTriggerType
900
899
  ? item?.initTriggerType
901
900
  : item?.initTriggerType || LoadJsInitTriggerType.NOW;
902
901
  const getInitLinkTriggerWay =
903
902
  window?.PAGE_DATA[item?.initLinkTriggerWay] || false;
904
903
  return (
905
904
  getLoastLoadEventState &&
906
905
  getInitTriggerType === triggerType &&
907
906
  getInitLinkTriggerWay
908
907
  );
909
908
  });
910
909
  console.log(
911
910
  "获取当前触发方式",
912
911
  triggerType,
913
912
  "获取当前最后加载的js集合",
914
913
  getLoadFilterList,
915
914
  "过滤前的加载集合",
916
915
  getLoadJsList
917
916
  );
918
917
  getLoadFilterList.length > 0 &&
919
918
  getLoadFilterList.forEach((item) => {
920
919
  const isLoadState = /sgm/.test(item?.fileName)
921
920
  ? window?.shopGlobalSwitch?.openSgm === "true"
922
921
  : true;
923
922
  isLoadState &&
924
923
  this.loadItemSdkPromise(item)
925
924
  .then((res) => {
926
925
  console.info("当前js地址" + item?.src, "加载状态", res);
927
926
  })
928
927
  .catch((err) => {
929
928
  console.info("当前js地址加载异常", item?.src);
930
929
  window?.fetchErrorData &&
931
930
  window.fetchErrorData({
932
931
  title: "公共js加载异常",
933
932
  type: "jsLoad",
934
933
  data: err,
935
934
  });
936
935
  });
937
936
  });
938
937
  }
939
938
  loadScriptEle(jsInfo, resolve, reject) {
940
939
  const getFileName = jsInfo?.fileName;
941
940
  if (getFileName) {
942
941
  const getEleId = `J_loadJs_${getFileName}`;
943
942
  const getEle = document.getElementById(getEleId);
944
943
  if (!getEle) {
945
944
  const jsLoadErrorSgmCode = `jsLoadError_${
946
945
  jsInfo?.fileName || "customJs"
947
946
  }`;
948
947
  const _sgmEle = document.createElement("script");
949
948
  _sgmEle.id = getEleId;
950
949
  _sgmEle.onload = function () {
951
950
  resolve({
952
951
  ...jsInfo,
953
952
  jsTip: "js加载成功",
954
953
  });
955
954
  };
956
955
  _sgmEle.onerror = function () {
957
956
  reject({
958
957
  ...jsInfo,
959
958
  env: getSgmCustomCode(jsLoadErrorSgmCode),
960
959
  jsReqError:
961
960
  "当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误",
962
961
  });
963
962
  };
964
963
  const dataAttrList = ["timeout", "fileName", "env"];
965
964
  const getJsInfoKeyList = Object.keys(jsInfo);
966
965
  getJsInfoKeyList.forEach((key) => {
967
966
  if (key === "async") {
968
967
  _sgmEle.async = jsInfo[key];
969
968
  } else if (key === "crossOrigin") {
970
969
  _sgmEle.crossOrigin = jsInfo[key];
971
970
  } else if (key === "src") {
972
971
  _sgmEle.src = `${jsInfo[key]}`;
973
972
  } else if (dataAttrList.includes(key) || /init/.test(key)) {
974
973
  _sgmEle.setAttribute(`data-${key}`, jsInfo[key]);
975
974
  } else {
976
975
  _sgmEle.setAttribute(key, jsInfo[key]);
977
976
  }
978
977
  });
979
978
  document.head.appendChild(_sgmEle);
980
979
  } else {
981
980
  console.log(
982
981
  `当前${jsInfo?.fileName || "js"}已经存在页面中,可以直接调用相关方法`,
983
982
  jsInfo
984
983
  );
985
984
  resolve({
986
985
  ...jsInfo,
987
986
  jsTip: "js本身已存在页面中",
988
987
  });
989
988
  }
990
989
  } else {
991
990
  console.warn("当前js资源信息缺少必要的参数fileName,请关注", jsInfo);
992
991
  }
993
992
  }
994
993
 
995
994
  loadItemSdkPromise(jsInfo = {}) {
996
995
  if (jsInfo?.src) {
997
996
  const getInitLoadType =
998
997
  isJdApp && jsInfo?.initJdAppLoadType
999
998
  ? jsInfo?.initJdAppLoadType
1000
999
  : jsInfo?.initLoadType || LoadJsInitLoadType.ALL;
1001
1000
  if (getInitLoadType !== LoadJsInitLoadType.NONE) {
1002
1001
  const getFileKeyName = jsInfo?.fileName || jsInfo?.src;
1003
1002
  if (!this.loadJsSdkListCachePromise[getFileKeyName]) {
1004
1003
  if (getInitLoadType !== LoadJsInitLoadType.INSERT_ELE) {
1005
1004
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise(
1006
1005
  (resolve, reject) => {
1007
1006
  const jsLoadErrorSgmCode = `jsLoadError_${
1008
1007
  jsInfo?.fileName || "customJs"
1009
1008
  }`;
1010
1009
  try {
1011
1010
  const jsXhrRequest = new XMLHttpRequest();
1012
1011
  jsXhrRequest.timeout = jsInfo?.timeout ?? 2000;
1013
1012
  const jsUrl = `${jsInfo?.src}`;
1014
1013
  jsXhrRequest.open("GET", jsUrl, true);
1015
1014
  jsXhrRequest.onload = () => {
1016
1015
  if (jsXhrRequest.status === 200) {
1017
1016
  const getInsetHeadState =
1018
1017
  getInitLoadType === LoadJsInitLoadType.ALL;
1019
1018
  if (getInsetHeadState) {
1020
1019
  this.loadScriptEle(jsInfo, resolve, reject);
1021
1020
  } else {
1022
1021
  resolve({
1023
1022
  ...jsInfo,
1024
1023
  jsTip:
1025
1024
  "js请求成功,暂未插入head节点,业务自行单独插入",
1026
1025
  });
1027
1026
  }
1028
1027
  } else {
1029
1028
  const getRes = {
1030
1029
  ...jsInfo,
1031
1030
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1032
1031
  jsReqError: `请求状态异常,状态为${jsXhrRequest?.status}`,
1033
1032
  jsReqState: jsXhrRequest?.status,
1034
1033
  };
1035
1034
  console.log("当前js请求状态异常", getRes);
1036
1035
  reject(getRes);
1037
1036
  }
1038
1037
  };
1039
1038
  jsXhrRequest.onerror = () => {
1040
1039
  const getRes = {
1041
1040
  ...jsInfo,
1042
1041
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1043
1042
  jsReqError: "请求错误",
1044
1043
  };
1045
1044
  console.log("当前js请求错误", getRes);
1046
1045
  jsXhrRequest.abort();
1047
1046
  reject(getRes);
1048
1047
  };
1049
1048
  jsXhrRequest.ontimeout = () => {
1050
1049
  const getRes = {
1051
1050
  ...jsInfo,
1052
1051
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1053
1052
  jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
1054
1053
  };
1055
1054
  console.log("当前js请求超时异常", getRes);
1056
1055
  jsXhrRequest.abort();
1057
1056
  reject(getRes);
1058
1057
  };
1059
1058
  jsXhrRequest.send();
1060
1059
  } catch (e) {
1061
1060
  console.log("执行js请求异常", e);
1062
1061
  reject({
1063
1062
  ...jsInfo,
1064
1063
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1065
1064
  jsReqError: "未知异常",
1066
1065
  error: e,
1067
1066
  });
1068
1067
  }
1069
1068
  }
1070
1069
  );
1071
1070
  } else {
1072
1071
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise(
1073
1072
  (resolve, reject) => {
1074
1073
  return this.loadScriptEle(jsInfo, resolve, reject);
1075
1074
  }
1076
1075
  );
1077
1076
  }
1078
1077
  }
1079
1078
  return this.loadJsSdkListCachePromise[getFileKeyName];
1080
1079
  } else {
1081
1080
  return Promise.resolve({
1082
1081
  ...jsInfo,
1083
1082
  jsTip: "js加载方式设置为不加载,当前不做处理",
1084
1083
  });
1085
1084
  }
1086
1085
  } else {
1087
1086
  return Promise.reject(jsInfo);
1088
1087
  }
1089
1088
  }
1089
+ import Taro from '@tarojs/taro'
1090
1090
  isIosDevice,
1091
1091
  isAndroidDevice,
1092
1092
  isJdAndHarmonyDevice,
1093
1093
  isJdAndAndroidDevice,
1094
1094
  jdAppVersion,
1095
1095
  jdAppVersionStr,
1096
1096
  isString,
1097
1097
  isObject,
1098
1098
  serialize,
1099
1099
  dealNativePixelToCssPixel,
1100
1100
  isPc,
1101
1101
  BUSINESS_TYPE,
1102
1102
  JSSDK_APP_WEBVIEW_CODE,
1103
1103
  SECTION_HOME_TAB_NAME_TYPE,
1104
1104
  SECTION_HOME_TAB_TYPE,
1105
1105
  WXAPP_BIZ_KEY,
1106
1106
  WX_BUSINESS_TYPE,
1107
1107
  MPAAS_CONFIG_APP_VERSION,
1108
1108
  MPAAS_CONFIG_APP_LOW_VERSION,
1109
1109
  WXAPP_BIZ_SHOP_LIGHT_KEY,
1110
1110
  LoadJsInitLoadEnvType,
1111
1111
  LoadJsInitLoadType,
1112
1112
  LoadJsInitTriggerType
1113
1113
  loginState: false,
1114
1114
  cookiesStr: '',
1115
1115
  userInfo: userPinKey,
1116
1116
  isJingGouMiniViewState: false,
1117
1117
  isJingxiMiniViewState: false,
1118
1118
  pageInfo: {
1119
1119
  wxBusinessType: WX_BUSINESS_TYPE.NO,
1120
1120
  address: '',
1121
1121
  addressCommaStr: '',
1122
1122
  un_area: '',
1123
1123
  vapptype: '1',
1124
1124
  pageType: 'home',
1125
1125
  isExposureState: false,
1126
1126
  moduleId: '',
1127
1127
  entrance: '',
1128
1128
  dataType: BUSINESS_TYPE.ONLINE,
1129
1129
  floorExposureInfo: {},
1130
1130
  floorVideInfo: {},
1131
1131
  productVideInfo: {},
1132
1132
  tabsLoadAllDataInfo: {
1133
1133
  [SECTION_HOME_TAB_NAME_TYPE[
1134
1134
  SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
1135
1135
  ]]: false,
1136
1136
  },
1137
1137
  updateShopInfosAllState: false,
1138
1138
  isVipShop: false,
1139
1139
  isJdShowNativeImmersivePlayer: false,
1140
1140
  ...shopConfig,
1141
1141
  pageScrollTop: 0,
1142
1142
  pageIdxHeightInfo: {
1143
1143
  list: [],
1144
1144
  },
1145
1145
  shopNavBarHeight: 0,
1146
1146
  },
1147
1147
  defaultQueryLogInfo: {
1148
1148
  sourceType: 'JDshop',
1149
1149
  sourceValue: '',
1150
1150
  moduleId: 'none',
1151
1151
  entrance: 'none',
1152
1152
  },
1153
1153
  sysInfo: {
1154
1154
  windowWidth: isPc ? 375 : 0,
1155
1155
  containerWidth: isPc ? 375 : 0,
1156
1156
  windowHeight: 0,
1157
1157
  netWorkType: '4g',
1158
1158
  jdBottomBarHeight: 0,
1159
1159
  jdNativeHeaderHeight: 0,
1160
1160
  },
1161
1161
  queryInfo: {},
1162
1162
  shopInfo: {},
1163
1163
  openAppData: {},
1164
1164
  public info: CommonInterFace.BaseConfigInfo
1165
1165
  public config: {
1166
1166
  [key: string]: any
1167
1167
  }
1168
1168
  public lazyContainer: CommonInterFace.lazyContainer
1169
1169
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents
1170
1170
  public rootEleNode: HTMLElement | null
1171
1171
  public checkStatusAndLoginPromise: object | null
1172
1172
  private jmfeRegisterStatePromise: Promise<any> | null
1173
1173
  private jmfeRegisterState: boolean
1174
1174
  public loadJsSdkList: Array<any>
1175
1175
  public loadJsSdkListCachePromise: any
1176
1176
  constructor(opt) {
1177
1177
  this.info = this._getConfig(opt)
1178
1178
  this.config = {}
1179
1179
  this.loadJsSdkList = []
1180
1180
  this.loadJsSdkListCachePromise = {}
1181
1181
  this.lazyContainer = {
1182
1182
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
1183
1183
  appLazyContainerList: [],
1184
1184
  appLazyFinishContainerList: [],
1185
1185
  },
1186
1186
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
1187
1187
  appLazyContainerList: [],
1188
1188
  appLazyFinishContainerList: [],
1189
1189
  },
1190
1190
  }
1191
1191
  this.renderedIsvComponents = {}
1192
1192
  this.rootEleNode = document.querySelector('body')
1193
1193
  this.checkStatusAndLoginPromise = null
1194
1194
  this.jmfeRegisterStatePromise = null
1195
1195
  this.loadOtherSdk()
1196
1196
  isJdApp && this.jmfeReayPromise()
1197
1197
  }
1198
1198
  _getConfig(opt) {
1199
1199
  return Object.assign({}, DefaultConfig, opt)
1200
1200
  }
1201
1201
 
1202
1202
  jmfeReayPromise(): Promise<any> {
1203
1203
  if (isJdApp) {
1204
1204
  if (this.jmfeRegisterState) {
1205
1205
  return Promise.resolve(true)
1206
1206
  } else {
1207
1207
  !this.jmfeRegisterStatePromise &&
1208
1208
  (this.jmfeRegisterStatePromise = new Promise((resolve, reject) => {
1209
1209
  ready('jmfe', 3000)
1210
1210
  .then(() => {
1211
1211
  window?.jmfe && window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE)
1212
1212
  this.jmfeRegisterState = true
1213
1213
  resolve(true)
1214
1214
  console.log('松果app内初始化注册jmfe认证完成')
1215
1215
  })
1216
1216
  .catch((err) => {
1217
1217
  console.error('jmfe ready error', err)
1218
1218
  reject(false)
1219
1219
  })
1220
1220
  }))
1221
1221
  return this.jmfeRegisterStatePromise
1222
1222
  }
1223
1223
  } else {
1224
1224
  return Promise.reject(false)
1225
1225
  }
1226
1226
  }
1227
1227
 
1228
1228
  updateBusinessDomainAndApi(domain, api) {
1229
1229
  }
1230
1230
 
1231
1231
  formatNativeScreenPageData(action) {
1232
1232
  let getChangePageInfo: any = null
1233
1233
  try {
1234
1234
  const getNativeScreenPageInfoStr = window.XWebView?._callNative(
1235
1235
  JSON.stringify({
1236
1236
  plugin: 'JDHybridScreenPlugin',
1237
1237
  action,
1238
1238
  sync: '1',
1239
1239
  }),
1240
1240
  )
1241
1241
  const getChangePageInfoData =
1242
1242
  typeof getNativeScreenPageInfoStr === 'string'
1243
1243
  ? JSON.parse(getNativeScreenPageInfoStr)
1244
1244
  : null
1245
1245
  if (getChangePageInfoData && typeof getChangePageInfoData === 'object') {
1246
1246
  const { code, data } = getChangePageInfoData
1247
1247
  getChangePageInfo = code && code === '0' ? data : null
1248
1248
  }
1249
1249
  } catch (e) {
1250
1250
  console.log('JDHybridScreenPlugin转换异常', e)
1251
1251
  }
1252
1252
  return getChangePageInfo
1253
1253
  }
1254
1254
 
1255
1255
  isAndroidFoldScreen() {
1256
1256
  return this.formatNativeScreenPageData('isFoldScreen') === '1'
1257
1257
  }
1258
1258
 
1259
1259
  getJdAndroidPageChangeScreenInfo() {
1260
1260
  const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize')
1261
1261
  if (
1262
1262
  getPageScreenInfo &&
1263
1263
  getPageScreenInfo?.pageWidth &&
1264
1264
  getPageScreenInfo?.pageHeight
1265
1265
  ) {
1266
1266
  const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
1267
1267
  pageWidth: getPageScreenInfo.pageWidth,
1268
1268
  pageHeight: getPageScreenInfo.pageHeight,
1269
1269
  })
1270
1270
  getPageScreenInfo.pageWidth = pageWidth
1271
1271
  getPageScreenInfo.pageHeight = pageHeight
1272
1272
  }
1273
1273
  return getPageScreenInfo
1274
1274
  }
1275
1275
 
1276
1276
  getSystemInfo(params) {
1277
1277
  let info: UtilsInterFace.taroGetSystemInfoSyncRes | {} = isPc
1278
1278
  ? {}
1279
1279
  : getSystemInfos(params)
1280
1280
  if (isJdAndAndroidDevice && info?.initWindowWidth <= 0) {
1281
1281
  let _isfoldScreen = false
1282
1282
  const getStorageData = getTaroStorageKeyValue("jd_shopx_androidIsFoldScreen")
1283
1283
  console.info("获取当前本地存储是否有jd_shopx_androidIsFoldScreen", getStorageData,"通过缓存值第一次判断是否是折叠屏", getStorageData === 'true')
1284
1284
  if(!getStorageData){
1285
1285
  _isfoldScreen = this.isAndroidFoldScreen()
1286
1286
  setTaroStorage("jd_shopx_androidIsFoldScreen", `${_isfoldScreen}`)
1287
1287
  }else {
1288
1288
  _isfoldScreen = getStorageData === 'true'
1289
1289
  }
1290
1290
  if (_isfoldScreen) {
1291
1291
  const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo()
1292
1292
  if(getJdAndroidPageInfo){
1293
1293
  info = getSystemInfos(getJdAndroidPageInfo)
1294
1294
  console.warn("当前为松果安卓折叠屏app,获取折叠屏信息",getJdAndroidPageInfo,"获取转换后的系统信息",info)
1295
1295
  sgmCustomReport({
1296
1296
  type: 2,
1297
1297
  code: 'android_jdapp_foldScreen_info',
1298
1298
  msg: {
1299
1299
  title: `松果安卓app为折叠屏,重置获取的系统宽高信息,因为获取宽高度信息初始化内部可能存在横竖屏差异`,
1300
1300
  androidPageInfo: getJdAndroidPageInfo,
1301
1301
  jdAppVersionStr,
1302
1302
  taroSysInfo: info
1303
1303
  }
1304
1304
  })
1305
1305
  }
1306
1306
  }
1307
1307
  }
1308
1308
  this.info.sysInfo = {
1309
1309
  actualNavBarHeight: 0,
1310
1310
  ...this.info.sysInfo,
1311
1311
  ...info,
1312
1312
  safeContentHeight: info?.screenHeight,
1313
1313
  headerHeight: 0,
1314
1314
  tabBarHeight: 0,
1315
1315
  }
1316
1316
  if (isJdApp) {
1317
1317
  this.info.sysInfo['hostVersionName'] = jdAppVersionStr
1318
1318
  this.info.sysInfo['hostAppVersion'] = jdAppVersion
1319
1319
  this.getAddressCachePromise()
1320
1320
  this.getElderModePromise()
1321
1321
  this.getJDAppearanceStatePromise()
1322
1322
  this.createJdAndroidRquestEventForTouchStart()
1323
1323
  }
1324
1324
  this.getWifiVideoAutoPlayAsync()
1325
1325
  this.getMPaasConfigAsync()
1326
1326
  this.getNetWorkType()
1327
1327
  }
1328
1328
 
1329
1329
  taskTimeoutPromise(callBack, timeout = 2000) {
1330
1330
  return new Promise(resolve => {
1331
1331
  setTimeout(() => {
1332
1332
  const getCallBackRes = typeof callBack === 'function' && callBack()
1333
1333
  return resolve(getCallBackRes || false)
1334
1334
  }, timeout)
1335
1335
  })
1336
1336
  }
1337
1337
 
1338
1338
  getElderModePromise() {
1339
1339
  if (this.info.sysInfo.hasOwnProperty('jdAppModeType')) {
1340
1340
  return Promise.resolve(this.info.sysInfo.jdAppModeType)
1341
1341
  } else {
1342
1342
  if (isJdAndAndroidDevice) {
1343
1343
  this.info.sysInfo.jdAppModeType = '0'
1344
1344
  return Promise.resolve(this.info.sysInfo.jdAppModeType)
1345
1345
  } else {
1346
1346
  return Promise.race([
1347
1347
  this.taskTimeoutPromise(() => {
1348
1348
  this.info.sysInfo.jdAppModeType = '0'
1349
1349
  return this.info.sysInfo.jdAppModeType
1350
1350
  }),
1351
1351
  new Promise(resolve => {
1352
1352
  const getCallBackName = `getJdCurrentModeType${Date.now()}`
1353
1353
  if (!window[getCallBackName]) {
1354
1354
  window[getCallBackName] = res => {
1355
1355
  try {
1356
1356
  const getResJson =
1357
1357
  typeof res === 'string' ? JSON.parse(res) : res
1358
1358
  const { status, data, msg } = getResJson
1359
1359
  console.log(`获取松果app展示模式成功,返回结果${data}`)
1360
1360
  if (status === '0') {
1361
1361
  this.info.sysInfo.jdAppModeType = data
1362
1362
  resolve(data)
1363
1363
  } else {
1364
1364
  resolve('0')
1365
1365
  }
1366
1366
  } catch (e) {
1367
1367
  resolve('0')
1368
1368
  }
1369
1369
  window[getCallBackName] = null
1370
1370
  }
1371
1371
  }
1372
1372
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
1373
1373
  method: 'callSyncRouterModuleWithParams',
1374
1374
  params: JSON.stringify({
1375
1375
  routerURL: 'router://JDBModeModule/getCurrentMode',
1376
1376
  routerParam: {},
1377
1377
  callBackName: `window.${getCallBackName}`,
1378
1378
  callBackId: `${getCallBackName}Ios`,
1379
1379
  }),
1380
1380
  })
1381
1381
  }),
1382
1382
  ])
1383
1383
  }
1384
1384
  }
1385
1385
  }
1386
1386
  getAPPUseStraightCorner() {
1387
1387
  const routerURL = 'router://JDBaseUtilsModule/isUI14Enable'
1388
1388
  const params = {
1389
1389
  routerURL,
1390
1390
  routerParam: {},
1391
1391
  jdRouter: '1',
1392
1392
  }
1393
1393
  if (this.info.sysInfo.hasOwnProperty('jdStraightCorner')) {
1394
1394
  return Promise.resolve(this.info.sysInfo.jdStraightCorner)
1395
1395
  } else {
1396
1396
  return this.jmfeReayPromise()
1397
1397
  .then(() => {
1398
1398
  if(isJdAndHarmonyDevice || !isJdApp) {
1399
1399
  console.log('not APP or is Harmony')
1400
1400
  return Promise.resolve(false)
1401
1401
  }
1402
1402
  console.log('jmfe setShareInfo', params)
1403
1403
  return Promise.race([window.jmfe.callRouter(params), this.taskTimeoutPromise(() => {return false})])
1404
1404
  .then(({ status, data }) => {
1405
1405
  console.log('004 ~ file: index.tsx:133 ~ .then ~ data:', data)
1406
1406
  console.log('004 ~ file: index.tsx:133 ~ .then ~ status:', status)
1407
1407
  this.info.sysInfo.jdStraightCorner = status === '0' && Number(data) === 1
1408
1408
  return Promise.resolve( status === '0' && Number(data) === 1)
1409
1409
  })
1410
1410
  })
1411
1411
  .catch(e => {
1412
1412
  console.log('jmfe error', e)
1413
1413
  return Promise.resolve(false)
1414
1414
  })
1415
1415
  }
1416
1416
  }
1417
1417
 
1418
1418
  getJDAppearanceStatePromise() {
1419
1419
  if (this.info.sysInfo.hasOwnProperty('jdAppearanceState')) {
1420
1420
  return Promise.resolve(this.info.sysInfo.jdAppearanceState)
1421
1421
  } else {
1422
1422
  return Promise.race([
1423
1423
  this.taskTimeoutPromise(() => {
1424
1424
  this.info.sysInfo.jdAppearanceState = '0'
1425
1425
  return this.info.sysInfo.jdAppearanceState
1426
1426
  }),
1427
1427
  new Promise(resolve => {
1428
1428
  const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`
1429
1429
  if (!window[getCallBackName]) {
1430
1430
  window[getCallBackName] = res => {
1431
1431
  try {
1432
1432
  console.log('getJDAppearanceStatePromise', res)
1433
1433
  const getResJson =
1434
1434
  typeof res === 'string' ? JSON.parse(res) : res
1435
1435
  const { status, data, msg } = getResJson
1436
1436
  console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`)
1437
1437
  if (status === '0') {
1438
1438
  this.info.sysInfo.jdAppearanceState = data
1439
1439
  resolve(data)
1440
1440
  } else {
1441
1441
  resolve('0')
1442
1442
  }
1443
1443
  } catch (e) {
1444
1444
  resolve('0')
1445
1445
  }
1446
1446
  window[getCallBackName] = null
1447
1447
  }
1448
1448
  }
1449
1449
  if (isAndroidDevice) {
1450
1450
  const jsonString = JSON.stringify({
1451
1451
  callBackName: `window.${getCallBackName}`,
1452
1452
  })
1453
1453
  console.log('window.JDAppearance', window.JDAppearance)
1454
1454
  window.JDAppearance && window.JDAppearance.getUiState(jsonString)
1455
1455
  } else {
1456
1456
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
1457
1457
  method: 'callSyncRouterModuleWithParams',
1458
1458
  params: JSON.stringify({
1459
1459
  routerURL:
1460
1460
  'router://JDWebViewBusinessModule/getJDAppearanceState',
1461
1461
  routerParam: {},
1462
1462
  callBackName: `window.${getCallBackName}`,
1463
1463
  callBackId: `${getCallBackName}Ios`,
1464
1464
  }),
1465
1465
  })
1466
1466
  }
1467
1467
  }),
1468
1468
  ])
1469
1469
  }
1470
1470
  }
1471
1471
 
1472
1472
  createJdAndroidRquestEventForTouchStart() {
1473
1473
  if (isJdAndAndroidDevice && window.JdAndroid) {
1474
1474
  const rootEleNode = document.querySelector('body')
1475
1475
  if (rootEleNode) {
1476
1476
  rootEleNode.addEventListener(
1477
1477
  'touchstart',
1478
1478
  this.jdAndroidAddEventListenerTouchStart,
1479
1479
  false,
1480
1480
  )
1481
1481
  }
1482
1482
  }
1483
1483
  }
1484
1484
  jdAndroidAddEventListenerTouchStart(e) {
1485
1485
  const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom')
1486
1486
  if (!isH5SwiperCustomEle) {
1487
1487
  const hasCustomEle = e
1488
1488
  ? e?.target?.closest('.J_customScroll') ||
1489
1489
  e?.target?.closest('.J_customLayout')
1490
1490
  : false
1491
1491
  if (!hasCustomEle) {
1492
1492
  window.JdAndroid.requestEvent(false)
1493
1493
  console.log(
1494
1494
  'createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false',
1495
1495
  )
1496
1496
  }
1497
1497
  }
1498
1498
  }
1499
1499
  removeJdAndroidRquestEventForTouchStart() {
1500
1500
  if (isJdAndAndroidDevice && window.JdAndroid) {
1501
1501
  const rootEleNode = document.querySelector('body')
1502
1502
  if (rootEleNode) {
1503
1503
  rootEleNode.removeEventListener(
1504
1504
  'touchstart',
1505
1505
  this.jdAndroidAddEventListenerTouchStart,
1506
1506
  false,
1507
1507
  )
1508
1508
  }
1509
1509
  }
1510
1510
  }
1511
1511
 
1512
1512
  getNetWorkType() {
1513
1513
  if (isJdApp) {
1514
1514
  this.jmfeReayPromise().then(() => {
1515
1515
  window.jmfe
1516
1516
  .getNetworkStatus()
1517
1517
  .then(({ status, data }) => {
1518
1518
  console.log(
1519
1519
  '在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====',
1520
1520
  data,
1521
1521
  )
1522
1522
  if (status === '0') {
1523
1523
  this.info.sysInfo['netWorkType'] = data
1524
1524
  } else {
1525
1525
  this._taroGetNetworkType()
1526
1526
  }
1527
1527
  })
1528
1528
  .catch(err => {
1529
1529
  console.log('在app内初始化通过jmfe对象获取网络状态异常====', err)
1530
1530
  this._taroGetNetworkType()
1531
1531
  })
1532
1532
  })
1533
1533
  } else {
1534
1534
  this._taroGetNetworkType()
1535
1535
  }
1536
1536
  }
1537
1537
  _taroGetNetworkType() {
1538
1538
  Taro.getNetworkType().then(getRes => {
1539
1539
  if (getRes && getRes.networkType) {
1540
1540
  this.info.sysInfo['netWorkType'] = getRes.networkType
1541
1541
  console.log(
1542
1542
  '在app内通过taro对象获取网络状态完成,当前网络状态',
1543
1543
  this.info.sysInfo['netWorkType'],
1544
1544
  )
1545
1545
  }
1546
1546
  })
1547
1547
  }
1548
1548
  getCacheAddressRouter() {
1549
1549
  if (!window.jmfe) return
1550
1550
  if (isAndroidDevice) {
1551
1551
  return window.jmfe.callRouter({
1552
1552
  jdRouter: '1',
1553
1553
  routerURL: 'router://JDAddressModule/getCacheAddress',
1554
1554
  routerParam: { sceneId: 'basicShoppingProcess' },
1555
1555
  })
1556
1556
  } else if (isIosDevice) {
1557
1557
  return window.jmfe.callRouter({
1558
1558
  jdRouter: '1',
1559
1559
  routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
1560
1560
  routerParam: { sceneId: 'basicShoppingProcess' },
1561
1561
  })
1562
1562
  } else if (isJdAndHarmonyDevice) {
1563
1563
  return new Promise(resolve => {
1564
1564
  resolve({})
1565
1565
  })
1566
1566
  } else {
1567
1567
  throw Error(
1568
1568
  'Unknown device type cannot obtain the address information through the route!',
1569
1569
  )
1570
1570
  }
1571
1571
  }
1572
1572
 
1573
1573
  getAddressCachePromise() {
1574
1574
  return new Promise(resolve => {
1575
1575
  if (
1576
1576
  this?.info?.sysInfo?.lat &&
1577
1577
  this?.info?.sysInfo?.lng &&
1578
1578
  this?.info?.sysInfo?.area
1579
1579
  ) {
1580
1580
  resolve({
1581
1581
  lat: this.info.sysInfo.lat,
1582
1582
  lng: this.info.sysInfo.lng,
1583
1583
  area: this?.info?.sysInfo?.area,
1584
1584
  })
1585
1585
  } else {
1586
1586
  this.jmfeReayPromise().then(() => {
1587
1587
  this.getCacheAddressRouter()
1588
1588
  .then(({ status, data }) => {
1589
1589
  console.log("原生端获取经纬度原始数据结果",status,data)
1590
1590
  if (status === '0' && data) {
1591
1591
  const {
1592
1592
  lat,
1593
1593
  latitude,
1594
1594
  lng,
1595
1595
  longitude,
1596
1596
  provinceId,
1597
1597
  cityId,
1598
1598
  countyId,
1599
1599
  townId,
1600
1600
  } = data || {}
1601
1601
  let area = ''
1602
1602
  this.info.sysInfo['lat'] = `${lat || latitude || ''}`
1603
1603
  this.info.sysInfo['lng'] = `${lng || longitude || ''}`
1604
1604
  if (provinceId) {
1605
1605
  area = `${provinceId}_${cityId || 0}_${countyId ||
1606
1606
  0}_${townId || 0}`
1607
1607
  this.info.pageInfo['address'] = area
1608
1608
  this.info.pageInfo['addressCommaStr'] = area.replace(
1609
1609
  /_/g,
1610
1610
  ',',
1611
1611
  )
1612
1612
  }
1613
1613
  resolve({
1614
1614
  lat: this.info.sysInfo['lat'],
1615
1615
  lng: this.info.sysInfo['lng'],
1616
1616
  area: area,
1617
1617
  })
1618
1618
  } else {
1619
1619
  resolve({ lat: '', lng: '', area: '' })
1620
1620
  }
1621
1621
  })
1622
1622
  .catch(e => {
1623
1623
  console.log(' ~~ file: index.h5.ts:518 ~~ .catch ~~ e:', e)
1624
1624
  resolve({ lat: '', lng: '', area: '' })
1625
1625
  console.log('getCacheAddressRouter catch e,获取经纬度信息异常e', e)
1626
1626
  })
1627
1627
  }).catch(e => {
1628
1628
  resolve({ lat: '', lng: '', area: '' })
1629
1629
  console.log('判断jmfe不存在,获取经纬度信息异常e', e)
1630
1630
  })
1631
1631
  }
1632
1632
  })
1633
1633
  }
1634
1634
 
1635
1635
  async updateMPaasConfigAsync(isBeforePageReady: boolean) {
1636
1636
  console.log("updateMPaasConfigAsync isBeforePageReady:", isBeforePageReady)
1637
1637
  if (!isJdApp) {
1638
1638
  return
1639
1639
  }
1640
1640
  const avifSwitch = await getMPaasConfigByBussinessKey(
1641
1641
  'avifSwitch',
1642
1642
  isBeforePageReady,
1643
1643
  )
1644
1644
  this.info.sysInfo.dynamicConfig['avifSwitch'] = avifSwitch
1645
1645
  const hybridHttpSwitch = await getMPaasConfigByBussinessKey(
1646
1646
  'hybridHttpSwitch',
1647
1647
  isBeforePageReady,
1648
1648
  )
1649
1649
  this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = hybridHttpSwitch
1650
1650
  const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
1651
1651
  'isFollowAppVideoPlayStatus',
1652
1652
  isBeforePageReady,
1653
1653
  )
1654
1654
  console.log(
1655
1655
  'isBeforePageReady:',
1656
1656
  isBeforePageReady,
1657
1657
  'isFollowAppVideoPlayStatus:',
1658
1658
  isFollowAppVideoPlayStatus,
1659
1659
  )
1660
1660
  if (
1661
1661
  isFollowAppVideoPlayStatus === true ||
1662
1662
  isFollowAppVideoPlayStatus === 'true'
1663
1663
  ) {
1664
1664
  this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = true
1665
1665
  }
1666
1666
  }
1667
1667
 
1668
1668
  async getWifiVideoAutoPlayAsync() {
1669
1669
  this.info.sysInfo['wifiVideoAutoPlay'] = false
1670
1670
  if (!isJdApp) {
1671
1671
  return
1672
1672
  }
1673
1673
  const videoPlayStatus = await getWifiVideoAutoPlay().catch(e => {
1674
1674
  return 0
1675
1675
  })
1676
1676
  if (Number(videoPlayStatus) === 1) {
1677
1677
  this.info.sysInfo['wifiVideoAutoPlay'] = true
1678
1678
  }
1679
1679
  }
1680
1680
 
1681
1681
  async getMPaasConfigAsync() {
1682
1682
  this.info.sysInfo.dynamicConfig = {}
1683
1683
  this.info.sysInfo.dynamicConfig['avifSwitch'] = {}
1684
1684
  this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = {}
1685
1685
  this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = false
1686
1686
  return this.updateMPaasConfigAsync(true)
1687
1687
  }
1688
1688
 
1689
1689
  getDynamicConfig(key: string){
1690
1690
  return this.info.sysInfo.dynamicConfig[key]
1691
1691
  }
1692
1692
  async updateMPaasConfig() {
1693
1693
  console.log('updateMPaasConfig')
1694
1694
  if (
1695
1695
  isIosDevice &&
1696
1696
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
1697
1697
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
1698
1698
  ) {
1699
1699
  try {
1700
1700
  await this.updateMPaasConfigAsync(false)
1701
1701
  } catch (e) {
1702
1702
  console.log('updateMPaasConfigAsync:', e)
1703
1703
  }
1704
1704
  }
1705
1705
  }
1706
1706
 
1707
1707
  toLogin(options) {
1708
1708
  return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
1709
1709
  ? this.toWxAppLogin(options)
1710
1710
  : this.toWebLogin(options)
1711
1711
  }
1712
1712
 
1713
1713
  doLogin(options) {
1714
1714
  return this.toLogin(options)
1715
1715
  }
1716
1716
 
1717
1717
  doLoginForJdPin(options = {}) {
1718
1718
  return this.doLogin({
1719
1719
  loginColor: {
1720
1720
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
1721
1721
  dpin: 0,
1722
1722
  },
1723
1723
  ...options,
1724
1724
  })
1725
1725
  }
1726
1726
 
1727
1727
  toWebLogin(options) {
1728
1728
  let params: {
1729
1729
  returnurl: string
1730
1730
  } = {
1731
1731
  returnurl: '',
1732
1732
  }
1733
1733
  const loginUrl = isPc
1734
1734
  ? `//passport.jd.com/new/login.aspx`
1735
1735
  : `${domain.mobileLogin}/user/login.action`
1736
1736
  const defaultParams = {
1737
1737
  appid: '100',
1738
1738
  returnurl: window.location.href,
1739
1739
  }
1740
1740
  if (isString(options)) {
1741
1741
  params = Object.assign({}, defaultParams, {
1742
1742
  returnurl: options,
1743
1743
  })
1744
1744
  } else if (isObject(options)) {
1745
1745
  const { loginColor, ...otherOptions } = options
1746
1746
  params = Object.assign({}, defaultParams, otherOptions)
1747
1747
  } else {
1748
1748
  params = defaultParams
1749
1749
  }
1750
1750
  params.returnurl = encodeURIComponent(params.returnurl)
1751
1751
  let getFullUrl = loginUrl + '?' + serialize(params)
1752
1752
  if (isPc) {
1753
1753
  getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl')
1754
1754
  }
1755
1755
  return Promise.resolve({
1756
1756
  h5ToUrl: true,
1757
1757
  url: getFullUrl,
1758
1758
  }).then(() => {
1759
1759
  window.location.href = getFullUrl
1760
1760
  })
1761
1761
  }
1762
1762
 
1763
1763
  toWxAppLogin(options = {}) {
1764
1764
  console.log('微信京购小程序中h5登录跳转', options)
1765
1765
  return Promise.resolve(true).then(() => {
1766
1766
  const { loginColor } = Object.assign(
1767
1767
  {},
1768
1768
  {
1769
1769
  loginColor: {
1770
1770
  biz: WXAPP_BIZ_KEY,
1771
1771
  dpin: 1,
1772
1772
  },
1773
1773
  },
1774
1774
  options,
1775
1775
  )
1776
1776
  window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
1777
1777
  loginColor.biz
1778
1778
  }&url=${encodeURIComponent(window.location.href)}`
1779
1779
  })
1780
1780
  }
1781
1781
 
1782
1782
  getLoginCookie() {
1783
1783
  return Promise.resolve({
1784
1784
  pin: cookie.get('pin') || '',
1785
1785
  })
1786
1786
  }
1787
1787
 
1788
1788
  clearLoginCookie() {
1789
1789
  cookie.remove('pin')
1790
1790
  }
1791
1791
 
1792
1792
  checkStatusAndLogin(options = {}) {
1793
1793
  if (!this.checkStatusAndLoginPromise) {
1794
1794
  this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
1795
1795
  try {
1796
1796
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(
1797
1797
  options,
1798
1798
  )
1799
1799
  if (getLoginState) {
1800
1800
  resolve(true)
1801
1801
  } else {
1802
1802
  this.toLogin(options)
1803
1803
  reject(false)
1804
1804
  }
1805
1805
  } catch (e) {
1806
1806
  this.toLogin(options)
1807
1807
  reject(false)
1808
1808
  }
1809
1809
  })
1810
1810
  return this.checkStatusAndLoginPromise
1811
1811
  } else {
1812
1812
  return this.checkStatusAndLoginPromise
1813
1813
  .then(() => {
1814
1814
  return Promise.resolve(true)
1815
1815
  })
1816
1816
  .catch(() => {
1817
1817
  this.toLogin(options)
1818
1818
  return Promise.reject(true)
1819
1819
  })
1820
1820
  }
1821
1821
  }
1822
1822
 
1823
1823
  checkJdStatusAndLogin(
1824
1824
  options = {
1825
1825
  loginColor: {
1826
1826
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
1827
1827
  dpin: 0,
1828
1828
  },
1829
1829
  },
1830
1830
  ) {
1831
1831
  return this.checkStatusAndLogin(options)
1832
1832
  }
1833
1833
 
1834
1834
  doCheckLoginStateAndForApiCheck(options) {
1835
1835
  if (this.info.loginState) {
1836
1836
  return Promise.resolve(true)
1837
1837
  } else {
1838
1838
  return new Promise((resolve, reject) => {
1839
1839
  if (
1840
1840
  this.info.isJingGouMiniViewState ||
1841
1841
  this.info.isJingxiMiniViewState
1842
1842
  ) {
1843
1843
  const getWqAuthToken = cookie.get('wq_auth_token')
1844
1844
  const getWqSkey = cookie.get('wq_skey')
1845
1845
  const getWqUin = cookie.get('wq_uin')
1846
1846
  const isLoginState =
1847
1847
  options?.loginColor?.dpin === 0
1848
1848
  ? getWqAuthToken
1849
1849
  : getWqSkey && getWqUin
1850
1850
  if (isLoginState) {
1851
1851
  this.info.loginState = true
1852
1852
  resolve(true)
1853
1853
  } else {
1854
1854
  reject(false)
1855
1855
  }
1856
1856
  } else {
1857
1857
  Taro.request({
1858
1858
  url: api.isLogin,
1859
1859
  jsonp: true,
1860
1860
  timeout: 3000,
1861
1861
  success: res => {
1862
1862
  const { statusCode, data } = res
1863
1863
  if (
1864
1864
  statusCode === 200 &&
1865
1865
  data?.islogin &&
1866
1866
  Number(data.islogin) === 1
1867
1867
  ) {
1868
1868
  this.info.loginState = true
1869
1869
  resolve(true)
1870
1870
  } else {
1871
1871
  reject(false)
1872
1872
  }
1873
1873
  },
1874
1874
  fail: err => {
1875
1875
  console.log('登录检查异常', err)
1876
1876
  reject(false)
1877
1877
  },
1878
1878
  })
1879
1879
  }
1880
1880
  })
1881
1881
  }
1882
1882
  }
1883
1883
 
1884
1884
  checkLoginStatus(options) {
1885
1885
  return new Promise(async (resolve, reject) => {
1886
1886
  try {
1887
1887
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(
1888
1888
  options,
1889
1889
  )
1890
1890
  if (getLoginState) {
1891
1891
  const { pin } = await this.getLoginCookie()
1892
1892
  this.info.userInfo = {
1893
1893
  pin,
1894
1894
  encodePin: encodeURIComponent(pin),
1895
1895
  ptkey: '',
1896
1896
  }
1897
1897
  resolve(true)
1898
1898
  } else {
1899
1899
  reject(false)
1900
1900
  }
1901
1901
  } catch (e) {
1902
1902
  reject(false)
1903
1903
  }
1904
1904
  })
1905
1905
  }
1906
1906
 
1907
1907
  updatePageAndLogInfo(updateQuery = {}) {
1908
1908
  const createUpdateQueryInfo: {
1909
1909
  query: {
1910
1910
  shopId?: string | number
1911
1911
  venderId?: string | number
1912
1912
  }
1913
1913
  updateShopInfoState: boolean
1914
1914
  } = Object.assign(
1915
1915
  {},
1916
1916
  {
1917
1917
  query: {},
1918
1918
  updateShopInfoState: false,
1919
1919
  },
1920
1920
  updateQuery,
1921
1921
  )
1922
1922
  console.log(
1923
1923
  '获取当前下发的店铺查询参数',
1924
1924
  updateQuery,
1925
1925
  '获取之前保存的shopInfo店铺查询参数',
1926
1926
  this.info?.shopInfo,
1927
1927
  )
1928
1928
  const { query, updateShopInfoState } = createUpdateQueryInfo
1929
1929
  const { shopId, venderId, un_area } = query
1930
1930
  if (updateShopInfoState) {
1931
1931
  this.info.queryInfo = {
1932
1932
  ...this.info.queryInfo,
1933
1933
  ...query,
1934
1934
  }
1935
1935
  if (shopId && venderId) {
1936
1936
  this.info.shopInfo = {
1937
1937
  shopId: `${shopId}`,
1938
1938
  venderId: `${venderId}`,
1939
1939
  }
1940
1940
  }
1941
1941
  } else {
1942
1942
  this.info.queryInfo = {
1943
1943
  ...query,
1944
1944
  }
1945
1945
  if (
1946
1946
  this.info.shopInfo?.shopId &&
1947
1947
  this.info.shopInfo?.venderId &&
1948
1948
  (this.info.shopInfo.shopId == shopId ||
1949
1949
  this.info.shopInfo.venderId == venderId)
1950
1950
  ) {
1951
1951
  this.info.queryInfo.shopId = this.info.shopInfo.shopId
1952
1952
  this.info.queryInfo.venderId = this.info.shopInfo.venderId
1953
1953
  console.log(
1954
1954
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
1955
1955
  this.info.queryInfo,
1956
1956
  )
1957
1957
  }
1958
1958
  }
1959
1959
  this.info.queryInfo['shopId'] &&
1960
1960
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
1961
1961
  this.info.queryInfo['venderId'] &&
1962
1962
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
1963
1963
  console.log(
1964
1964
  'h5==获取店铺下发查询参数\n',
1965
1965
  query,
1966
1966
  '\n获取店铺最后查询参数\n',
1967
1967
  this.info.queryInfo,
1968
1968
  '\n是否为更新店铺状态\n',
1969
1969
  updateShopInfoState,
1970
1970
  )
1971
1971
  const changeArea =
1972
1972
  un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : ''
1973
1973
  if (changeArea) {
1974
1974
  this.info.pageInfo.address = changeArea
1975
1975
  this.info.pageInfo.un_area = changeArea
1976
1976
  this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
1977
1977
  }
1978
1978
  }
1979
1979
 
1980
1980
  dealLoadSdkList(){
1981
1981
  const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
1982
1982
  const businessLoadJsList = window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? []
1983
1983
  const concatLoadJsList = [].concat(globalLoadJsList,businessLoadJsList)
1984
1984
  let mergeLoadJsList = globalLoadJsList
1985
1985
  try {
1986
1986
  mergeLoadJsList = concatLoadJsList.reduce((accArr: any[], current: any) => {
1987
1987
  const getFindIndex = accArr.findIndex(item => item?.fileName === current?.fileName);
1988
1988
  getFindIndex !== -1 ? (accArr[getFindIndex] = {...accArr[getFindIndex],...current }) : accArr.push(current);
1989
1989
  return accArr;
1990
1990
  }, []);
1991
1991
  }catch (e) {
1992
1992
  console.log("LoadJsList合并错误", e)
1993
1993
  }
1994
1994
  console.log("globalLoadJsList",globalLoadJsList,"businessLoadJsList",businessLoadJsList,"两个加载jsList集合合并完成", mergeLoadJsList)
1995
1995
  this.loadJsSdkList = mergeLoadJsList
1996
1996
  return this.loadJsSdkList
1997
1997
  }
1998
1998
 
1999
1999
  renderNextTickLoadSdk(){
2000
2000
  Taro.nextTick(() => {
2001
2001
  console.log("页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s=======")
2002
2002
  setTimeout(() => {
2003
2003
  this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK,this.loadJsSdkList)
2004
2004
  },1000)
2005
2005
  })
2006
2006
  }
2007
2007
 
2008
2008
  loadOtherSdk(triggerType = LoadJsInitTriggerType.NOW,loadJsList:any[] = [] ) {
2009
2009
  const getLoadJsList = Array.isArray(loadJsList) && loadJsList.length > 0 ? loadJsList : this.dealLoadSdkList()
2010
2010
  const getLoadFilterList = getLoadJsList.filter(item => {
2011
2011
  const getInitLoadEnvType = item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL
2012
2012
  let getLoastLoadEventState = true
2013
2013
  if(getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP){
2014
2014
  getLoastLoadEventState = isJdApp
2015
2015
  }
2016
2016
  else if(getInitLoadEnvType === LoadJsInitLoadEnvType.M){
2017
2017
  getLoastLoadEventState = !isJdApp
2018
2018
  }
2019
2019
  const getInitTriggerType = isJdApp && item?.initJdAppTriggerType ? item?.initTriggerType : item?.initTriggerType || LoadJsInitTriggerType.NOW
2020
2020
  const getInitLinkTriggerWay = window?.PAGE_DATA[item?.initLinkTriggerWay] || false
2021
2021
  return getLoastLoadEventState && getInitTriggerType === triggerType && getInitLinkTriggerWay
2022
2022
  })
2023
2023
  console.log("获取当前触发方式",triggerType,"获取当前最后加载的js集合",getLoadFilterList,"过滤前的加载集合",getLoadJsList)
2024
2024
  getLoadFilterList.length > 0 && getLoadFilterList.forEach((item) => {
2025
2025
  const isLoadState = /sgm/.test(item?.fileName) ? window?.shopGlobalSwitch?.openSgm === "true" : true
2026
2026
  isLoadState && this.loadItemSdkPromise(item)
2027
2027
  .then((res) => {
2028
2028
  console.info('当前js地址' + item?.src, '加载状态', res)
2029
2029
  const isFileNameNewDraSdkJs = res?.fileName === 'newDraSdkJs'
2030
2030
  if (isFileNameNewDraSdkJs && window?.dra?.run) {
2031
2031
  window.dra.run('init', { aid: res?.aid })
2032
2032
  window.dra.run('start')
2033
2033
  }
2034
2034
  })
2035
2035
  .catch((err) => {
2036
2036
  console.info('当前js地址加载异常', item?.src)
2037
2037
  window?.fetchErrorData &&
2038
2038
  window.fetchErrorData({
2039
2039
  title: '公共js加载异常',
2040
2040
  type: "jsLoad",
2041
2041
  data: err,
2042
2042
  })
2043
2043
  })
2044
2044
  })
2045
2045
  }
2046
2046
  loadScriptEle(jsInfo,resolve,reject){
2047
2047
  const getFileName = jsInfo?.fileName;
2048
2048
  if(getFileName){
2049
2049
  const getEleId = `J_loadJs_${getFileName}`
2050
2050
  const getEle = document.getElementById(getEleId)
2051
2051
  if (!getEle) {
2052
2052
  const jsLoadErrorSgmCode = `jsLoadError_${
2053
2053
  jsInfo?.fileName || 'customJs'
2054
2054
  }`
2055
2055
  const _sgmEle = document.createElement('script')
2056
2056
  _sgmEle.id = getEleId
2057
2057
  _sgmEle.onload = function () {
2058
2058
  resolve({
2059
2059
  ...jsInfo,
2060
2060
  jsTip: "js加载成功",
2061
2061
  })
2062
2062
  }
2063
2063
  _sgmEle.onerror = function () {
2064
2064
  reject({
2065
2065
  ...jsInfo,
2066
2066
  env: getSgmCustomCode(jsLoadErrorSgmCode),
2067
2067
  jsReqError: '当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误',
2068
2068
  })
2069
2069
  }
2070
2070
  const dataAttrList = ['timeout','fileName',"env"]
2071
2071
  const getJsInfoKeyList = Object.keys(jsInfo)
2072
2072
  getJsInfoKeyList.forEach(key => {
2073
2073
  if(key === "async"){
2074
2074
  _sgmEle.async = jsInfo[key]
2075
2075
  }else if(key === "crossOrigin"){
2076
2076
  _sgmEle.crossOrigin = jsInfo[key]
2077
2077
  }else if(key === "src"){
2078
2078
  _sgmEle.src = `${jsInfo[key]}`
2079
2079
  }else if(dataAttrList.includes(key) || /init/.test(key)) {
2080
2080
  _sgmEle.setAttribute(`data-${key}`, jsInfo[key])
2081
2081
  }else {
2082
2082
  _sgmEle.setAttribute(key, jsInfo[key])
2083
2083
  }
2084
2084
  })
2085
2085
  document.head.appendChild(_sgmEle)
2086
2086
  }else {
2087
2087
  console.log(`当前${jsInfo?.fileName || "js"}已经存在页面中,可以直接调用相关方法`,jsInfo)
2088
2088
  resolve({
2089
2089
  ...jsInfo,
2090
2090
  jsTip: "js本身已存在页面中",
2091
2091
  })
2092
2092
  }
2093
2093
  }else {
2094
2094
  console.warn("当前js资源信息缺少必要的参数fileName,请关注",jsInfo)
2095
2095
  }
2096
2096
  }
2097
2097
 
2098
2098
  loadItemSdkPromise(jsInfo = {}){
2099
2099
  if(jsInfo?.src){
2100
2100
  const getInitLoadType = isJdApp && jsInfo?.initJdAppLoadType ? jsInfo?.initJdAppLoadType : jsInfo?.initLoadType || LoadJsInitLoadType.ALL
2101
2101
  if(getInitLoadType !== LoadJsInitLoadType.NONE){
2102
2102
  const getFileKeyName = jsInfo?.fileName || jsInfo?.src
2103
2103
  if (!this.loadJsSdkListCachePromise[getFileKeyName]){
2104
2104
  if(getInitLoadType !== LoadJsInitLoadType.INSERT_ELE){
2105
2105
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
2106
2106
  const jsLoadErrorSgmCode = `jsLoadError_${
2107
2107
  jsInfo?.fileName || 'customJs'
2108
2108
  }`
2109
2109
  try {
2110
2110
  const jsXhrRequest = new XMLHttpRequest();
2111
2111
  jsXhrRequest.timeout = jsInfo?.timeout ?? 2000
2112
2112
  const jsUrl = `${jsInfo?.src}`
2113
2113
  jsXhrRequest.open('GET', jsUrl, true);
2114
2114
  jsXhrRequest.onreadystatechange = () => {
2115
2115
  if (jsXhrRequest.readyState === 4){
2116
2116
  const getReqStatus = jsXhrRequest.status
2117
2117
  if (getReqStatus >= 200 && getReqStatus < 300 || getReqStatus === 304){
2118
2118
  const getInsetHeadState = getInitLoadType === LoadJsInitLoadType.ALL
2119
2119
  if(getInsetHeadState){
2120
2120
  this.loadScriptEle(jsInfo,resolve,reject)
2121
2121
  }else {
2122
2122
  resolve({
2123
2123
  ...jsInfo,
2124
2124
  jsTip: "js请求成功,暂未插入head节点,业务自行单独插入",
2125
2125
  })
2126
2126
  }
2127
2127
  getReqStatus !== 200 && sgmCustomReport({
2128
2128
  type: 3,
2129
2129
  code: "js_load_special_code",
2130
2130
  msg: {
2131
2131
  msg: "当前js加载成功,状态非200,特殊上报观察",
2132
2132
  jsReqState: getReqStatus,
2133
2133
  env: getSgmCustomCode("js_load_special_code"),
2134
2134
  data: jsInfo
2135
2135
  }
2136
2136
  })
2137
2137
  }else {
2138
2138
  const getRes = {
2139
2139
  ...jsInfo,
2140
2140
  env: getSgmCustomCode(jsLoadErrorSgmCode),
2141
2141
  jsReqError: `请求状态异常,状态码为${getReqStatus}`,
2142
2142
  jsReqState: getReqStatus,
2143
2143
  }
2144
2144
  console.log("当前js请求状态异常,具体信息见", getRes)
2145
2145
  reject(getRes)
2146
2146
  }
2147
2147
  }
2148
2148
  };
2149
2149
  jsXhrRequest.onerror = () => {
2150
2150
  const getRes = {
2151
2151
  ...jsInfo,
2152
2152
  env: getSgmCustomCode(jsLoadErrorSgmCode),
2153
2153
  jsReqError: '请求错误',
2154
2154
  }
2155
2155
  console.log("当前js请求错误", getRes)
2156
2156
  jsXhrRequest.abort()
2157
2157
  reject(getRes)
2158
2158
  }
2159
2159
  jsXhrRequest.ontimeout = () => {
2160
2160
  const getRes = {
2161
2161
  ...jsInfo,
2162
2162
  env: getSgmCustomCode(jsLoadErrorSgmCode),
2163
2163
  jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
2164
2164
  jsReqState: jsXhrRequest.status,
2165
2165
  }
2166
2166
  console.log("当前js请求超时异常", getRes)
2167
2167
  jsXhrRequest.abort()
2168
2168
  reject(getRes)
2169
2169
  }
2170
2170
  jsXhrRequest.send();
2171
2171
  }catch (e) {
2172
2172
  console.log("执行js请求异常",e)
2173
2173
  reject({
2174
2174
  ...jsInfo,
2175
2175
  env: getSgmCustomCode(jsLoadErrorSgmCode),
2176
2176
  jsReqError: '未知异常',
2177
2177
  error: e,
2178
2178
  })
2179
2179
  }
2180
2180
  })
2181
2181
  }else {
2182
2182
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
2183
2183
  return this.loadScriptEle(jsInfo,resolve,reject)
2184
2184
  })
2185
2185
  }
2186
2186
  }
2187
2187
  return this.loadJsSdkListCachePromise[getFileKeyName]
2188
2188
  }else {
2189
2189
  return Promise.resolve({
2190
2190
  ...jsInfo,
2191
2191
  jsTip: "js加载方式设置为不加载,当前不做处理",
2192
2192
  })
2193
2193
  }
2194
2194
  }else {
2195
2195
  return Promise.reject(jsInfo)
2196
2196
  }
2197
2197
  }