@conecli/cone-render 0.8.20-shop.137 → 0.8.20-shop.139

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