@conecli/cone-render 0.10.1-isv2.2 → 0.10.1-isv3.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 (123) hide show
  1. package/README.md +1 -1
  2. package/dist/api/index.ts +1 -1
  3. package/dist/common/accessibility.h5.ts +1 -0
  4. package/dist/common/accessibility.ts +1 -0
  5. package/dist/common/const.ts +1 -1
  6. package/dist/common/index.h5.ts +1 -1
  7. package/dist/common/index.jd.ts +1 -1
  8. package/dist/common/index.ts +1 -1
  9. package/dist/common/index.weapp.ts +1 -1
  10. package/dist/common/jdplayerSdk.weapp.tsx +1 -0
  11. package/dist/common/jssdk.ts +1 -1
  12. package/dist/common/jssdk.weapp.ts +1 -0
  13. package/dist/common/pageType.ts +1 -1
  14. package/dist/common/token/index.h5.ts +1 -1
  15. package/dist/common/token/token.jd.ts +1 -1
  16. package/dist/common/wxappApi.ascf.ts +1 -0
  17. package/dist/common/wxappApi.ts +1 -1
  18. package/dist/components/ErrorBoundary.tsx +1 -1
  19. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  20. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  21. package/dist/components/base/CountDown/index.tsx +1 -1
  22. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  23. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  24. package/dist/components/base/CustomVideo/index.tsx +1 -1
  25. package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
  26. package/dist/components/base/Dialog/index.module.scss +11 -0
  27. package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
  28. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  29. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  30. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  31. package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
  32. package/dist/components/base/InViewRender/index.tsx +1 -1
  33. package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
  34. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  35. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  36. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  37. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  38. package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
  39. package/dist/components/base/NetworkDataError/const.ts +1 -1
  40. package/dist/components/base/NetworkDataError/index.module.scss +118 -72
  41. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  42. package/dist/components/base/Price/Base/index.module.scss +12 -0
  43. package/dist/components/base/Price/Base/index.tsx +1 -1
  44. package/dist/components/base/Price/Double/index.module.scss +25 -1
  45. package/dist/components/base/Price/Double/index.tsx +1 -1
  46. package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
  47. package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
  48. package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
  49. package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
  50. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  51. package/dist/components/floorItem.tsx +1 -1
  52. package/dist/components/floorItem.weapp.tsx +1 -1
  53. package/dist/components/isv/Floor/index.tsx +1 -1
  54. package/dist/components/remoteFloorItem.tsx +1 -1
  55. package/dist/config/env.ts +1 -1
  56. package/dist/interface/common.ts +1 -1
  57. package/dist/interface/component.ts +1 -1
  58. package/dist/interface/jumpEventReport.ts +1 -1
  59. package/dist/interface/service.ts +1 -1
  60. package/dist/jumpEventReport/base.ts +1 -1
  61. package/dist/jumpEventReport/const.ts +1 -1
  62. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  63. package/dist/jumpEventReport/index.h5.ts +1 -1
  64. package/dist/jumpEventReport/index.jd.ts +1 -1
  65. package/dist/jumpEventReport/index.weapp.ts +1 -1
  66. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  67. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  68. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
  69. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  70. package/dist/jumpEventReport/web/report.ts +1 -1
  71. package/dist/jumpEventReport/web.base.ts +1 -1
  72. package/dist/jumpEventReport/web.jd.ts +1 -1
  73. package/dist/jumpEventReport/web.pc.ts +1 -1
  74. package/dist/jumpEventReport/web.tjm.ts +1 -1
  75. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  76. package/dist/language/en_US.json +395 -0
  77. package/dist/language/zh_CN.json +395 -0
  78. package/dist/language/zh_HK.json +395 -0
  79. package/dist/libs/openShopBridge.js +161 -0
  80. package/dist/libs/openShopBridge.min.js +1 -0
  81. package/dist/libs/taroAppReport.js +2 -2
  82. package/dist/modules/ContainerFloorList/index.h5.module.scss +80 -53
  83. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  84. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  85. package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
  86. package/dist/open/api/environment.ts +1 -1
  87. package/dist/open/api/shopMember.ts +1 -1
  88. package/dist/open/api/shopMember.weapp.ts +1 -0
  89. package/dist/open/api/track.ts +1 -1
  90. package/dist/open/api/util.ts +1 -1
  91. package/dist/open/components/index.ts +1 -1
  92. package/dist/open/index.ts +1 -1
  93. package/dist/sass/app.h5.scss +278 -224
  94. package/dist/sass/base.scss +8 -4
  95. package/dist/service/fetchGateway.ts +1 -1
  96. package/dist/service/fetchGateway.weapp.ts +1 -0
  97. package/dist/service/fetchJsonp.weapp.ts +1 -0
  98. package/dist/service/http/colorSign.ts +1 -1
  99. package/dist/service/http/const.ts +1 -1
  100. package/dist/service/http/h5Http.ts +1 -1
  101. package/dist/service/http/httpInterceptors.weapp.ts +1 -0
  102. package/dist/service/requestServer.h5.ts +1 -1
  103. package/dist/service/requestServer.ts +1 -1
  104. package/dist/service/requestServer.weapp.ts +1 -0
  105. package/dist/utils/connectNativeJsBridge.ts +1 -1
  106. package/dist/utils/h5Utils.ts +1 -1
  107. package/dist/utils/harmonyCallRouter.h5.ts +1 -0
  108. package/dist/utils/harmonyCallRouter.ts +0 -0
  109. package/dist/utils/index.h5.ts +1 -1
  110. package/dist/utils/index.ts +1 -1
  111. package/dist/utils/index.weapp.ts +1 -1
  112. package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
  113. package/dist/utils/jumpExtMapUtil.ts +1 -0
  114. package/dist/utils/jumpExtMapUtil.weapp.ts +1 -0
  115. package/dist/utils/log.ts +1 -0
  116. package/dist/utils/sColor.ts +1 -0
  117. package/dist/utils/sColor.weapp.ts +1 -0
  118. package/dist/utils/utils.ts +1 -1
  119. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  120. package/dist/wxapp/common/user_info.js +1 -1
  121. package/package.json +164 -141
  122. package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
  123. package/dist/utils/priceUtils.js +0 -1
@@ -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
  TaroEventType,
26
25
  loginState: false,
27
26
  cookiesStr: '',
28
27
  userInfo: userPinKey,
29
28
  isJingGouMiniViewState: false,
30
29
  isJingxiMiniViewState: false,
31
30
  pageInfo: {
32
31
  wxBusinessType: WX_BUSINESS_TYPE.NO,
33
32
  address: '',
34
33
  addressCommaStr: '',
35
34
  un_area: '',
36
35
  vapptype: '1',
37
36
  pageType: 'home',
38
37
  isExposureState: false,
39
38
  moduleId: '',
40
39
  entrance: '',
41
40
  dataType: BUSINESS_TYPE.ONLINE,
42
41
  floorExposureInfo: {},
43
42
  floorVideInfo: {},
44
43
  productVideInfo: {},
45
44
  tabsLoadAllDataInfo: {
46
45
  [SECTION_HOME_TAB_NAME_TYPE[
47
46
  SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
48
47
  ]]: false,
49
48
  },
50
49
  updateShopInfosAllState: false,
51
50
  isVipShop: false,
52
51
  isJdShowNativeImmersivePlayer: false,
53
52
  ...shopConfig,
54
53
  pageScrollTop: 0,
55
54
  pageIdxHeightInfo: {
56
55
  list: [],
57
56
  },
58
57
  shopNavBarHeight: 0,
59
58
  },
60
59
  defaultQueryLogInfo: {
61
60
  sourceType: 'JDshop',
62
61
  sourceValue: '',
63
62
  moduleId: 'none',
64
63
  entrance: 'none',
65
64
  },
66
65
  sysInfo: {
67
66
  windowWidth: isPc ? 375 : 0,
68
67
  containerWidth: isPc ? 375 : 0,
69
68
  windowHeight: 0,
70
69
  netWorkType: '4g',
71
70
  jdBottomBarHeight: 0,
72
71
  jdNativeHeaderHeight: 0,
73
72
  },
74
73
  queryInfo: {},
75
74
  shopInfo: {},
76
75
  openAppData: {},
77
76
  public info: CommonInterFace.BaseConfigInfo
78
77
  public config: {
79
78
  [key: string]: any
80
79
  }
81
80
  public lazyContainer: CommonInterFace.lazyContainer
82
81
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents
83
82
  public rootEleNode: HTMLElement | null
84
83
  public checkStatusAndLoginPromise: object | null
85
84
  private jmfeRegisterStatePromise: Promise<any> | null
86
85
  private jmfeRegisterState: boolean
87
86
  public loadJsSdkList: Array<any>
88
87
  public loadJsSdkListCachePromise: any
89
88
  constructor(opt) {
90
89
  this.info = this._getConfig(opt)
91
90
  this.config = {}
92
91
  this.loadJsSdkList = []
93
92
  this.loadJsSdkListCachePromise = {}
94
93
  this.lazyContainer = {
95
94
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
96
95
  appLazyContainerList: [],
97
96
  appLazyFinishContainerList: [],
98
97
  },
99
98
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
100
99
  appLazyContainerList: [],
101
100
  appLazyFinishContainerList: [],
102
101
  },
103
102
  }
104
103
  this.renderedIsvComponents = {}
105
104
  this.rootEleNode = document.querySelector('body')
106
105
  this.checkStatusAndLoginPromise = null
107
106
  this.jmfeRegisterStatePromise = null
108
107
  this.loadOtherSdk()
109
108
  isJdApp && this.jmfeReayPromise()
110
109
  }
111
110
  _getConfig(opt) {
112
111
  return Object.assign({}, DefaultConfig, opt)
113
112
  }
114
113
 
115
114
  jmfeReayPromise(): Promise<any> {
116
115
  if (isJdApp) {
117
116
  if (this.jmfeRegisterState) {
118
117
  return Promise.resolve(true)
119
118
  } else {
120
119
  !this.jmfeRegisterStatePromise &&
121
120
  (this.jmfeRegisterStatePromise = new Promise((resolve, reject) => {
122
121
  ready('jmfe', 3000)
123
122
  .then(() => {
124
123
  window?.jmfe && window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE)
125
124
  this.jmfeRegisterState = true
126
125
  resolve(true)
127
126
  console.log('松果app内初始化注册jmfe认证完成')
128
127
  })
129
128
  .catch((err) => {
130
129
  console.error('jmfe ready error', err)
131
130
  reject(false)
132
131
  })
133
132
  }))
134
133
  return this.jmfeRegisterStatePromise
135
134
  }
136
135
  } else {
137
136
  return Promise.reject(false)
138
137
  }
139
138
  }
140
139
 
141
140
  updateBusinessDomainAndApi(domain, api) {
142
141
  }
143
142
 
144
143
  formatNativeScreenPageData(action) {
145
144
  let getChangePageInfo: any = null
146
145
  try {
147
146
  const getNativeScreenPageInfoStr = window.XWebView?._callNative(
148
147
  JSON.stringify({
149
148
  plugin: 'JDHybridScreenPlugin',
150
149
  action,
151
150
  sync: '1',
152
151
  }),
153
152
  )
154
153
  const getChangePageInfoData =
155
154
  typeof getNativeScreenPageInfoStr === 'string'
156
155
  ? JSON.parse(getNativeScreenPageInfoStr)
157
156
  : null
158
157
  if (getChangePageInfoData && typeof getChangePageInfoData === 'object') {
159
158
  const { code, data } = getChangePageInfoData
160
159
  getChangePageInfo = code && code === '0' ? data : null
161
160
  }
162
161
  } catch (e) {
163
162
  console.log('JDHybridScreenPlugin转换异常', e)
164
163
  }
165
164
  return getChangePageInfo
166
165
  }
167
166
 
168
167
  isAndroidFoldScreen() {
169
168
  return this.formatNativeScreenPageData('isFoldScreen') === '1'
170
169
  }
171
170
 
172
171
  getJdAndroidPageChangeScreenInfo() {
173
172
  const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize')
174
173
  if (
175
174
  getPageScreenInfo &&
176
175
  getPageScreenInfo?.pageWidth &&
177
176
  getPageScreenInfo?.pageHeight
178
177
  ) {
179
178
  const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
180
179
  pageWidth: getPageScreenInfo.pageWidth,
181
180
  pageHeight: getPageScreenInfo.pageHeight,
182
181
  })
183
182
  getPageScreenInfo.pageWidth = pageWidth
184
183
  getPageScreenInfo.pageHeight = pageHeight
185
184
  }
186
185
  return getPageScreenInfo
187
186
  }
188
187
 
189
188
  getSystemInfo(params) {
190
189
  let info: UtilsInterFace.taroGetSystemInfoSyncRes | {} = isPc
191
190
  ? {}
192
191
  : getSystemInfos(params)
193
192
  if (isJdAndAndroidDevice && info?.initWindowWidth <= 0) {
194
193
  let _isfoldScreen = false
195
194
  const getStorageData = getTaroStorageKeyValue("jd_shopx_androidIsFoldScreen")
196
195
  console.info("获取当前本地存储是否有jd_shopx_androidIsFoldScreen", getStorageData,"通过缓存值第一次判断是否是折叠屏", getStorageData === 'true')
197
196
  if(!getStorageData){
198
197
  _isfoldScreen = this.isAndroidFoldScreen()
199
198
  setTaroStorage("jd_shopx_androidIsFoldScreen", `${_isfoldScreen}`)
200
199
  }else {
201
200
  _isfoldScreen = getStorageData === 'true'
202
201
  }
203
202
  if (_isfoldScreen) {
204
203
  const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo()
205
204
  if(getJdAndroidPageInfo){
206
205
  info = getSystemInfos(getJdAndroidPageInfo)
207
206
  console.warn("当前为松果安卓折叠屏app,获取折叠屏信息",getJdAndroidPageInfo,"获取转换后的系统信息",info)
208
207
  sgmCustomReport({
209
208
  type: 2,
210
209
  code: 'android_jdapp_foldScreen_info',
211
210
  msg: {
212
211
  title: `松果安卓app为折叠屏,重置获取的系统宽高信息,因为获取宽高度信息初始化内部可能存在横竖屏差异`,
213
212
  androidPageInfo: getJdAndroidPageInfo,
214
213
  jdAppVersionStr,
215
214
  taroSysInfo: info
216
215
  }
217
216
  })
218
217
  }
219
218
  }
220
219
  }
221
220
  this.info.sysInfo = {
222
221
  actualNavBarHeight: 0,
223
222
  ...this.info.sysInfo,
224
223
  ...info,
225
224
  safeContentHeight: info?.screenHeight,
226
225
  headerHeight: 0,
227
226
  tabBarHeight: 0,
228
227
  }
229
228
  if (isJdApp) {
230
229
  this.info.sysInfo['hostVersionName'] = jdAppVersionStr
231
230
  this.info.sysInfo['hostAppVersion'] = jdAppVersion
232
231
  this.getAddressCachePromise()
233
232
  this.getElderModePromise()
234
233
  this.getJDAppearanceStatePromise()
235
234
  this.createJdAndroidRquestEventForTouchStart()
236
235
  }
237
236
  this.getWifiVideoAutoPlayAsync()
238
237
  this.getMPaasConfigAsync()
239
238
  this.getNetWorkType()
240
239
  }
241
240
 
242
241
  taskTimeoutPromise(callBack, timeout = 2000) {
243
242
  return new Promise(resolve => {
244
243
  setTimeout(() => {
245
244
  const getCallBackRes = typeof callBack === 'function' && callBack()
246
245
  return resolve(getCallBackRes || false)
247
246
  }, timeout)
248
247
  })
249
248
  }
250
249
 
251
250
  getElderModePromise() {
252
251
  if (this.info.sysInfo.hasOwnProperty('jdAppModeType')) {
253
252
  return Promise.resolve(this.info.sysInfo.jdAppModeType)
254
253
  } else {
255
254
  if (isJdAndAndroidDevice) {
256
255
  this.info.sysInfo.jdAppModeType = '0'
257
256
  return Promise.resolve(this.info.sysInfo.jdAppModeType)
258
257
  } else {
259
258
  return Promise.race([
260
259
  this.taskTimeoutPromise(() => {
261
260
  this.info.sysInfo.jdAppModeType = '0'
262
261
  return this.info.sysInfo.jdAppModeType
263
262
  }),
264
263
  new Promise(resolve => {
265
264
  const getCallBackName = `getJdCurrentModeType${Date.now()}`
266
265
  if (!window[getCallBackName]) {
267
266
  window[getCallBackName] = res => {
268
267
  try {
269
268
  const getResJson =
270
269
  typeof res === 'string' ? JSON.parse(res) : res
271
270
  const { status, data, msg } = getResJson
272
271
  console.log(`获取松果app展示模式成功,返回结果${data}`)
273
272
  if (status === '0') {
274
273
  this.info.sysInfo.jdAppModeType = data
275
274
  resolve(data)
276
275
  } else {
277
276
  resolve('0')
278
277
  }
279
278
  } catch (e) {
280
279
  resolve('0')
281
280
  }
282
281
  window[getCallBackName] = null
283
282
  }
284
283
  }
285
284
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
286
285
  method: 'callSyncRouterModuleWithParams',
287
286
  params: JSON.stringify({
288
287
  routerURL: 'router://JDBModeModule/getCurrentMode',
289
288
  routerParam: {},
290
289
  callBackName: `window.${getCallBackName}`,
291
290
  callBackId: `${getCallBackName}Ios`,
292
291
  }),
293
292
  })
294
293
  }),
295
294
  ])
296
295
  }
297
296
  }
298
297
  }
299
298
  getAPPUseStraightCorner() {
300
299
  const routerURL = 'router://JDBaseUtilsModule/isUI14Enable'
301
300
  const params = {
302
301
  routerURL,
303
302
  routerParam: {},
304
303
  jdRouter: '1',
305
304
  }
306
305
  if (this.info.sysInfo.hasOwnProperty('jdStraightCorner')) {
307
306
  return Promise.resolve(this.info.sysInfo.jdStraightCorner)
308
307
  } else {
309
308
  return this.jmfeReayPromise()
310
309
  .then(() => {
311
310
  if(isJdAndHarmonyDevice || !isJdApp) {
312
311
  console.log('not APP or is Harmony')
313
312
  return Promise.resolve(false)
314
313
  }
315
314
  console.log('jmfe setShareInfo', params)
316
315
  return Promise.race([window.jmfe.callRouter(params), this.taskTimeoutPromise(() => {return false})])
317
316
  .then(({ status, data }) => {
318
317
  console.log('004 ~ file: index.tsx:133 ~ .then ~ data:', data)
319
318
  console.log('004 ~ file: index.tsx:133 ~ .then ~ status:', status)
320
319
  this.info.sysInfo.jdStraightCorner = status === '0' && Number(data) === 1
321
320
  return Promise.resolve( status === '0' && Number(data) === 1)
322
321
  })
323
322
  })
324
323
  .catch(e => {
325
324
  console.log('jmfe error', e)
326
325
  return Promise.resolve(false)
327
326
  })
328
327
  }
329
328
  }
330
329
 
331
330
  getJDAppearanceStatePromise() {
332
331
  if (this.info.sysInfo.hasOwnProperty('jdAppearanceState')) {
333
332
  return Promise.resolve(this.info.sysInfo.jdAppearanceState)
334
333
  } else {
335
334
  return Promise.race([
336
335
  this.taskTimeoutPromise(() => {
337
336
  this.info.sysInfo.jdAppearanceState = '0'
338
337
  return this.info.sysInfo.jdAppearanceState
339
338
  }),
340
339
  new Promise(resolve => {
341
340
  const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`
342
341
  if (!window[getCallBackName]) {
343
342
  window[getCallBackName] = res => {
344
343
  try {
345
344
  console.log('getJDAppearanceStatePromise', res)
346
345
  const getResJson =
347
346
  typeof res === 'string' ? JSON.parse(res) : res
348
347
  const { status, data, msg } = getResJson
349
348
  console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`)
350
349
  if (status === '0') {
351
350
  this.info.sysInfo.jdAppearanceState = data
352
351
  resolve(data)
353
352
  } else {
354
353
  resolve('0')
355
354
  }
356
355
  } catch (e) {
357
356
  resolve('0')
358
357
  }
359
358
  window[getCallBackName] = null
360
359
  }
361
360
  }
362
361
  if (isAndroidDevice) {
363
362
  const jsonString = JSON.stringify({
364
363
  callBackName: `window.${getCallBackName}`,
365
364
  })
366
365
  console.log('window.JDAppearance', window.JDAppearance)
367
366
  window.JDAppearance && window.JDAppearance.getUiState(jsonString)
368
367
  } else {
369
368
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
370
369
  method: 'callSyncRouterModuleWithParams',
371
370
  params: JSON.stringify({
372
371
  routerURL:
373
372
  'router://JDWebViewBusinessModule/getJDAppearanceState',
374
373
  routerParam: {},
375
374
  callBackName: `window.${getCallBackName}`,
376
375
  callBackId: `${getCallBackName}Ios`,
377
376
  }),
378
377
  })
379
378
  }
380
379
  }),
381
380
  ])
382
381
  }
383
382
  }
384
383
 
385
384
  createJdAndroidRquestEventForTouchStart() {
386
385
  if (isJdAndAndroidDevice && window.JdAndroid) {
387
386
  const rootEleNode = document.querySelector('body')
388
387
  if (rootEleNode) {
389
388
  rootEleNode.addEventListener(
390
389
  'touchstart',
391
390
  this.jdAndroidAddEventListenerTouchStart,
392
391
  false,
393
392
  )
394
393
  }
395
394
  }
396
395
  }
397
396
  jdAndroidAddEventListenerTouchStart(e) {
398
397
  const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom')
399
398
  if (!isH5SwiperCustomEle) {
400
399
  const hasCustomEle = e
401
400
  ? e?.target?.closest('.J_customScroll') ||
402
401
  e?.target?.closest('.J_customLayout')
403
402
  : false
404
403
  if (!hasCustomEle) {
405
404
  window.JdAndroid.requestEvent(false)
406
405
  console.log(
407
406
  'createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false',
408
407
  )
409
408
  }
410
409
  }
411
410
  }
412
411
  removeJdAndroidRquestEventForTouchStart() {
413
412
  if (isJdAndAndroidDevice && window.JdAndroid) {
414
413
  const rootEleNode = document.querySelector('body')
415
414
  if (rootEleNode) {
416
415
  rootEleNode.removeEventListener(
417
416
  'touchstart',
418
417
  this.jdAndroidAddEventListenerTouchStart,
419
418
  false,
420
419
  )
421
420
  }
422
421
  }
423
422
  }
424
423
 
425
424
  getNetWorkType() {
426
425
  if (isJdApp) {
427
426
  this.jmfeReayPromise().then(() => {
428
427
  window.jmfe
429
428
  .getNetworkStatus()
430
429
  .then(({ status, data }) => {
431
430
  console.log(
432
431
  '在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====',
433
432
  data,
434
433
  )
435
434
  if (status === '0') {
436
435
  this.info.sysInfo['netWorkType'] = data
437
436
  } else {
438
437
  this._taroGetNetworkType()
439
438
  }
440
439
  })
441
440
  .catch(err => {
442
441
  console.log('在app内初始化通过jmfe对象获取网络状态异常====', err)
443
442
  this._taroGetNetworkType()
444
443
  })
445
444
  })
446
445
  } else {
447
446
  this._taroGetNetworkType()
448
447
  }
449
448
  }
450
449
  _taroGetNetworkType() {
451
450
  Taro.getNetworkType().then(getRes => {
452
451
  if (getRes && getRes.networkType) {
453
452
  this.info.sysInfo['netWorkType'] = getRes.networkType
454
453
  console.log(
455
454
  '在app内通过taro对象获取网络状态完成,当前网络状态',
456
455
  this.info.sysInfo['netWorkType'],
457
456
  )
458
457
  }
459
458
  })
460
459
  }
461
460
 
462
461
  getCacheAddressRouter() {
463
462
  if(window.jmfe && isJdApp){
464
463
  if(!isJdAndHarmonyDevice){
465
464
  return Promise.race([window.jmfe.callRouter({
466
465
  jdRouter: '1',
467
466
  routerURL: isAndroidDevice ? 'router://JDAddressModule/getCacheAddress' : 'router://JDBAddressCacheManagerModule/getCacheAddress',
468
467
  routerParam: { sceneId: 'basicShoppingProcess' },
469
468
  }), this.taskTimeoutPromise(() => {
470
469
  return {
471
470
  status: "-1000",
472
471
  msg: "原生router协议获取地址信息超时"
473
472
  }
474
473
  }, 3000)])
475
474
  }else {
476
475
  return Promise.resolve({
477
476
  status: "-1001",
478
477
  msg: "鸿蒙系统调用jmfe异常,获取失败"
479
478
  })
480
479
  }
481
480
  }else {
482
481
  return Promise.resolve({
483
482
  status: "-1002",
484
483
  msg: "jmfe不存在,获取失败"
485
484
  })
486
485
  }
487
486
  }
488
487
 
489
488
  getAddressCachePromise() {
490
489
  return new Promise(resolve => {
491
490
  if (
492
491
  this?.info?.sysInfo?.lat &&
493
492
  this?.info?.sysInfo?.lng &&
494
493
  this?.info?.sysInfo?.area
495
494
  ) {
496
495
  resolve({
497
496
  lat: this.info.sysInfo.lat,
498
497
  lng: this.info.sysInfo.lng,
499
498
  area: this?.info?.sysInfo?.area,
500
499
  })
501
500
  } else {
502
501
  this.jmfeReayPromise().then(() => {
503
502
  this.getCacheAddressRouter()
504
503
  .then((res) => {
505
504
  const { status, data } = res
506
505
  console.log("原生端获取经纬度原始数据结果",status,data)
507
506
  if (status === '0' && data) {
508
507
  const {
509
508
  lat,
510
509
  latitude,
511
510
  lng,
512
511
  longitude,
513
512
  provinceId,
514
513
  cityId,
515
514
  countyId,
516
515
  townId,
517
516
  } = data || {}
518
517
  let area = ''
519
518
  this.info.sysInfo['lat'] = `${lat || latitude || ''}`
520
519
  this.info.sysInfo['lng'] = `${lng || longitude || ''}`
521
520
  if (provinceId) {
522
521
  area = `${provinceId}_${cityId || 0}_${countyId ||
523
522
  0}_${townId || 0}`
524
523
  this.info.pageInfo['address'] = area
525
524
  this.info.pageInfo['addressCommaStr'] = area.replace(
526
525
  /_/g,
527
526
  ',',
528
527
  )
529
528
  Taro.eventCenter.trigger(
530
529
  TaroEventType.USER_AREA_UPDATE,
531
530
  this.info.pageInfo.address
532
531
  );
533
532
  }
534
533
  resolve({
535
534
  lat: this.info.sysInfo['lat'],
536
535
  lng: this.info.sysInfo['lng'],
537
536
  area: area,
538
537
  })
539
538
  } else {
540
539
  typeof res === "object" && sgmCustomReport({
541
540
  type: 3,
542
541
  code: 'jdapp_getCacheAddress_info',
543
542
  msg: {
544
543
  title: "松果app内通过router协议获取用户地址及经纬度信息异常",
545
544
  jdAppVersion: jdAppVersionStr,
546
545
  ...res
547
546
  }
548
547
  })
549
548
  resolve({ lat: '', lng: '', area: '' })
550
549
  }
551
550
  })
552
551
  .catch(e => {
553
552
  console.log(' ~~ file: index.h5.ts:518 ~~ .catch ~~ e:', e)
554
553
  resolve({ lat: '', lng: '', area: '' })
555
554
  console.log('getCacheAddressRouter catch e,获取经纬度信息异常e', e)
556
555
  })
557
556
  }).catch(e => {
558
557
  resolve({ lat: '', lng: '', area: '' })
559
558
  console.log('判断jmfe不存在,获取经纬度信息异常e', e)
560
559
  })
561
560
  }
562
561
  })
563
562
  }
564
563
 
565
564
  async updateMPaasConfigAsync(isBeforePageReady: boolean) {
566
565
  console.log("updateMPaasConfigAsync isBeforePageReady:", isBeforePageReady)
567
566
  if (!isJdApp) {
568
567
  return
569
568
  }
570
569
  const avifSwitch = await getMPaasConfigByBussinessKey(
571
570
  'avifSwitch',
572
571
  isBeforePageReady,
573
572
  )
574
573
  this.info.sysInfo.dynamicConfig['avifSwitch'] = avifSwitch
575
574
  const hybridHttpSwitch = await getMPaasConfigByBussinessKey(
576
575
  'hybridHttpSwitch',
577
576
  isBeforePageReady,
578
577
  )
579
578
  this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = hybridHttpSwitch
580
579
  const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
581
580
  'isFollowAppVideoPlayStatus',
582
581
  isBeforePageReady,
583
582
  )
584
583
  console.log(
585
584
  'isBeforePageReady:',
586
585
  isBeforePageReady,
587
586
  'isFollowAppVideoPlayStatus:',
588
587
  isFollowAppVideoPlayStatus,
589
588
  )
590
589
  if (
591
590
  isFollowAppVideoPlayStatus === true ||
592
591
  isFollowAppVideoPlayStatus === 'true'
593
592
  ) {
594
593
  this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = true
595
594
  }
596
595
  }
597
596
 
598
597
  async getWifiVideoAutoPlayAsync() {
599
598
  this.info.sysInfo['wifiVideoAutoPlay'] = false
600
599
  if (!isJdApp) {
601
600
  return
602
601
  }
603
602
  const videoPlayStatus = await getWifiVideoAutoPlay().catch(e => {
604
603
  return 0
605
604
  })
606
605
  if (Number(videoPlayStatus) === 1) {
607
606
  this.info.sysInfo['wifiVideoAutoPlay'] = true
608
607
  }
609
608
  }
610
609
 
611
610
  async getMPaasConfigAsync() {
612
611
  this.info.sysInfo.dynamicConfig = {}
613
612
  this.info.sysInfo.dynamicConfig['avifSwitch'] = {}
614
613
  this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = {}
615
614
  this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = false
616
615
  return this.updateMPaasConfigAsync(true)
617
616
  }
618
617
 
619
618
  getDynamicConfig(key: string){
620
619
  return this.info.sysInfo.dynamicConfig[key]
621
620
  }
622
621
  async updateMPaasConfig() {
623
622
  console.log('updateMPaasConfig')
624
623
  if (
625
624
  isIosDevice &&
626
625
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
627
626
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
628
627
  ) {
629
628
  try {
630
629
  await this.updateMPaasConfigAsync(false)
631
630
  } catch (e) {
632
631
  console.log('updateMPaasConfigAsync:', e)
633
632
  }
634
633
  }
635
634
  }
636
635
 
637
636
  toLogin(options) {
638
637
  return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
639
638
  ? this.toWxAppLogin(options)
640
639
  : this.toWebLogin(options)
641
640
  }
642
641
 
643
642
  doLogin(options) {
644
643
  return this.toLogin(options)
645
644
  }
646
645
 
647
646
  doLoginForJdPin(options = {}) {
648
647
  return this.doLogin({
649
648
  loginColor: {
650
649
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
651
650
  dpin: 0,
652
651
  },
653
652
  ...options,
654
653
  })
655
654
  }
656
655
 
657
656
  toWebLogin(options) {
658
657
  let params: {
659
658
  returnurl: string
660
659
  } = {
661
660
  returnurl: '',
662
661
  }
663
662
  const loginUrl = isPc
664
663
  ? `//passport.jd.com/new/login.aspx`
665
664
  : `${domain.mobileLogin}/user/login.action`
666
665
  const defaultParams = {
667
666
  appid: '100',
668
667
  returnurl: window.location.href,
669
668
  }
670
669
  if (isString(options)) {
671
670
  params = Object.assign({}, defaultParams, {
672
671
  returnurl: options,
673
672
  })
674
673
  } else if (isObject(options)) {
675
674
  const { loginColor, ...otherOptions } = options
676
675
  params = Object.assign({}, defaultParams, otherOptions)
677
676
  } else {
678
677
  params = defaultParams
679
678
  }
680
679
  params.returnurl = encodeURIComponent(params.returnurl)
681
680
  let getFullUrl = loginUrl + '?' + serialize(params)
682
681
  if (isPc) {
683
682
  getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl')
684
683
  }
685
684
  return Promise.resolve({
686
685
  h5ToUrl: true,
687
686
  url: getFullUrl,
688
687
  }).then(() => {
689
688
  window.location.href = getFullUrl
690
689
  })
691
690
  }
692
691
 
693
692
  toWxAppLogin(options = {}) {
694
693
  console.log('微信京购小程序中h5登录跳转', options)
695
694
  return Promise.resolve(true).then(() => {
696
695
  const { loginColor } = Object.assign(
697
696
  {},
698
697
  {
699
698
  loginColor: {
700
699
  biz: WXAPP_BIZ_KEY,
701
700
  dpin: 1,
702
701
  },
703
702
  },
704
703
  options,
705
704
  )
706
705
  window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
707
706
  loginColor.biz
708
707
  }&url=${encodeURIComponent(window.location.href)}`
709
708
  })
710
709
  }
711
710
 
712
711
  getLoginCookie() {
713
712
  return Promise.resolve({
714
713
  pin: cookie.get('pin') || '',
715
714
  })
716
715
  }
717
716
 
718
717
  clearLoginCookie() {
719
718
  cookie.remove('pin')
720
719
  }
721
720
 
722
721
  checkStatusAndLogin(options = {}) {
723
722
  if (!this.checkStatusAndLoginPromise) {
724
723
  this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
725
724
  try {
726
725
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(
727
726
  options,
728
727
  )
729
728
  if (getLoginState) {
730
729
  resolve(true)
731
730
  } else {
732
731
  this.toLogin(options)
733
732
  reject(false)
734
733
  }
735
734
  } catch (e) {
736
735
  this.toLogin(options)
737
736
  reject(false)
738
737
  }
739
738
  })
740
739
  return this.checkStatusAndLoginPromise
741
740
  } else {
742
741
  return this.checkStatusAndLoginPromise
743
742
  .then(() => {
744
743
  return Promise.resolve(true)
745
744
  })
746
745
  .catch(() => {
747
746
  this.toLogin(options)
748
747
  return Promise.reject(true)
749
748
  })
750
749
  }
751
750
  }
752
751
 
753
752
  checkJdStatusAndLogin(
754
753
  options = {
755
754
  loginColor: {
756
755
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
757
756
  dpin: 0,
758
757
  },
759
758
  },
760
759
  ) {
761
760
  return this.checkStatusAndLogin(options)
762
761
  }
763
762
 
764
763
  doCheckLoginStateAndForApiCheck(options) {
765
764
  if (this.info.loginState) {
766
765
  return Promise.resolve(true)
767
766
  } else {
768
767
  return new Promise((resolve, reject) => {
769
768
  if (
770
769
  this.info.isJingGouMiniViewState ||
771
770
  this.info.isJingxiMiniViewState
772
771
  ) {
773
772
  const getWqAuthToken = cookie.get('wq_auth_token')
774
773
  const getWqSkey = cookie.get('wq_skey')
775
774
  const getWqUin = cookie.get('wq_uin')
776
775
  const isLoginState =
777
776
  options?.loginColor?.dpin === 0
778
777
  ? getWqAuthToken
779
778
  : getWqSkey && getWqUin
780
779
  if (isLoginState) {
781
780
  this.info.loginState = true
782
781
  resolve(true)
783
782
  } else {
784
783
  reject(false)
785
784
  }
786
785
  } else {
787
786
  Taro.request({
788
787
  url: api.isLogin,
789
788
  jsonp: true,
790
789
  timeout: 3000,
791
790
  success: res => {
792
791
  const { statusCode, data } = res
793
792
  if (
794
793
  statusCode === 200 &&
795
794
  data?.islogin &&
796
795
  Number(data.islogin) === 1
797
796
  ) {
798
797
  this.info.loginState = true
799
798
  resolve(true)
800
799
  } else {
801
800
  reject(false)
802
801
  }
803
802
  },
804
803
  fail: err => {
805
804
  console.log('登录检查异常', err)
806
805
  reject(false)
807
806
  },
808
807
  })
809
808
  }
810
809
  })
811
810
  }
812
811
  }
813
812
 
814
813
  checkLoginStatus(options) {
815
814
  return new Promise(async (resolve, reject) => {
816
815
  try {
817
816
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(
818
817
  options,
819
818
  )
820
819
  if (getLoginState) {
821
820
  const { pin } = await this.getLoginCookie()
822
821
  this.info.userInfo = {
823
822
  pin,
824
823
  encodePin: encodeURIComponent(pin),
825
824
  ptkey: '',
826
825
  }
827
826
  resolve(true)
828
827
  } else {
829
828
  reject(false)
830
829
  }
831
830
  } catch (e) {
832
831
  reject(false)
833
832
  }
834
833
  })
835
834
  }
836
835
 
837
836
  updatePageAndLogInfo(updateQuery = {}) {
838
837
  const createUpdateQueryInfo: {
839
838
  query: {
840
839
  shopId?: string | number
841
840
  venderId?: string | number
842
841
  }
843
842
  updateShopInfoState: boolean
844
843
  } = Object.assign(
845
844
  {},
846
845
  {
847
846
  query: {},
848
847
  updateShopInfoState: false,
849
848
  },
850
849
  updateQuery,
851
850
  )
852
851
  console.log(
853
852
  '获取当前下发的店铺查询参数',
854
853
  updateQuery,
855
854
  '获取之前保存的shopInfo店铺查询参数',
856
855
  this.info?.shopInfo,
857
856
  )
858
857
  const { query, updateShopInfoState } = createUpdateQueryInfo
859
858
  const { shopId, venderId, un_area } = query
860
859
  if (updateShopInfoState) {
861
860
  this.info.queryInfo = {
862
861
  ...this.info.queryInfo,
863
862
  ...query,
864
863
  }
865
864
  if (shopId && venderId) {
866
865
  this.info.shopInfo = {
867
866
  shopId: `${shopId}`,
868
867
  venderId: `${venderId}`,
869
868
  }
870
869
  }
871
870
  } else {
872
871
  this.info.queryInfo = {
873
872
  ...query,
874
873
  }
875
874
  if (
876
875
  this.info.shopInfo?.shopId &&
877
876
  this.info.shopInfo?.venderId &&
878
877
  (this.info.shopInfo.shopId == shopId ||
879
878
  this.info.shopInfo.venderId == venderId)
880
879
  ) {
881
880
  this.info.queryInfo.shopId = this.info.shopInfo.shopId
882
881
  this.info.queryInfo.venderId = this.info.shopInfo.venderId
883
882
  console.log(
884
883
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
885
884
  this.info.queryInfo,
886
885
  )
887
886
  }
888
887
  }
889
888
  this.info.queryInfo['shopId'] &&
890
889
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
891
890
  this.info.queryInfo['venderId'] &&
892
891
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
893
892
  console.log(
894
893
  'h5==获取店铺下发查询参数\n',
895
894
  query,
896
895
  '\n获取店铺最后查询参数\n',
897
896
  this.info.queryInfo,
898
897
  '\n是否为更新店铺状态\n',
899
898
  updateShopInfoState,
900
899
  )
901
900
  const changeArea =
902
901
  un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : ''
903
902
  if (changeArea) {
904
903
  this.info.pageInfo.address = changeArea
905
904
  this.info.pageInfo.un_area = changeArea
906
905
  this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
907
906
  }
908
907
  }
909
908
 
910
909
  dealLoadSdkList(){
911
910
  const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
912
911
  const businessLoadJsList = window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? []
913
912
  const concatLoadJsList = [].concat(globalLoadJsList,businessLoadJsList)
914
913
  let mergeLoadJsList = globalLoadJsList
915
914
  try {
916
915
  mergeLoadJsList = concatLoadJsList.reduce((accArr: any[], current: any) => {
917
916
  const getFindIndex = accArr.findIndex(item => item?.fileName === current?.fileName);
918
917
  getFindIndex !== -1 ? (accArr[getFindIndex] = {...accArr[getFindIndex],...current }) : accArr.push(current);
919
918
  return accArr;
920
919
  }, []);
921
920
  }catch (e) {
922
921
  console.log("LoadJsList合并错误", e)
923
922
  }
924
923
  console.log("globalLoadJsList",globalLoadJsList,"businessLoadJsList",businessLoadJsList,"两个加载jsList集合合并完成", mergeLoadJsList)
925
924
  this.loadJsSdkList = mergeLoadJsList
926
925
  return this.loadJsSdkList
927
926
  }
928
927
 
929
928
  renderNextTickLoadSdk(){
930
929
  Taro.nextTick(() => {
931
930
  console.log("页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s=======")
932
931
  setTimeout(() => {
933
932
  this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK,this.loadJsSdkList)
934
933
  },1000)
935
934
  })
936
935
  }
937
936
 
938
937
  loadOtherSdk(triggerType = LoadJsInitTriggerType.NOW,loadJsList:any[] = [] ) {
939
938
  const getLoadJsList = Array.isArray(loadJsList) && loadJsList.length > 0 ? loadJsList : this.dealLoadSdkList()
940
939
  const getLoadFilterList = getLoadJsList.filter(item => {
941
940
  const getInitLoadEnvType = item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL
942
941
  let getLoastLoadEventState = true
943
942
  if(getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP){
944
943
  getLoastLoadEventState = isJdApp
945
944
  }
946
945
  else if(getInitLoadEnvType === LoadJsInitLoadEnvType.M){
947
946
  getLoastLoadEventState = !isJdApp
948
947
  }
949
948
  const getInitTriggerType = isJdApp && item?.initJdAppTriggerType ? item?.initTriggerType : item?.initTriggerType || LoadJsInitTriggerType.NOW
950
949
  const getInitLinkTriggerWay = window?.PAGE_DATA[item?.initLinkTriggerWay] || false
951
950
  return getLoastLoadEventState && getInitTriggerType === triggerType && getInitLinkTriggerWay
952
951
  })
953
952
  console.log("获取当前触发方式",triggerType,"获取当前最后加载的js集合",getLoadFilterList,"过滤前的加载集合",getLoadJsList)
954
953
  getLoadFilterList.length > 0 && getLoadFilterList.forEach((item) => {
955
954
  const isLoadState = /sgm/.test(item?.fileName) ? window?.shopGlobalSwitch?.openSgm === "true" : true
956
955
  isLoadState && this.loadItemSdkPromise(item)
957
956
  .then((res) => {
958
957
  console.info('当前js地址' + item?.src, '加载状态', res)
959
958
  const isFileNameNewDraSdkJs = res?.fileName === 'newDraSdkJs'
960
959
  if (isFileNameNewDraSdkJs && window?.dra?.run) {
961
960
  window.dra.run('init', { aid: res?.aid })
962
961
  window.dra.run('start')
963
962
  }
964
963
  })
965
964
  .catch((err) => {
966
965
  console.info('当前js地址加载异常', item?.src)
967
966
  window?.fetchErrorData &&
968
967
  window.fetchErrorData({
969
968
  title: '公共js加载异常',
970
969
  type: "jsLoad",
971
970
  data: err,
972
971
  })
973
972
  })
974
973
  })
975
974
  }
976
975
  loadScriptEle(jsInfo,resolve,reject){
977
976
  const getFileName = jsInfo?.fileName;
978
977
  if(getFileName){
979
978
  const getEleId = `J_loadJs_${getFileName}`
980
979
  const getEle = document.getElementById(getEleId)
981
980
  if (!getEle) {
982
981
  const jsLoadErrorSgmCode = `jsLoadError_${
983
982
  jsInfo?.fileName || 'customJs'
984
983
  }`
985
984
  const _sgmEle = document.createElement('script')
986
985
  _sgmEle.id = getEleId
987
986
  _sgmEle.onload = function () {
988
987
  resolve({
989
988
  ...jsInfo,
990
989
  jsTip: "js加载成功",
991
990
  })
992
991
  }
993
992
  _sgmEle.onerror = function () {
994
993
  reject({
995
994
  ...jsInfo,
996
995
  env: getSgmCustomCode(jsLoadErrorSgmCode),
997
996
  jsReqError: '当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误',
998
997
  })
999
998
  }
1000
999
  const dataAttrList = ['timeout','fileName',"env"]
1001
1000
  const getJsInfoKeyList = Object.keys(jsInfo)
1002
1001
  getJsInfoKeyList.forEach(key => {
1003
1002
  if(key === "async"){
1004
1003
  _sgmEle.async = jsInfo[key]
1005
1004
  }else if(key === "crossOrigin"){
1006
1005
  _sgmEle.crossOrigin = jsInfo[key]
1007
1006
  }else if(key === "src"){
1008
1007
  _sgmEle.src = `${jsInfo[key]}`
1009
1008
  }else if(dataAttrList.includes(key) || /init/.test(key)) {
1010
1009
  _sgmEle.setAttribute(`data-${key}`, jsInfo[key])
1011
1010
  }else {
1012
1011
  _sgmEle.setAttribute(key, jsInfo[key])
1013
1012
  }
1014
1013
  })
1015
1014
  document.head.appendChild(_sgmEle)
1016
1015
  }else {
1017
1016
  console.log(`当前${jsInfo?.fileName || "js"}已经存在页面中,可以直接调用相关方法`,jsInfo)
1018
1017
  resolve({
1019
1018
  ...jsInfo,
1020
1019
  jsTip: "js本身已存在页面中",
1021
1020
  })
1022
1021
  }
1023
1022
  }else {
1024
1023
  console.warn("当前js资源信息缺少必要的参数fileName,请关注",jsInfo)
1025
1024
  }
1026
1025
  }
1027
1026
 
1028
1027
  loadItemSdkPromise(jsInfo = {}){
1029
1028
  if(jsInfo?.src){
1030
1029
  const getInitLoadType = isJdApp && jsInfo?.initJdAppLoadType ? jsInfo?.initJdAppLoadType : jsInfo?.initLoadType || LoadJsInitLoadType.ALL
1031
1030
  if(getInitLoadType !== LoadJsInitLoadType.NONE){
1032
1031
  const getFileKeyName = jsInfo?.fileName || jsInfo?.src
1033
1032
  if (!this.loadJsSdkListCachePromise[getFileKeyName]){
1034
1033
  if(getInitLoadType !== LoadJsInitLoadType.INSERT_ELE){
1035
1034
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
1036
1035
  const jsLoadErrorSgmCode = `jsLoadError_${
1037
1036
  jsInfo?.fileName || 'customJs'
1038
1037
  }`
1039
1038
  try {
1040
1039
  const jsXhrRequest = new XMLHttpRequest();
1041
1040
  jsXhrRequest.timeout = jsInfo?.timeout ?? 2000
1042
1041
  const jsUrl = `${jsInfo?.src}`
1043
1042
  jsXhrRequest.open('GET', jsUrl, true);
1044
1043
  jsXhrRequest.onreadystatechange = () => {
1045
1044
  if (jsXhrRequest.readyState === 4){
1046
1045
  const getReqStatus = jsXhrRequest.status
1047
1046
  if (getReqStatus >= 200 && getReqStatus < 300 || getReqStatus === 304){
1048
1047
  const getInsetHeadState = getInitLoadType === LoadJsInitLoadType.ALL
1049
1048
  if(getInsetHeadState){
1050
1049
  this.loadScriptEle(jsInfo,resolve,reject)
1051
1050
  }else {
1052
1051
  resolve({
1053
1052
  ...jsInfo,
1054
1053
  jsTip: "js请求成功,暂未插入head节点,业务自行单独插入",
1055
1054
  })
1056
1055
  }
1057
1056
  getReqStatus !== 200 && sgmCustomReport({
1058
1057
  type: 3,
1059
1058
  code: "js_load_special_code",
1060
1059
  msg: {
1061
1060
  msg: "当前js加载成功,状态非200,特殊上报观察",
1062
1061
  jsReqState: getReqStatus,
1063
1062
  env: getSgmCustomCode("js_load_special_code"),
1064
1063
  data: jsInfo
1065
1064
  }
1066
1065
  })
1067
1066
  }else {
1068
1067
  const getRes = {
1069
1068
  ...jsInfo,
1070
1069
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1071
1070
  jsReqError: `请求状态异常,状态码为${getReqStatus}`,
1072
1071
  jsReqState: getReqStatus,
1073
1072
  }
1074
1073
  console.log("当前js请求状态异常,具体信息见", getRes)
1075
1074
  reject(getRes)
1076
1075
  }
1077
1076
  }
1078
1077
  };
1079
1078
  jsXhrRequest.onerror = () => {
1080
1079
  const getRes = {
1081
1080
  ...jsInfo,
1082
1081
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1083
1082
  jsReqError: '请求错误',
1084
1083
  }
1085
1084
  console.log("当前js请求错误", getRes)
1086
1085
  jsXhrRequest.abort()
1087
1086
  reject(getRes)
1088
1087
  }
1089
1088
  jsXhrRequest.ontimeout = () => {
1090
1089
  const getRes = {
1091
1090
  ...jsInfo,
1092
1091
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1093
1092
  jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
1094
1093
  jsReqState: jsXhrRequest.status,
1095
1094
  }
1096
1095
  console.log("当前js请求超时异常", getRes)
1097
1096
  jsXhrRequest.abort()
1098
1097
  reject(getRes)
1099
1098
  }
1100
1099
  jsXhrRequest.send();
1101
1100
  }catch (e) {
1102
1101
  console.log("执行js请求异常",e)
1103
1102
  reject({
1104
1103
  ...jsInfo,
1105
1104
  env: getSgmCustomCode(jsLoadErrorSgmCode),
1106
1105
  jsReqError: '未知异常',
1107
1106
  error: e,
1108
1107
  })
1109
1108
  }
1110
1109
  })
1111
1110
  }else {
1112
1111
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
1113
1112
  return this.loadScriptEle(jsInfo,resolve,reject)
1114
1113
  })
1115
1114
  }
1116
1115
  }
1117
1116
  return this.loadJsSdkListCachePromise[getFileKeyName]
1118
1117
  }else {
1119
1118
  return Promise.resolve({
1120
1119
  ...jsInfo,
1121
1120
  jsTip: "js加载方式设置为不加载,当前不做处理",
1122
1121
  })
1123
1122
  }
1124
1123
  }else {
1125
1124
  return Promise.reject(jsInfo)
1126
1125
  }
1127
1126
  }
1127
+ import Taro from '@tarojs/taro';
1128
1128
  BUSINESS_TYPE,
1129
1129
  cacheAppKey,
1130
1130
  cacheAppUuidKey,
1131
1131
  cacheH5LbsAddressKey,
1132
1132
  JSSDK_APP_WEBVIEW_CODE,
1133
1133
  LoadJsInitLoadEnvType,
1134
1134
  LoadJsInitLoadType,
1135
1135
  LoadJsInitTriggerType,
1136
1136
  MPAAS_CONFIG_APP_LOW_VERSION,
1137
1137
  MPAAS_CONFIG_APP_VERSION,
1138
1138
  SECTION_HOME_TAB_NAME_TYPE,
1139
1139
  SECTION_HOME_TAB_TYPE,
1140
1140
  TaroEventType,
1141
1141
  WX_BUSINESS_TYPE,
1142
1142
  WXAPP_BIZ_KEY,
1143
1143
  WXAPP_BIZ_SHOP_LIGHT_KEY,
1144
1144
  languageTypeList,
1145
1145
  getSystemInfos,
1146
1146
  getTaroStorageKeyValue,
1147
1147
  ipLoc_djd,
1148
1148
  setTaroStorage,
1149
1149
  isInJdAppH5DebugMode,
1150
1150
  callRouterAndroid,
1151
1151
  callRouterIOS,
1152
1152
  getMPaasConfigByBussinessKey,
1153
1153
  dealNativePixelToCssPixel,
1154
1154
  draBusinessCustomReport,
1155
1155
  isAndroidDevice,
1156
1156
  isH5AndJingGouMini,
1157
1157
  isIosDevice,
1158
1158
  isJdAndAndroidDevice,
1159
1159
  isObject,
1160
1160
  isPc,
1161
1161
  isString,
1162
1162
  jdAppVersion,
1163
1163
  jdAppVersionStr,
1164
1164
  serialize,
1165
1165
  languageNowType,
1166
1166
  urlCookie,
1167
1167
  isAscfApp,
1168
1168
  jdAppVersionCompare,
1169
1169
  parseQueryUrlObj,
1170
1170
  abTestLabels: {},
1171
1171
  nonSellableSkuids: {},
1172
1172
  loginState: false,
1173
1173
  cookiesStr: '',
1174
1174
  userInfo: userPinKey,
1175
1175
  isImmersive:
1176
1176
  !window?.shopGlobalSwitch?.disableImmersive &&
1177
1177
  isJdApp &&
1178
1178
  window.location?.search.includes('immersive=1'),
1179
1179
  isJingGouMiniViewState: false,
1180
1180
  isJingxiMiniViewState: false,
1181
1181
  baseAddCartSwitch: true,
1182
1182
  pageInfo: {
1183
1183
  wxBusinessType: WX_BUSINESS_TYPE.NO,
1184
1184
  address: '',
1185
1185
  addressCommaStr: '',
1186
1186
  fullAddress: '',
1187
1187
  un_area: '',
1188
1188
  userLbsAddress: '',
1189
1189
  vapptype: '1',
1190
1190
  pageType: 'home',
1191
1191
  isExposureState: false,
1192
1192
  moduleId: '',
1193
1193
  entrance: '',
1194
1194
  dataType: BUSINESS_TYPE.ONLINE,
1195
1195
  floorExposureInfo: {},
1196
1196
  floorVideInfo: {},
1197
1197
  productVideInfo: {},
1198
1198
  tabsLoadAllDataInfo: {
1199
1199
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
1200
1200
  },
1201
1201
  updateShopInfosAllState: false,
1202
1202
  isVipShop: false,
1203
1203
  isJdShowNativeImmersivePlayer: false,
1204
1204
  isSuperBrandShop: false,
1205
1205
  ...shopConfig,
1206
1206
  pageScrollTop: 0,
1207
1207
  pageIdxHeightInfo: {
1208
1208
  list: [],
1209
1209
  },
1210
1210
  shopNavBarHeight: 0,
1211
1211
  },
1212
1212
  defaultQueryLogInfo: {
1213
1213
  sourceType: 'JDshop',
1214
1214
  sourceValue: '',
1215
1215
  moduleId: 'none',
1216
1216
  entrance: 'none',
1217
1217
  },
1218
1218
  sysInfo: {
1219
1219
  windowWidth: isPc ? 375 : 0,
1220
1220
  containerWidth: isPc ? 375 : 0,
1221
1221
  windowHeight: 0,
1222
1222
  netWorkType: '4g',
1223
1223
  jdBottomBarHeight: 0,
1224
1224
  jdNativeHeaderHeight: 0,
1225
1225
  isJdTabletDevice: false,
1226
1226
  isJdTabletLandscape: false,
1227
1227
  },
1228
1228
  queryInfo: {},
1229
1229
  shopInfo: {},
1230
1230
  openAppData: {},
1231
1231
  public info: CommonInterFace.BaseConfigInfo;
1232
1232
  public config: {
1233
1233
  [key: string]: any;
1234
1234
  };
1235
1235
  public lazyContainer: CommonInterFace.lazyContainer;
1236
1236
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
1237
1237
  public rootEleNode: HTMLElement | null;
1238
1238
  public checkStatusAndLoginPromise: object | null;
1239
1239
  private jmfeRegisterStatePromise: Promise<any> | null;
1240
1240
  private jdScreenSizeInfoPromise: Promise<any> | null;
1241
1241
  private rootEleWidthRegisterPromise: Promise<any> | null;
1242
1242
  private loadJsH5tagStatePromise: Promise<any> | null;
1243
1243
  private loadJsApiRequestStatePromise: Promise<any> | null;
1244
1244
  private jmfeRegisterState: boolean;
1245
1245
  public loadJsSdkList: {
1246
1246
  src: string;
1247
1247
  timeout: number;
1248
1248
  fileName: string;
1249
1249
  initTriggerType: typeof LoadJsInitTriggerType;
1250
1250
  initLinkTriggerWay:
1251
1251
  | 'asyncLoadAppSdkJs'
1252
1252
  | 'asyncLoadHandlerJs'
1253
1253
  | 'asyncLoadReportJs'
1254
1254
  | 'asyncLoadMtkJs'
1255
1255
  | 'asyncLoadSecurityJs'
1256
1256
  | 'asyncLoadSgmJs'
1257
1257
  | 'asyncLoadCartJs'
1258
1258
  | 'asyncLoadNewDraSdkJs'
1259
1259
  | 'asyncLoadH5TagJs';
1260
1260
  initLoadEnvType: typeof LoadJsInitLoadEnvType;
1261
1261
  defer?: 'true';
1262
1262
  async?: 'true';
1263
1263
  crossOrigin: 'anonymous' | '';
1264
1264
  }[];
1265
1265
  public loadJsSdkListCachePromise: any;
1266
1266
  public rootEleInitWidth: number;
1267
1267
  public lbsAddressCachePromise: Promise<any> | null;
1268
1268
  public languageCacheProimse: Promise<any> | null;
1269
1269
  public languageJsonData: any | null;
1270
1270
  public businessWorkerReady: boolean;
1271
1271
  public businessWorkerReadyPromise: Promise<any> | null;
1272
1272
  public workerPreRequestData = new Map<string, any>();
1273
1273
  constructor(opt) {
1274
1274
  this.info = this._getConfig(opt);
1275
1275
  this.config = {};
1276
1276
  this.loadJsSdkList = [];
1277
1277
  this.loadJsSdkListCachePromise = {};
1278
1278
  this.lazyContainer = {
1279
1279
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
1280
1280
  appLazyContainerList: [],
1281
1281
  appLazyFinishContainerList: [],
1282
1282
  },
1283
1283
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
1284
1284
  appLazyContainerList: [],
1285
1285
  appLazyFinishContainerList: [],
1286
1286
  },
1287
1287
  };
1288
1288
  this.renderedIsvComponents = {};
1289
1289
  this.rootEleNode = document.querySelector('body');
1290
1290
  this.checkStatusAndLoginPromise = null;
1291
1291
  this.jmfeRegisterStatePromise = null;
1292
1292
  this.jdScreenSizeInfoPromise = null;
1293
1293
  this.rootEleWidthRegisterPromise = null;
1294
1294
  this.lbsAddressCachePromise = null;
1295
1295
  this.languageCacheProimse = null;
1296
1296
  this.businessWorkerReady = false;
1297
1297
  this.businessWorkerReadyPromise = null;
1298
1298
  this.loadJsH5tagStatePromise = null;
1299
1299
  this.loadJsApiRequestStatePromise = null;
1300
1300
  this.workerPreRequestData = new Map<string, any>();
1301
1301
  this.languageJsonData = langeJsonDataForCn;
1302
1302
  this.rootEleInitWidth = this.getRootEleWindowWidthInfo().getRootEleWidth || -1;
1303
1303
  this._init();
1304
1304
  if (isJdApp) {
1305
1305
  this.jmfeReayPromise().then(() => {
1306
1306
  this.jdWorkerReadyPromise();
1307
1307
  initAccessibility();
1308
1308
  });
1309
1309
  this._getJdPadMinWidthForListen() && this.getPadWindowRootEleWidthPromise();
1310
1310
  }
1311
1311
  }
1312
1312
  _getConfig(opt) {
1313
1313
  return Object.assign({}, DefaultConfig, opt);
1314
1314
  }
1315
1315
  _init() {
1316
1316
  this.loadOtherSdk();
1317
1317
  this.checkJdAddCartState();
1318
1318
  this.checkPageDomHeightToReport();
1319
1319
  }
1320
1320
  checkPageDomHeightToReport() {
1321
1321
  Taro.nextTick(() => {
1322
1322
  setTimeout(() => {
1323
1323
  const getReportData = {
1324
1324
  containerFloorLisHeight: -1,
1325
1325
  appHeight: -1,
1326
1326
  };
1327
1327
  const getAppEle = document.getElementById('app');
1328
1328
  const getFloorContainerEle = document.getElementById('J_shopContainerFloorList');
1329
1329
  const getNetWorkEle = document.querySelector('.J_shopNetwork');
1330
1330
  getFloorContainerEle &&
1331
1331
  (getReportData.containerFloorLisHeight =
1332
1332
  getFloorContainerEle?.getBoundingClientRect()?.height ?? -1);
1333
1333
  getAppEle && (getReportData.appHeight = getAppEle?.getBoundingClientRect()?.height ?? -1);
1334
1334
  const getMaxHeight = Math.max(
1335
1335
  getReportData.appHeight,
1336
1336
  getReportData.containerFloorLisHeight,
1337
1337
  );
1338
1338
  if (!getNetWorkEle && getMaxHeight > -1 && getMaxHeight < 80) {
1339
1339
  draBusinessCustomReport({
1340
1340
  eventName: 'business',
1341
1341
  errorName: 'pageDomHeightErrorCheck',
1342
1342
  errorMessage:
1343
1343
  '当前页面总高度异常小于80px,没有兜底network组件,可能空窗,请检查核对详细信息',
1344
1344
  extraData: JSON.stringify({
1345
1345
  data: getReportData,
1346
1346
  isJdApp,
1347
1347
  }),
1348
1348
  });
1349
1349
  }
1350
1350
  }, window?.shopGlobalSwitch?.checkPageDomHeightTime || 4000);
1351
1351
  });
1352
1352
  }
1353
1353
 
1354
1354
  checkJdAddCartState() {
1355
1355
  const getJdAppForNotMainRemoveCartUaList = isJdApp
1356
1356
  ? window?.PAGE_DATA?.businessData?.jdAppForNotMainRemoveCartUaList
1357
1357
  : undefined;
1358
1358
  if (
1359
1359
  getJdAppForNotMainRemoveCartUaList &&
1360
1360
  Array.isArray(getJdAppForNotMainRemoveCartUaList) &&
1361
1361
  getJdAppForNotMainRemoveCartUaList.length > 0
1362
1362
  ) {
1363
1363
  const setFilterReg = new RegExp(getJdAppForNotMainRemoveCartUaList.join('|'), 'i');
1364
1364
  this.info.baseAddCartSwitch = !setFilterReg.test(window.navigator.userAgent);
1365
1365
  }
1366
1366
  }
1367
1367
 
1368
1368
  loadApiSafeSteadyReayPromise() {
1369
1369
  if (!this.loadJsApiRequestStatePromise) {
1370
1370
  this.loadJsApiRequestStatePromise = this.loadOtherSdk(LoadJsInitTriggerType.API_REQUEST);
1371
1371
  }
1372
1372
  return this.loadJsApiRequestStatePromise;
1373
1373
  }
1374
1374
 
1375
1375
  loadH5tagReayPromise() {
1376
1376
  if (!this.loadJsH5tagStatePromise) {
1377
1377
  const h5TagJs = this.loadJsSdkList.find((e) => e.fileName === 'h5TagJs');
1378
1378
  this.loadJsH5tagStatePromise = !h5TagJs
1379
1379
  ? Promise.resolve(true)
1380
1380
  : this.loadOtherSdk(LoadJsInitTriggerType.NOW, [
1381
1381
  Object.assign({}, h5TagJs, {
1382
1382
  initTriggerType: LoadJsInitTriggerType.NOW,
1383
1383
  }),
1384
1384
  ]);
1385
1385
  }
1386
1386
  return this.loadJsH5tagStatePromise;
1387
1387
  }
1388
1388
 
1389
1389
  jmfeReayPromise(): Promise<any> {
1390
1390
  if (isJdApp) {
1391
1391
  if (this.jmfeRegisterState) {
1392
1392
  return Promise.resolve(true);
1393
1393
  } else {
1394
1394
  !this.jmfeRegisterStatePromise &&
1395
1395
  (this.jmfeRegisterStatePromise = new Promise((resolve, reject) => {
1396
1396
  ready('jmfe', 3000)
1397
1397
  .then(() => {
1398
1398
  window?.jmfe && window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE);
1399
1399
  this.jmfeRegisterState = true;
1400
1400
  resolve(true);
1401
1401
  console.log(
1402
1402
  '松果app内初始化注册jmfe认证完成',
1403
1403
  window?.jmfe,
1404
1404
  '当前版本',
1405
1405
  window?.jmfe?.VERSION,
1406
1406
  );
1407
1407
  })
1408
1408
  .catch((err) => {
1409
1409
  console.error('jmfe ready error', err);
1410
1410
  reject(false);
1411
1411
  });
1412
1412
  }));
1413
1413
  return this.jmfeRegisterStatePromise;
1414
1414
  }
1415
1415
  } else {
1416
1416
  return Promise.reject(false);
1417
1417
  }
1418
1418
  }
1419
1419
 
1420
1420
  jdWorkerReadyPromise(): Promise<any> {
1421
1421
  if (isJdApp) {
1422
1422
  if (this.businessWorkerReady) {
1423
1423
  return Promise.resolve(true);
1424
1424
  } else {
1425
1425
  const getOpenJdWorkerState =
1426
1426
  window?.PAGE_DATA?.businessData?.businessWorkerVersion &&
1427
1427
  versionCompare(
1428
1428
  jdAppVersionStr,
1429
1429
  window?.shopGlobalSwitch?.jdAppWorkerOpenVersion || '15.3.10',
1430
1430
  ) >= 0;
1431
1431
  !this.businessWorkerReadyPromise &&
1432
1432
  (this.businessWorkerReadyPromise = getOpenJdWorkerState
1433
1433
  ? new Promise((resolve) => {
1434
1434
  this.jmfeReayPromise()
1435
1435
  .then(() => {
1436
1436
  window.jmfe
1437
1437
  .onMsgForWorker(
1438
1438
  { version_code: window?.PAGE_DATA?.businessData?.businessWorkerVersion },
1439
1439
  (workerData) => {
1440
1440
  console.log('收到业务jd worker消息结果:', workerData);
1441
1441
  if (workerData && workerData?.workerType) {
1442
1442
  const getWorkerType = workerData?.workerType;
1443
1443
  if (getWorkerType === TaroEventType.jdWorkerPreRequest) {
1444
1444
  this.workerPreRequestData.set(workerData?.functionId, workerData);
1445
1445
  Taro.eventCenter.trigger(getWorkerType, workerData);
1446
1446
  } else if (getWorkerType === TaroEventType.jdWorkerRequest) {
1447
1447
  Taro.eventCenter.trigger(getWorkerType, workerData);
1448
1448
  }
1449
1449
  }
1450
1450
  },
1451
1451
  )
1452
1452
  .then(() => {
1453
1453
  console.log('jd worker注册成功');
1454
1454
  this.businessWorkerReady = true;
1455
1455
  resolve(true);
1456
1456
  })
1457
1457
  .catch((error) => {
1458
1458
  console.log(
1459
1459
  'jd worker注册失败,可能是客户端不支持worker,或者worker.js文件加载失败等原因。h5需要在此处做逻辑兜底,无法通过worker处理单独逻辑',
1460
1460
  error,
1461
1461
  );
1462
1462
  draBusinessCustomReport({
1463
1463
  eventName: 'business',
1464
1464
  errorName: 'jmfe_onMsgForWorker_error',
1465
1465
  errorMessage: `jd worker注册失败,可能是客户端不支持worker,或者worker.js文件加载失败等原因。h5需要在此处做逻辑兜底,无法通过worker处理单独逻辑`,
1466
1466
  extraData: JSON.stringify({
1467
1467
  businessWorkerVersion:
1468
1468
  window?.PAGE_DATA?.businessData?.businessWorkerVersion,
1469
1469
  error,
1470
1470
  }),
1471
1471
  });
1472
1472
  resolve(false);
1473
1473
  });
1474
1474
  })
1475
1475
  .catch((err) => {
1476
1476
  console.log('jmfe超时异常,worker注册失败', err);
1477
1477
  resolve(false);
1478
1478
  });
1479
1479
  })
1480
1480
  : Promise.resolve(false));
1481
1481
  }
1482
1482
  return this.businessWorkerReadyPromise;
1483
1483
  } else {
1484
1484
  return Promise.resolve(false);
1485
1485
  }
1486
1486
  }
1487
1487
 
1488
1488
  taskTimeoutPromise(callBack, timeout = 2000) {
1489
1489
  return new Promise((resolve) => {
1490
1490
  setTimeout(
1491
1491
  () => {
1492
1492
  const getCallBackRes = typeof callBack === 'function' && callBack();
1493
1493
  return resolve(getCallBackRes || false);
1494
1494
  },
1495
1495
  isInJdAppH5DebugMode ? 0 : timeout,
1496
1496
  );
1497
1497
  });
1498
1498
  }
1499
1499
  _getJdPadMinWidthForListen() {
1500
1500
  return (
1501
1501
  isJdApp &&
1502
1502
  Math.min(window.screen.width, window.screen.height) >
1503
1503
  (window?.shopGlobalSwitch?.checkPadRootEleMinWidth || 600)
1504
1504
  );
1505
1505
  }
1506
1506
 
1507
1507
  getJdScreenSizeInfoPromise() {
1508
1508
  !this.jdScreenSizeInfoPromise &&
1509
1509
  (this.jdScreenSizeInfoPromise = new Promise((resolve) => {
1510
1510
  const getThisTime = Date.now();
1511
1511
  this.jmfeReayPromise().then(() => {
1512
1512
  return Promise.race([
1513
1513
  window.jmfe.getScreenSize(),
1514
1514
  this.taskTimeoutPromise(() => {
1515
1515
  return {
1516
1516
  status: '-10',
1517
1517
  msg: '获取大屏信息2s超时',
1518
1518
  };
1519
1519
  }),
1520
1520
  ])
1521
1521
  .then((res) => {
1522
1522
  console.warn('===获取app大屏信息====', res);
1523
1523
  const { status, data } = res;
1524
1524
  if (status === '0' && data) {
1525
1525
  const { sizeType, isLandscape, pageHeight, pageWidth } = data;
1526
1526
  const getPageInfo = dealNativePixelToCssPixel({
1527
1527
  pageWidth,
1528
1528
  pageHeight,
1529
1529
  });
1530
1530
  this.info.sysInfo.jdScreenSizeType = sizeType;
1531
1531
  const getUseTime = Date.now() - getThisTime;
1532
1532
  console.warn(
1533
1533
  '===计算是否是app大屏信息,需满足宽度最新720===',
1534
1534
  getPageInfo,
1535
1535
  '原始数据',
1536
1536
  data,
1537
1537
  '是否是横屏isLandscape为1=',
1538
1538
  isLandscape,
1539
1539
  '用时',
1540
1540
  getUseTime,
1541
1541
  );
1542
1542
  if (getPageInfo?.pageWidth > 0) {
1543
1543
  this.rootEleInitWidth = getPageInfo?.pageWidth;
1544
1544
  draBusinessCustomReport({
1545
1545
  eventName: 'UIInteract',
1546
1546
  errorName: 'rootEle_width_getJdScreenSizeInfo',
1547
1547
  errorMessage: `根元素获取宽度初始化为0,通过getJdScreenSizeInfo获取结果,用时${getUseTime}`,
1548
1548
  extraData: JSON.stringify({
1549
1549
  isJdApp,
1550
1550
  getPageInfo,
1551
1551
  originData: res,
1552
1552
  }),
1553
1553
  });
1554
1554
  resolve(getPageInfo);
1555
1555
  } else {
1556
1556
  resolve({
1557
1557
  pageWidth: 0,
1558
1558
  pageHeight: 0,
1559
1559
  msg: '转换异常',
1560
1560
  });
1561
1561
  }
1562
1562
  } else {
1563
1563
  resolve({
1564
1564
  pageWidth: 0,
1565
1565
  pageHeight: 0,
1566
1566
  msg: '获取大屏信息异常或者超时',
1567
1567
  });
1568
1568
  }
1569
1569
  })
1570
1570
  .catch((err) => {
1571
1571
  console.log('获取大屏信息异常', err);
1572
1572
  resolve({
1573
1573
  pageWidth: 0,
1574
1574
  pageHeight: 0,
1575
1575
  msg: '获取大屏信息异常',
1576
1576
  });
1577
1577
  });
1578
1578
  });
1579
1579
  }));
1580
1580
  return this.jdScreenSizeInfoPromise;
1581
1581
  }
1582
1582
 
1583
1583
  listenJdTabletScreenChange() {
1584
1584
  this.jmfeReayPromise().then(() => {
1585
1585
  try {
1586
1586
  console.log('初始化监听大屏信息变化', window.jmfe.listenDeviceScreenChange);
1587
1587
  window.jmfe.listenDeviceScreenChange((event) => {
1588
1588
  console.log(
1589
1589
  '监听app大屏信息变化,orientation为landscape表示横屏,multiScreen为1表示android端分屏',
1590
1590
  event,
1591
1591
  '通过前端判断是不是横屏',
1592
1592
  window.matchMedia('(orientation: landscape)')?.matches,
1593
1593
  );
1594
1594
  const { orientation } = event?.data;
1595
1595
  if (orientation) {
1596
1596
  this.info.sysInfo.isJdTabletLandscape = orientation === 'landscape';
1597
1597
  Taro.eventCenter.trigger(
1598
1598
  TaroEventType.TABLE_SCREEN_CHANGE,
1599
1599
  this.info.sysInfo.isJdTabletLandscape,
1600
1600
  orientation,
1601
1601
  );
1602
1602
  }
1603
1603
  });
1604
1604
  } catch (error) {
1605
1605
  console.log('listenScreenChange的打印error:', error);
1606
1606
  }
1607
1607
  });
1608
1608
  }
1609
1609
 
1610
1610
  updateBusinessDomainAndApi(domain, api) {
1611
1611
  }
1612
1612
 
1613
1613
  formatNativeScreenPageData(action) {
1614
1614
  let getChangePageInfo: any = null;
1615
1615
  try {
1616
1616
  const getNativeScreenPageInfoStr = window.XWebView?._callNative(
1617
1617
  JSON.stringify({
1618
1618
  plugin: 'JDHybridScreenPlugin',
1619
1619
  action,
1620
1620
  sync: '1',
1621
1621
  }),
1622
1622
  );
1623
1623
  const getChangePageInfoData =
1624
1624
  typeof getNativeScreenPageInfoStr === 'string'
1625
1625
  ? JSON.parse(getNativeScreenPageInfoStr)
1626
1626
  : null;
1627
1627
  if (getChangePageInfoData && typeof getChangePageInfoData === 'object') {
1628
1628
  const { code, data } = getChangePageInfoData;
1629
1629
  getChangePageInfo = code && code === '0' ? data : null;
1630
1630
  }
1631
1631
  } catch (e) {
1632
1632
  console.log('JDHybridScreenPlugin转换异常', e);
1633
1633
  }
1634
1634
  return getChangePageInfo;
1635
1635
  }
1636
1636
 
1637
1637
  isAndroidFoldScreen() {
1638
1638
  return this.formatNativeScreenPageData('isFoldScreen') === '1';
1639
1639
  }
1640
1640
 
1641
1641
  isHarmonyFoldScreenPromise(): Promise<{
1642
1642
  isFoldScreen: boolean;
1643
1643
  getFoldDisplayMode?: number;
1644
1644
  }> {
1645
1645
  return new Promise((resolve) => {
1646
1646
  this.jmfeReayPromise()
1647
1647
  .then(() => {
1648
1648
  if (window.jmfe?.callNative) {
1649
1649
  Promise.all([
1650
1650
  window.jmfe.callNative('JDHybridScreenPlugin', 'isFoldScreen', {}),
1651
1651
  window.jmfe.callNative('JDHybridScreenPlugin', 'getFoldDisplayMode', {}),
1652
1652
  ])
1653
1653
  .then((res) => {
1654
1654
  resolve({
1655
1655
  isFoldScreen: res?.[0]?.data === '1',
1656
1656
  getFoldDisplayMode: res?.[1]?.data,
1657
1657
  });
1658
1658
  })
1659
1659
  .catch(() => {
1660
1660
  resolve({
1661
1661
  isFoldScreen: false,
1662
1662
  getFoldDisplayMode: undefined,
1663
1663
  });
1664
1664
  });
1665
1665
  } else {
1666
1666
  resolve({
1667
1667
  isFoldScreen: false,
1668
1668
  getFoldDisplayMode: undefined,
1669
1669
  });
1670
1670
  }
1671
1671
  })
1672
1672
  .catch(() => {
1673
1673
  resolve({
1674
1674
  isFoldScreen: false,
1675
1675
  getFoldDisplayMode: undefined,
1676
1676
  });
1677
1677
  });
1678
1678
  });
1679
1679
  }
1680
1680
 
1681
1681
  getJdAndroidPageChangeScreenInfo() {
1682
1682
  const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize');
1683
1683
  if (getPageScreenInfo && getPageScreenInfo?.pageWidth && getPageScreenInfo?.pageHeight) {
1684
1684
  const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
1685
1685
  pageWidth: getPageScreenInfo.pageWidth,
1686
1686
  pageHeight: getPageScreenInfo.pageHeight,
1687
1687
  });
1688
1688
  getPageScreenInfo.pageWidth = pageWidth;
1689
1689
  getPageScreenInfo.pageHeight = pageHeight;
1690
1690
  }
1691
1691
  return getPageScreenInfo;
1692
1692
  }
1693
1693
 
1694
1694
  getRootEleWindowWidthInfo() {
1695
1695
  const getRootEleWidth = document.documentElement.getBoundingClientRect().width;
1696
1696
  const getWindowWidth = window.innerWidth;
1697
1697
  const getScreenWidth = window.screen.width;
1698
1698
  return {
1699
1699
  getRootEleWidth,
1700
1700
  getWindowWidth,
1701
1701
  getScreenWidth,
1702
1702
  };
1703
1703
  }
1704
1704
 
1705
1705
  dealRootEleWidthFn(reportParam = {}, timeout = 0) {
1706
1706
  const { getRootEleWidth, getWindowWidth, getScreenWidth } = this.getRootEleWindowWidthInfo();
1707
1707
  console.log(
1708
1708
  '当前获取根元素的宽度',
1709
1709
  getRootEleWidth,
1710
1710
  'getWindowWidth',
1711
1711
  getWindowWidth,
1712
1712
  'getScreenWidth',
1713
1713
  getScreenWidth,
1714
1714
  );
1715
1715
  const getLastWidth =
1716
1716
  getRootEleWidth > 0
1717
1717
  ? Math.round(getRootEleWidth)
1718
1718
  : Math.round(getWindowWidth > 0 ? getWindowWidth : getScreenWidth);
1719
1719
  console.warn(
1720
1720
  `根元素获取宽度初始化为0,通过getJdScreenSizeInfo获取结果超时,超时时间超时时间${timeout}ms,最终兜底再获取一次根元素宽度${getLastWidth}`,
1721
1721
  );
1722
1722
  timeout > 0 &&
1723
1723
  draBusinessCustomReport({
1724
1724
  eventName: 'UIInteract',
1725
1725
  errorName: 'rootEle_width_timeout_getJdScreenSizeInfo',
1726
1726
  errorMessage: `根元素获取宽度初始化为0,通过getJdScreenSizeInfo获取结果超时,超时时间${timeout}ms,最终兜底再获取一次根元素宽度${getLastWidth}`,
1727
1727
  extraData: JSON.stringify({
1728
1728
  isJdApp,
1729
1729
  getRootEleWidth,
1730
1730
  getWindowWidth,
1731
1731
  getScreenWidth,
1732
1732
  ...reportParam,
1733
1733
  }),
1734
1734
  });
1735
1735
  return getLastWidth;
1736
1736
  }
1737
1737
 
1738
1738
  getPadWindowRootEleWidthPromise() {
1739
1739
  if (this.rootEleInitWidth > 0) {
1740
1740
  return Promise.resolve(this.rootEleInitWidth);
1741
1741
  } else {
1742
1742
  !this.rootEleWidthRegisterPromise &&
1743
1743
  (this.rootEleWidthRegisterPromise = new Promise((resolve) => {
1744
1744
  const getRootEleInitWidth = this.getRootEleWindowWidthInfo().getRootEleWidth;
1745
1745
  if (getRootEleInitWidth > 0) {
1746
1746
  console.log('初始化获取根元素宽度正常,为', getRootEleInitWidth);
1747
1747
  this.rootEleInitWidth = Math.round(getRootEleInitWidth);
1748
1748
  resolve(this.rootEleInitWidth);
1749
1749
  } else {
1750
1750
  const timerPromise = () => {
1751
1751
  return new Promise((resolve2) => {
1752
1752
  window.setTimeout(() => {
1753
1753
  const { getRootEleWidth, getWindowWidth, getScreenWidth } =
1754
1754
  this.getRootEleWindowWidthInfo();
1755
1755
  if (getRootEleWidth > 0 || getWindowWidth > 0) {
1756
1756
  console.warn(
1757
1757
  `根元素获取宽度初始化为0,200ms后尝试获取最新结果,getRootEleWidth为${getRootEleWidth},getWindowWidth为${getWindowWidth},getScreenWidth为${getScreenWidth}`,
1758
1758
  );
1759
1759
  draBusinessCustomReport({
1760
1760
  eventName: 'UIInteract',
1761
1761
  errorName: 'rootEle_width_200_timeout_info',
1762
1762
  errorMessage: `根元素获取宽度初始化为0,200ms后尝试获取最新结果,getRootEleWidth为${getRootEleWidth},getWindowWidth为${getWindowWidth}`,
1763
1763
  extraData: JSON.stringify({
1764
1764
  isJdApp,
1765
1765
  getRootEleWidth,
1766
1766
  getWindowWidth,
1767
1767
  getScreenWidth,
1768
1768
  }),
1769
1769
  });
1770
1770
  const getRes =
1771
1771
  getRootEleWidth > 0 && getWindowWidth > 0
1772
1772
  ? Math.min(getRootEleWidth, getWindowWidth)
1773
1773
  : Math.max(getRootEleWidth, getWindowWidth);
1774
1774
  resolve2({
1775
1775
  pageWidth: Math.round(getRes),
1776
1776
  });
1777
1777
  }
1778
1778
  }, 200);
1779
1779
  });
1780
1780
  };
1781
1781
  Promise.race([timerPromise(), this.getJdScreenSizeInfoPromise()]).then((res) => {
1782
1782
  const { pageWidth } = res;
1783
1783
  console.log('获取结果Promise.race getJdScreenSizeInfo', res);
1784
1784
  pageWidth > 0 ? resolve(pageWidth) : resolve(this.dealRootEleWidthFn(res, 2000));
1785
1785
  });
1786
1786
  }
1787
1787
  }));
1788
1788
  return this.rootEleWidthRegisterPromise;
1789
1789
  }
1790
1790
  }
1791
1791
 
1792
1792
  async getSystemInfo(params) {
1793
1793
  const getParams = Object.assign({}, params || {});
1794
1794
  if (this.rootEleInitWidth > 0) {
1795
1795
  getParams['rootEleInitWidth'] = this.rootEleInitWidth;
1796
1796
  console.log('获取当前系统信息的时候已经获取到根元素宽度,值为', this.rootEleInitWidth);
1797
1797
  } else {
1798
1798
  if (this._getJdPadMinWidthForListen()) {
1799
1799
  getParams['rootEleInitWidth'] = await this.getPadWindowRootEleWidthPromise();
1800
1800
  getParams['replaceSystemWidth'] = true;
1801
1801
  }
1802
1802
  }
1803
1803
  isJdApp && this.createLanguagePromise();
1804
1804
  let info: UtilsInterFace.taroGetSystemInfoSyncRes | any = getSystemInfos(getParams);
1805
1805
  if (isJdAndAndroidDevice && info?.initWindowWidth <= 0) {
1806
1806
  let _isfoldScreen = false;
1807
1807
  const getStorageData = getTaroStorageKeyValue('jd_shopx_androidIsFoldScreen');
1808
1808
  console.info(
1809
1809
  '获取当前本地存储是否有jd_shopx_androidIsFoldScreen',
1810
1810
  getStorageData,
1811
1811
  '通过缓存值第一次判断是否是折叠屏',
1812
1812
  getStorageData === 'true',
1813
1813
  );
1814
1814
  if (!getStorageData) {
1815
1815
  _isfoldScreen = this.isAndroidFoldScreen();
1816
1816
  setTaroStorage('jd_shopx_androidIsFoldScreen', `${_isfoldScreen}`);
1817
1817
  } else {
1818
1818
  _isfoldScreen = getStorageData === 'true';
1819
1819
  }
1820
1820
  if (_isfoldScreen) {
1821
1821
  const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo();
1822
1822
  if (getJdAndroidPageInfo) {
1823
1823
  info = getSystemInfos(getJdAndroidPageInfo);
1824
1824
  console.warn(
1825
1825
  '当前为松果安卓折叠屏app,获取折叠屏信息',
1826
1826
  getJdAndroidPageInfo,
1827
1827
  '获取转换后的系统信息',
1828
1828
  info,
1829
1829
  );
1830
1830
  draBusinessCustomReport({
1831
1831
  eventName: 'UIInteract',
1832
1832
  errorName: 'android_jdapp_foldScreen_info',
1833
1833
  errorMessage:
1834
1834
  '松果安卓app为折叠屏,重置获取的系统宽高信息,因为获取宽高度信息初始化内部可能存在横竖屏差异',
1835
1835
  extraData: JSON.stringify({
1836
1836
  title: `松果安卓app为折叠屏,重置获取的系统宽高信息,因为获取宽高度信息初始化内部可能存在横竖屏差异`,
1837
1837
  androidPageInfo: getJdAndroidPageInfo,
1838
1838
  jdAppVersionStr,
1839
1839
  taroSysInfo: info,
1840
1840
  }),
1841
1841
  });
1842
1842
  }
1843
1843
  }
1844
1844
  }
1845
1845
  if (isJdApp) {
1846
1846
  info?.isJdTabletDevice && this.listenJdTabletScreenChange();
1847
1847
  }
1848
1848
  this.info.sysInfo = {
1849
1849
  actualNavBarHeight: 0,
1850
1850
  ...this.info.sysInfo,
1851
1851
  ...info,
1852
1852
  safeContentHeight: info?.screenHeight,
1853
1853
  headerHeight: 0,
1854
1854
  tabBarHeight: 0,
1855
1855
  languageType: languageNowType,
1856
1856
  };
1857
1857
  if (isJdApp || isH5AndJingGouMini) {
1858
1858
  this.getAddressCachePromise();
1859
1859
  this.getLbsAddressCachePromise();
1860
1860
  }
1861
1861
  if (isJdApp) {
1862
1862
  this.info.sysInfo['hostVersionName'] = jdAppVersionStr;
1863
1863
  this.info.sysInfo['hostAppVersion'] = jdAppVersion;
1864
1864
  this.getJdAppBaseInfo();
1865
1865
  this.getElderModePromise();
1866
1866
  this.getJDAppearanceStatePromise();
1867
1867
  this.createJdAndroidRquestEventForTouchStart();
1868
1868
  }
1869
1869
  this.getWifiVideoAutoPlayAsync();
1870
1870
  this.getMPaasConfigAsync();
1871
1871
  this.getNetWorkType();
1872
1872
  }
1873
1873
 
1874
1874
  getElderModePromise() {
1875
1875
  if (this.info.sysInfo.hasOwnProperty('jdAppModeType')) {
1876
1876
  return Promise.resolve(this.info.sysInfo.jdAppModeType);
1877
1877
  } else {
1878
1878
  if (isJdAndAndroidDevice) {
1879
1879
  this.info.sysInfo.jdAppModeType = '0';
1880
1880
  return Promise.resolve(this.info.sysInfo.jdAppModeType);
1881
1881
  } else {
1882
1882
  return Promise.race([
1883
1883
  this.taskTimeoutPromise(() => {
1884
1884
  this.info.sysInfo.jdAppModeType = '0';
1885
1885
  return this.info.sysInfo.jdAppModeType;
1886
1886
  }),
1887
1887
  new Promise((resolve) => {
1888
1888
  const getCallBackName = `getJdCurrentModeType${Date.now()}`;
1889
1889
  if (!window[getCallBackName]) {
1890
1890
  window[getCallBackName] = (res) => {
1891
1891
  try {
1892
1892
  const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
1893
1893
  const { status, data, msg } = getResJson;
1894
1894
  console.log(`获取松果app展示模式成功,返回结果${data}`);
1895
1895
  if (status === '0') {
1896
1896
  this.info.sysInfo.jdAppModeType = data;
1897
1897
  resolve(data);
1898
1898
  } else {
1899
1899
  resolve('0');
1900
1900
  }
1901
1901
  } catch (e) {
1902
1902
  resolve('0');
1903
1903
  }
1904
1904
  window[getCallBackName] = null;
1905
1905
  };
1906
1906
  }
1907
1907
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
1908
1908
  method: 'callSyncRouterModuleWithParams',
1909
1909
  params: JSON.stringify({
1910
1910
  routerURL: 'router://JDBModeModule/getCurrentMode',
1911
1911
  routerParam: {},
1912
1912
  callBackName: `window.${getCallBackName}`,
1913
1913
  callBackId: `${getCallBackName}Ios`,
1914
1914
  }),
1915
1915
  });
1916
1916
  }),
1917
1917
  ]);
1918
1918
  }
1919
1919
  }
1920
1920
  }
1921
1921
  getAPPUseStraightCorner() {
1922
1922
  const routerURL = 'router://JDBaseUtilsModule/isUI14Enable';
1923
1923
  const params = {
1924
1924
  routerURL,
1925
1925
  routerParam: {},
1926
1926
  jdRouter: '1',
1927
1927
  };
1928
1928
  if (this.info.sysInfo.hasOwnProperty('jdStraightCorner')) {
1929
1929
  return Promise.resolve(this.info.sysInfo.jdStraightCorner);
1930
1930
  } else {
1931
1931
  return this.jmfeReayPromise()
1932
1932
  .then(() => {
1933
1933
  if (isJdAndHarmonyDevice || !isJdApp) {
1934
1934
  console.log('not APP or is Harmony');
1935
1935
  return Promise.resolve(false);
1936
1936
  }
1937
1937
  console.log('jmfe setShareInfo', params);
1938
1938
  return Promise.race([
1939
1939
  window.jmfe.callRouter(params),
1940
1940
  this.taskTimeoutPromise(() => {
1941
1941
  return false;
1942
1942
  }),
1943
1943
  ]).then(({ status, data }) => {
1944
1944
  console.log('004 ~ file: index.tsx:133 ~ .then ~ data:', data);
1945
1945
  console.log('004 ~ file: index.tsx:133 ~ .then ~ status:', status);
1946
1946
  this.info.sysInfo.jdStraightCorner = status === '0' && Number(data) === 1;
1947
1947
  return Promise.resolve(status === '0' && Number(data) === 1);
1948
1948
  });
1949
1949
  })
1950
1950
  .catch((e) => {
1951
1951
  console.log('jmfe error', e);
1952
1952
  return Promise.resolve(false);
1953
1953
  });
1954
1954
  }
1955
1955
  }
1956
1956
 
1957
1957
  getJDAppearanceStatePromise() {
1958
1958
  if (this.info.sysInfo.hasOwnProperty('jdAppearanceState')) {
1959
1959
  return Promise.resolve(this.info.sysInfo.jdAppearanceState);
1960
1960
  } else {
1961
1961
  return Promise.race([
1962
1962
  this.taskTimeoutPromise(() => {
1963
1963
  this.info.sysInfo.jdAppearanceState = '0';
1964
1964
  return this.info.sysInfo.jdAppearanceState;
1965
1965
  }),
1966
1966
  new Promise((resolve) => {
1967
1967
  const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`;
1968
1968
  if (!window[getCallBackName]) {
1969
1969
  window[getCallBackName] = (res) => {
1970
1970
  try {
1971
1971
  console.log('getJDAppearanceStatePromise', res);
1972
1972
  const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
1973
1973
  const { status, data, msg } = getResJson;
1974
1974
  console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`);
1975
1975
  if (status === '0') {
1976
1976
  this.info.sysInfo.jdAppearanceState = data;
1977
1977
  resolve(data);
1978
1978
  } else {
1979
1979
  resolve('0');
1980
1980
  }
1981
1981
  } catch (e) {
1982
1982
  resolve('0');
1983
1983
  }
1984
1984
  window[getCallBackName] = null;
1985
1985
  };
1986
1986
  }
1987
1987
  if (isAndroidDevice) {
1988
1988
  const jsonString = JSON.stringify({
1989
1989
  callBackName: `window.${getCallBackName}`,
1990
1990
  });
1991
1991
  console.log('window.JDAppearance', window?.JDAppearance);
1992
1992
  window?.JDAppearance &&
1993
1993
  window?.JDAppearance?.getUiState &&
1994
1994
  window.JDAppearance.getUiState(jsonString);
1995
1995
  } else {
1996
1996
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
1997
1997
  method: 'callSyncRouterModuleWithParams',
1998
1998
  params: JSON.stringify({
1999
1999
  routerURL: 'router://JDWebViewBusinessModule/getJDAppearanceState',
2000
2000
  routerParam: {},
2001
2001
  callBackName: `window.${getCallBackName}`,
2002
2002
  callBackId: `${getCallBackName}Ios`,
2003
2003
  }),
2004
2004
  });
2005
2005
  }
2006
2006
  }),
2007
2007
  ]);
2008
2008
  }
2009
2009
  }
2010
2010
 
2011
2011
  createJdAndroidRquestEventForTouchStart() {
2012
2012
  if (isJdAndAndroidDevice && window?.JdAndroid) {
2013
2013
  const rootEleNode = document.querySelector('body');
2014
2014
  if (rootEleNode) {
2015
2015
  rootEleNode.addEventListener('touchstart', this.jdAndroidAddEventListenerTouchStart, false);
2016
2016
  }
2017
2017
  }
2018
2018
  }
2019
2019
  jdAndroidAddEventListenerTouchStart(e) {
2020
2020
  const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
2021
2021
  if (!isH5SwiperCustomEle && window?.JdAndroid) {
2022
2022
  const hasCustomEle = e
2023
2023
  ? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
2024
2024
  : false;
2025
2025
  if (!hasCustomEle) {
2026
2026
  window?.JdAndroid?.requestEvent && window.JdAndroid.requestEvent(false);
2027
2027
  console.log(
2028
2028
  'createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false',
2029
2029
  );
2030
2030
  }
2031
2031
  }
2032
2032
  }
2033
2033
  removeJdAndroidRquestEventForTouchStart() {
2034
2034
  if (isJdAndAndroidDevice && window.JdAndroid) {
2035
2035
  const rootEleNode = document.querySelector('body');
2036
2036
  if (rootEleNode) {
2037
2037
  rootEleNode.removeEventListener(
2038
2038
  'touchstart',
2039
2039
  this.jdAndroidAddEventListenerTouchStart,
2040
2040
  false,
2041
2041
  );
2042
2042
  }
2043
2043
  }
2044
2044
  }
2045
2045
 
2046
2046
  getNetWorkType() {
2047
2047
  if (isJdApp) {
2048
2048
  this.jmfeReayPromise().then(() => {
2049
2049
  window.jmfe
2050
2050
  .getNetworkStatus()
2051
2051
  .then(({ status, data }) => {
2052
2052
  console.log('在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====', data);
2053
2053
  if (status === '0') {
2054
2054
  this.info.sysInfo['netWorkType'] = data;
2055
2055
  } else {
2056
2056
  this._taroGetNetworkType();
2057
2057
  }
2058
2058
  })
2059
2059
  .catch((err) => {
2060
2060
  console.log('在app内初始化通过jmfe对象获取网络状态异常====', err);
2061
2061
  this._taroGetNetworkType();
2062
2062
  });
2063
2063
  });
2064
2064
  } else {
2065
2065
  this._taroGetNetworkType();
2066
2066
  }
2067
2067
  }
2068
2068
  _taroGetNetworkType() {
2069
2069
  Taro.getNetworkType().then((getRes) => {
2070
2070
  if (getRes && getRes.networkType) {
2071
2071
  this.info.sysInfo['netWorkType'] = getRes.networkType;
2072
2072
  console.log(
2073
2073
  '在app内通过taro对象获取网络状态完成,当前网络状态',
2074
2074
  this.info.sysInfo['netWorkType'],
2075
2075
  );
2076
2076
  }
2077
2077
  });
2078
2078
  }
2079
2079
 
2080
2080
  getJdAppBaseInfo() {
2081
2081
  const appKeyCacheToCookieMinuteTime =
2082
2082
  window?.shopGlobalSwitch?.appKeyCacheToCookieMinuteTime || 0,
2083
2083
  appUuidCacheToCookieMinuteTime =
2084
2084
  window?.shopGlobalSwitch?.appUuidCacheToCookieMinuteTime || 0,
2085
2085
  getAppKey = cookie.get(cacheAppKey),
2086
2086
  getAppUuidKey = cookie.get(cacheAppUuidKey);
2087
2087
  console.log(
2088
2088
  '在app内初始化优先通过cookie获取api请求参数集合baseApiKeyParam',
2089
2089
  cacheAppKey,
2090
2090
  getAppKey,
2091
2091
  cacheAppUuidKey,
2092
2092
  getAppUuidKey,
2093
2093
  );
2094
2094
  if (
2095
2095
  appKeyCacheToCookieMinuteTime &&
2096
2096
  appUuidCacheToCookieMinuteTime &&
2097
2097
  getAppKey &&
2098
2098
  getAppUuidKey
2099
2099
  ) {
2100
2100
  const [uuid, eufv] = getAppUuidKey.split('@');
2101
2101
  const baseApiKeyParam = {
2102
2102
  uuid,
2103
2103
  };
2104
2104
  getAppKey !== '-1000' && (baseApiKeyParam['x_app_key'] = getAppKey);
2105
2105
  if (eufv === '1' && /-/.test(uuid)) {
2106
2106
  const [eu, fv] = uuid.split('-');
2107
2107
  baseApiKeyParam['eu'] = eu;
2108
2108
  baseApiKeyParam['fv'] = fv;
2109
2109
  }
2110
2110
  this.info.sysInfo['baseApiKeyParam'] = baseApiKeyParam;
2111
2111
  this.jmfeReayPromise().then(() => {
2112
2112
  console.log('在app内初始化通过cookie获取api请求参数集合baseApiKeyParam', baseApiKeyParam);
2113
2113
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, baseApiKeyParam);
2114
2114
  });
2115
2115
  } else {
2116
2116
  const checkGetJdAppKeyState =
2117
2117
  window?.shopGlobalSwitch?.getJdAppKeyVersion &&
2118
2118
  jdAppVersionCompare(window?.shopGlobalSwitch?.getJdAppKeyVersion) >= 0;
2119
2119
  this.jmfeReayPromise().then(() => {
2120
2120
  Promise.all([
2121
2121
  checkGetJdAppKeyState && window.jmfe?.callNative
2122
2122
  ? window.jmfe.callNative('SwitchQueryPlugin', 'getAppKey', {}, '0')
2123
2123
  : Promise.resolve({
2124
2124
  status: '-1000',
2125
2125
  msg: '当前版本不支持获取松果app中的getAppKey',
2126
2126
  data: '-1000',
2127
2127
  }),
2128
2128
  window.jmfe.getDeviceInfo(),
2129
2129
  ]).then((resList) => {
2130
2130
  const [getAppKeyRes, deviceInfoRes] = resList;
2131
2131
  console.log(
2132
2132
  '在app内初始化通过jmfe获取getAppKey结果',
2133
2133
  getAppKeyRes,
2134
2134
  '通过jmfe获取getDeviceInfo获取结果',
2135
2135
  deviceInfoRes,
2136
2136
  );
2137
2137
  const baseApiKeyParam = {};
2138
2138
  if (['0', '-1000'].includes(getAppKeyRes?.status) && getAppKeyRes?.data) {
2139
2139
  const getJmfeAppKey = getAppKeyRes?.data;
2140
2140
  if (getJmfeAppKey && getJmfeAppKey !== '') {
2141
2141
  getJmfeAppKey !== '-1000' && (baseApiKeyParam['x_app_key'] = getJmfeAppKey);
2142
2142
  const getJdAppKeyCacheToCookieMinuteTime =
2143
2143
  (window?.shopGlobalSwitch?.appKeyCacheToCookieMinuteTime || 0) * 60 * 1000;
2144
2144
  if (getJdAppKeyCacheToCookieMinuteTime) {
2145
2145
  const expires = new Date(Date.now() + getJdAppKeyCacheToCookieMinuteTime);
2146
2146
  cookie.set(cacheAppKey, getJmfeAppKey, {
2147
2147
  path: '/',
2148
2148
  expires,
2149
2149
  });
2150
2150
  }
2151
2151
  }
2152
2152
  }
2153
2153
  if (deviceInfoRes?.status === '0' && deviceInfoRes?.data) {
2154
2154
  const { uuid, eufv = '0', networkType } = deviceInfoRes?.data;
2155
2155
  if (uuid && uuid !== '') {
2156
2156
  networkType && (this.info.sysInfo['netWorkType'] = networkType);
2157
2157
  baseApiKeyParam['uuid'] = uuid;
2158
2158
  if (eufv === '1' && /-/.test(uuid)) {
2159
2159
  const [eu, fv] = uuid.split('-');
2160
2160
  baseApiKeyParam['eu'] = eu;
2161
2161
  baseApiKeyParam['fv'] = fv;
2162
2162
  }
2163
2163
  const getAppUuidCacheToCookieMinuteTime =
2164
2164
  (window?.shopGlobalSwitch?.appUuidCacheToCookieMinuteTime || 0) * 60 * 1000;
2165
2165
  if (getAppUuidCacheToCookieMinuteTime) {
2166
2166
  const expires = new Date(Date.now() + getAppUuidCacheToCookieMinuteTime);
2167
2167
  cookie.set(cacheAppUuidKey, `${uuid}@${eufv}`, {
2168
2168
  path: '/',
2169
2169
  expires,
2170
2170
  });
2171
2171
  }
2172
2172
  }
2173
2173
  }
2174
2174
  console.log(
2175
2175
  '在app内初始化通过jmfe需要更新的基础api请求参数集合baseApiKeyParam',
2176
2176
  baseApiKeyParam,
2177
2177
  );
2178
2178
  if (Object.keys(baseApiKeyParam).length > 0) {
2179
2179
  this.info.sysInfo['baseApiKeyParam'] = baseApiKeyParam;
2180
2180
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, baseApiKeyParam);
2181
2181
  }
2182
2182
  });
2183
2183
  });
2184
2184
  }
2185
2185
  }
2186
2186
 
2187
2187
  getCacheAddressRouter() {
2188
2188
  if (isJdApp) {
2189
2189
  if (!isJdAndHarmonyDevice) {
2190
2190
  return Promise.race([
2191
2191
  new Promise((resolve) => {
2192
2192
  const getCallBackName = `getJdCacheAddress${Date.now()}`;
2193
2193
  if (!window[getCallBackName]) {
2194
2194
  window[getCallBackName] = (res) => {
2195
2195
  console.warn(`获取松果appGetJdCacheAddressRes,返回结果`, res);
2196
2196
  try {
2197
2197
  const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
2198
2198
  resolve(getResJson);
2199
2199
  } catch (e) {
2200
2200
  resolve({
2201
2201
  status: '-1002',
2202
2202
  msg: '地址信息解析json异常',
2203
2203
  res,
2204
2204
  });
2205
2205
  }
2206
2206
  window[getCallBackName] = null;
2207
2207
  };
2208
2208
  }
2209
2209
  const getRouterParam = {
2210
2210
  sceneId: 'basicShoppingProcess',
2211
2211
  };
2212
2212
  if (isAndroidDevice) {
2213
2213
  return callRouterAndroid({
2214
2214
  routerURL: 'router://JDAddressModule/getCacheAddress',
2215
2215
  routerParam: getRouterParam,
2216
2216
  callBackName: getCallBackName,
2217
2217
  isSync: true,
2218
2218
  });
2219
2219
  } else {
2220
2220
  return callRouterIOS({
2221
2221
  routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
2222
2222
  routerParam: getRouterParam,
2223
2223
  callBackName: getCallBackName,
2224
2224
  });
2225
2225
  }
2226
2226
  }),
2227
2227
  this.taskTimeoutPromise(() => {
2228
2228
  return {
2229
2229
  status: '-1000',
2230
2230
  msg: '原生router协议获取地址信息超时',
2231
2231
  };
2232
2232
  }, 3000),
2233
2233
  ]);
2234
2234
  } else {
2235
2235
  return Promise.race([
2236
2236
  new Promise((resolve) => {
2237
2237
  this.jmfeReayPromise()
2238
2238
  .then(() => {
2239
2239
  const plugin = 'JDHybridRouterPlugin';
2240
2240
  const action = 'callSyncRouterModuleWithParams';
2241
2241
  const params = {
2242
2242
  routerURL: 'router://JDAddressCacheModule/getAddressCache?sceneId=1',
2243
2243
  routerParam: '',
2244
2244
  };
2245
2245
  const sync = '1';
2246
2246
  try {
2247
2247
  window.jmfe.callNative(plugin, action, params, sync).then((res) => {
2248
2248
  resolve(res);
2249
2249
  });
2250
2250
  } catch (error) {
2251
2251
  resolve({
2252
2252
  status: '-1001',
2253
2253
  msg: '判断jmfe不存在,获取经纬度信息异常',
2254
2254
  });
2255
2255
  }
2256
2256
  })
2257
2257
  .catch(() => {
2258
2258
  resolve({
2259
2259
  status: '-1002',
2260
2260
  msg: '鸿蒙系统调用jmfe异常,获取失败',
2261
2261
  });
2262
2262
  });
2263
2263
  }),
2264
2264
  this.taskTimeoutPromise(() => {
2265
2265
  return {
2266
2266
  status: '-1000',
2267
2267
  msg: '原生router协议获取地址信息超时',
2268
2268
  };
2269
2269
  }, 3000),
2270
2270
  ]);
2271
2271
  }
2272
2272
  } else if (isH5AndJingGouMini) {
2273
2273
  const { areaId, addressName } = this.getJingGouMiniInh5Address();
2274
2274
  if (areaId && areaId !== '' && addressName && addressName !== '') {
2275
2275
  return Promise.resolve({
2276
2276
  status: '0',
2277
2277
  data: {
2278
2278
  areaId,
2279
2279
  fullAddress: addressName,
2280
2280
  },
2281
2281
  });
2282
2282
  } else {
2283
2283
  return Promise.resolve({
2284
2284
  status: '-1002',
2285
2285
  msg: '京购内嵌h5h5暂无业务需要,未实现,获取失败',
2286
2286
  });
2287
2287
  }
2288
2288
  } else {
2289
2289
  return Promise.resolve({
2290
2290
  status: '-1002',
2291
2291
  msg: '普通h5暂无业务需要,未实现,获取失败',
2292
2292
  });
2293
2293
  }
2294
2294
  }
2295
2295
 
2296
2296
  getJingGouMiniInh5Address() {
2297
2297
  let getRes: any = {
2298
2298
  areaId: '',
2299
2299
  addressName: '',
2300
2300
  };
2301
2301
  try {
2302
2302
  const getUrlHast = decodeURIComponent(window.location.hash || '');
2303
2303
  const sensMatch = getUrlHast ? getUrlHast.match(/sens=({.*?})/) : null;
2304
2304
  if (sensMatch && sensMatch[1]) {
2305
2305
  const sensData = JSON.parse(sensMatch[1]);
2306
2306
  const getWqAddr = sensData?.wq_addr || '';
2307
2307
  if (getWqAddr && /\|/.test(getWqAddr)) {
2308
2308
  const addressList = getWqAddr.split(/\|/);
2309
2309
  const [addressId, areaId, areaName, addressName, coordinate] = addressList;
2310
2310
  getRes = {
2311
2311
  addressId,
2312
2312
  areaId,
2313
2313
  areaName,
2314
2314
  addressName,
2315
2315
  coordinate,
2316
2316
  };
2317
2317
  }
2318
2318
  }
2319
2319
  } catch (e) {
2320
2320
  console.log('获取hash转换异常', e);
2321
2321
  }
2322
2322
  return getRes;
2323
2323
  }
2324
2324
 
2325
2325
  getAddressCachePromise() {
2326
2326
  return new Promise((resolve) => {
2327
2327
  if (this?.info?.sysInfo?.lat && this?.info?.sysInfo?.lng && this?.info?.sysInfo?.area) {
2328
2328
  resolve({
2329
2329
  lat: this.info.sysInfo.lat,
2330
2330
  lng: this.info.sysInfo.lng,
2331
2331
  area: this?.info?.sysInfo?.area,
2332
2332
  fullAddress: this?.info?.pageInfo?.fullAddress,
2333
2333
  });
2334
2334
  } else {
2335
2335
  this.getCacheAddressRouter()
2336
2336
  .then((res) => {
2337
2337
  const { status, data } = res;
2338
2338
  console.log('原生端获取经纬度及四级地址原始数据结果', status, data, res);
2339
2339
  if (status === '0' && data) {
2340
2340
  const {
2341
2341
  lat,
2342
2342
  latitude,
2343
2343
  lng,
2344
2344
  longitude,
2345
2345
  provinceId,
2346
2346
  cityId,
2347
2347
  countyId,
2348
2348
  townId,
2349
2349
  fullAddress,
2350
2350
  areaId,
2351
2351
  } = data || {};
2352
2352
  const getAreaIdsEnable = areaId && areaId !== '';
2353
2353
  const getEncodeFullAddress = fullAddress ? encodeURIComponent(fullAddress) : '';
2354
2354
  let area = getAreaIdsEnable ? areaId : '';
2355
2355
  this.info.sysInfo['lat'] = `${lat || latitude || ''}`;
2356
2356
  this.info.sysInfo['lng'] = `${lng || longitude || ''}`;
2357
2357
  const getProvinceIdNum = provinceId ? Number(provinceId) : 0;
2358
2358
  if ((getProvinceIdNum && getProvinceIdNum > 0) || getAreaIdsEnable) {
2359
2359
  area = getAreaIdsEnable
2360
2360
  ? areaId
2361
2361
  : `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
2362
2362
  this.info.pageInfo['address'] = area;
2363
2363
  this.info.pageInfo['addressCommaStr'] = area.replace(/_/g, ',');
2364
2364
  this.info.sysInfo['area'] = area;
2365
2365
  const getUpdateData = {
2366
2366
  area: this.info.pageInfo.address,
2367
2367
  };
2368
2368
  if (fullAddress && fullAddress.length > 0) {
2369
2369
  getUpdateData['fullAddress'] = getEncodeFullAddress;
2370
2370
  this.info.pageInfo['fullAddress'] = getEncodeFullAddress;
2371
2371
  }
2372
2372
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, getUpdateData);
2373
2373
  }
2374
2374
  resolve({
2375
2375
  lat: this.info.sysInfo['lat'],
2376
2376
  lng: this.info.sysInfo['lng'],
2377
2377
  fullAddress: getEncodeFullAddress,
2378
2378
  area: area,
2379
2379
  });
2380
2380
  } else {
2381
2381
  if (typeof res === 'object') {
2382
2382
  draBusinessCustomReport({
2383
2383
  eventName: 'business',
2384
2384
  errorName: 'jdapp_getCacheAddress_info_err',
2385
2385
  errorMessage: '松果app内通过router协议获取用户地址及经纬度信息异常',
2386
2386
  extraData: JSON.stringify({
2387
2387
  isJdApp,
2388
2388
  jdAppVersion: jdAppVersionStr,
2389
2389
  ...res,
2390
2390
  }),
2391
2391
  });
2392
2392
  }
2393
2393
  resolve({ lat: '', lng: '', area: '', fullAddress: '' });
2394
2394
  }
2395
2395
  })
2396
2396
  .catch((e) => {
2397
2397
  console.log('getCacheAddressRouter catch e,获取经纬度信息异常e', e);
2398
2398
  draBusinessCustomReport({
2399
2399
  eventName: 'business',
2400
2400
  errorName: 'jdapp_getCacheAddress_info_catch_err',
2401
2401
  errorMessage: '松果app内通过router协议获取用户地址及经纬度信息catch异常',
2402
2402
  extraData: JSON.stringify({
2403
2403
  isJdApp,
2404
2404
  jdAppVersion: jdAppVersionStr,
2405
2405
  }),
2406
2406
  });
2407
2407
  resolve({ lat: '', lng: '', area: '', fullAddress: '' });
2408
2408
  });
2409
2409
  }
2410
2410
  });
2411
2411
  }
2412
2412
 
2413
2413
  getLbsCacheAddressRouter() {
2414
2414
  if (isJdApp) {
2415
2415
  if (!isJdAndHarmonyDevice) {
2416
2416
  return Promise.race([
2417
2417
  new Promise((resolve) => {
2418
2418
  const getCallBackName = `getJdLbsCacheAddress${Date.now()}`;
2419
2419
  if (!window[getCallBackName]) {
2420
2420
  window[getCallBackName] = (res) => {
2421
2421
  console.warn(`获取松果appGetJdLbsCacheAddressRes,返回结果`, res);
2422
2422
  try {
2423
2423
  const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
2424
2424
  resolve(getResJson);
2425
2425
  } catch (e) {
2426
2426
  resolve({
2427
2427
  status: '-1002',
2428
2428
  msg: '地址信息解析json异常',
2429
2429
  res,
2430
2430
  });
2431
2431
  }
2432
2432
  window[getCallBackName] = null;
2433
2433
  };
2434
2434
  }
2435
2435
  const getRouterParam = {
2436
2436
  appid: '219f70bbbf7e4ede7968bedaa1beafb4',
2437
2437
  sceneId: 'basicShoppingProcess',
2438
2438
  };
2439
2439
  if (isAndroidDevice) {
2440
2440
  return callRouterAndroid({
2441
2441
  routerURL: 'router://com.jingdong.app.mall.location.JSLocationManager/getLocation',
2442
2442
  routerParam: getRouterParam,
2443
2443
  callBackName: getCallBackName,
2444
2444
  isSync: true,
2445
2445
  hasJdRouter: false,
2446
2446
  });
2447
2447
  } else {
2448
2448
  return callRouterIOS({
2449
2449
  routerURL: 'router://JDBLBSKitModule/getCacheAddressInfo',
2450
2450
  routerParam: getRouterParam,
2451
2451
  callBackName: getCallBackName,
2452
2452
  isSync: true,
2453
2453
  });
2454
2454
  }
2455
2455
  }),
2456
2456
  this.taskTimeoutPromise(() => {
2457
2457
  return {
2458
2458
  status: '-1000',
2459
2459
  msg: '原生router协议获取lbs地址信息3s超时',
2460
2460
  };
2461
2461
  }, 3000),
2462
2462
  ]);
2463
2463
  } else {
2464
2464
  return Promise.resolve({
2465
2465
  status: '-1001',
2466
2466
  msg: '鸿蒙系统调用未实现,获取失败',
2467
2467
  });
2468
2468
  }
2469
2469
  } else if (isH5AndJingGouMini) {
2470
2470
  return this.getLocationForGpsPromise();
2471
2471
  } else {
2472
2472
  return Promise.resolve({
2473
2473
  status: '-1002',
2474
2474
  msg: '普通h5暂无业务需要,未实现,获取失败',
2475
2475
  });
2476
2476
  }
2477
2477
  }
2478
2478
  getLocationForGpsPromise() {
2479
2479
  return new Promise((resolve) => {
2480
2480
  let hasGetLocationForGps = true;
2481
2481
  if (urlCookie && urlCookie['loc']) {
2482
2482
  const [provinceid = 0, cityid = 0, districtid = 0, townid = 0] =
2483
2483
  urlCookie['loc'].split('_');
2484
2484
  const getProvinceIdNum = provinceid ? Number(provinceid) : 0;
2485
2485
  if (getProvinceIdNum && getProvinceIdNum > 0) {
2486
2486
  hasGetLocationForGps = false;
2487
2487
  resolve({
2488
2488
  status: '0',
2489
2489
  data: {
2490
2490
  provinceid,
2491
2491
  cityid,
2492
2492
  districtid,
2493
2493
  townid,
2494
2494
  origin: 'wxapp',
2495
2495
  },
2496
2496
  });
2497
2497
  }
2498
2498
  }
2499
2499
  if (hasGetLocationForGps && window?.navigator?.geolocation) {
2500
2500
  window.navigator.geolocation.getCurrentPosition(
2501
2501
  (position) => {
2502
2502
  console.log('h5 浏览器通过原生geolocation获取经纬度结果', position?.coords);
2503
2503
  if (position?.coords) {
2504
2504
  resolve({
2505
2505
  status: '0',
2506
2506
  data: {
2507
2507
  srclat: position.coords?.latitude,
2508
2508
  srclng: position.coords.longitude,
2509
2509
  origin: 'h5',
2510
2510
  },
2511
2511
  });
2512
2512
  } else {
2513
2513
  resolve({
2514
2514
  status: '-1001',
2515
2515
  msg: 'h5 浏览器通过原生geolocation获取经纬度结果异常,详情见position',
2516
2516
  position,
2517
2517
  });
2518
2518
  }
2519
2519
  },
2520
2520
  (error) => {
2521
2521
  resolve({
2522
2522
  status: '-1001',
2523
2523
  msg: 'h5 浏览器通过原生geolocation获取经纬度结果定位异常,详情见error',
2524
2524
  error,
2525
2525
  });
2526
2526
  },
2527
2527
  {
2528
2528
  enableHighAccuracy: false,
2529
2529
  timeout: 3 * 1000,
2530
2530
  maximumAge: 10 * 60 * 1000,
2531
2531
  },
2532
2532
  );
2533
2533
  } else {
2534
2534
  resolve({
2535
2535
  status: '-1001',
2536
2536
  msg: '您的浏览器不支持地理定位',
2537
2537
  });
2538
2538
  }
2539
2539
  });
2540
2540
  }
2541
2541
 
2542
2542
  createLbsCacheAddress(realTimeArea) {
2543
2543
  const getLbsAddressCacheMinuteTime = Number(
2544
2544
  window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime || 0,
2545
2545
  );
2546
2546
  console.log(
2547
2547
  '获取lbs缓存到cookie的时间,分钟',
2548
2548
  getLbsAddressCacheMinuteTime,
2549
2549
  'lbsAddressCacheToCookieMinuteTime',
2550
2550
  window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime,
2551
2551
  );
2552
2552
  if (getLbsAddressCacheMinuteTime > 0) {
2553
2553
  const expires = new Date(Date.now() + getLbsAddressCacheMinuteTime * 60 * 1000);
2554
2554
  realTimeArea &&
2555
2555
  cookie.set(cacheH5LbsAddressKey, realTimeArea, {
2556
2556
  path: '/',
2557
2557
  expires,
2558
2558
  });
2559
2559
  }
2560
2560
  }
2561
2561
 
2562
2562
  getLbsAddressCachePromise() {
2563
2563
  if (!this.lbsAddressCachePromise) {
2564
2564
  this.lbsAddressCachePromise = new Promise((resolve) => {
2565
2565
  const getCookieForLbsAddress = window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime
2566
2566
  ? cookie.get(cacheH5LbsAddressKey)
2567
2567
  : '';
2568
2568
  const getUserLbsAddress = this?.info?.pageInfo?.userLbsAddress;
2569
2569
  if (getUserLbsAddress && getUserLbsAddress !== '') {
2570
2570
  resolve({
2571
2571
  ok: true,
2572
2572
  realTimeArea: getUserLbsAddress,
2573
2573
  });
2574
2574
  } else if (getCookieForLbsAddress && getCookieForLbsAddress !== '') {
2575
2575
  console.info(
2576
2576
  `通过cookie获取缓存的userLbsAddress,${window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime}分钟内有效`,
2577
2577
  getCookieForLbsAddress,
2578
2578
  );
2579
2579
  this.info.pageInfo['userLbsAddress'] = getCookieForLbsAddress;
2580
2580
  this.info.sysInfo['realTimeArea'] = getCookieForLbsAddress;
2581
2581
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
2582
2582
  realTimeArea: getCookieForLbsAddress,
2583
2583
  });
2584
2584
  resolve({
2585
2585
  ok: true,
2586
2586
  realTimeArea: getCookieForLbsAddress,
2587
2587
  });
2588
2588
  } else {
2589
2589
  this.getLbsCacheAddressRouter()
2590
2590
  .then((res) => {
2591
2591
  const { status, data } = res;
2592
2592
  console.log(
2593
2593
  '原生或者内嵌京购端获取基于lbs的经纬度及四级地址原始数据结果',
2594
2594
  status,
2595
2595
  data,
2596
2596
  res,
2597
2597
  );
2598
2598
  if (status === '0' && data) {
2599
2599
  const { srclat, srclng, provinceid, cityid, districtid, townid, origin } =
2600
2600
  data || {};
2601
2601
  let realTimeArea = '';
2602
2602
  this.info.sysInfo['srclat'] = `${srclat || ''}`;
2603
2603
  this.info.sysInfo['srclng'] = `${srclng || ''}`;
2604
2604
  const getProvinceIdNum = provinceid ? Number(provinceid) : 0;
2605
2605
  if (getProvinceIdNum && getProvinceIdNum > 0) {
2606
2606
  realTimeArea = `${provinceid}_${cityid || 0}_${districtid || 0}_${townid || 0}`;
2607
2607
  this.info.pageInfo['userLbsAddress'] = realTimeArea;
2608
2608
  this.info.sysInfo['realTimeArea'] = realTimeArea;
2609
2609
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
2610
2610
  realTimeArea: this.info.pageInfo.userLbsAddress,
2611
2611
  });
2612
2612
  this.createLbsCacheAddress(realTimeArea);
2613
2613
  } else {
2614
2614
  !origin && (this.lbsAddressCachePromise = null);
2615
2615
  }
2616
2616
  const getValidRealTimeArea = realTimeArea !== '';
2617
2617
  resolve({
2618
2618
  lat: this.info.sysInfo['srclat'],
2619
2619
  lng: this.info.sysInfo['srclng'],
2620
2620
  realTimeArea: realTimeArea,
2621
2621
  ok: getValidRealTimeArea,
2622
2622
  msg: getValidRealTimeArea
2623
2623
  ? '成功'
2624
2624
  : origin
2625
2625
  ? origin
2626
2626
  : '根据router底层获取lbs地址信息异常,详情见data',
2627
2627
  data: getValidRealTimeArea ? null : res,
2628
2628
  });
2629
2629
  if (!getValidRealTimeArea && !origin) {
2630
2630
  draBusinessCustomReport({
2631
2631
  eventName: 'business',
2632
2632
  errorName: 'h5_getLbsCacheAddress_info_err',
2633
2633
  errorMessage:
2634
2634
  '松果app内通过router协议获取基于lbs实时用户地址及经纬度信息catch异常',
2635
2635
  extraData: JSON.stringify({
2636
2636
  isJdApp,
2637
2637
  jdAppVersion: jdAppVersionStr,
2638
2638
  }),
2639
2639
  });
2640
2640
  }
2641
2641
  } else {
2642
2642
  typeof res === 'object' &&
2643
2643
  draBusinessCustomReport({
2644
2644
  eventName: 'business',
2645
2645
  errorName: 'h5_getLbsCacheAddress_info_err',
2646
2646
  errorMessage:
2647
2647
  'h5通过router协议或者浏览器gps获取基于lbs实时用户缓存地址及经纬度信息异常',
2648
2648
  extraData: JSON.stringify({
2649
2649
  isJdApp,
2650
2650
  jdAppVersion: jdAppVersionStr,
2651
2651
  ...res,
2652
2652
  }),
2653
2653
  });
2654
2654
  this.lbsAddressCachePromise = null;
2655
2655
  resolve({ realTimeArea: '', ok: false });
2656
2656
  }
2657
2657
  })
2658
2658
  .catch((e) => {
2659
2659
  console.log('getLbsAddressCachePromise catch e,获取经纬度信息异常e', e);
2660
2660
  this.lbsAddressCachePromise = null;
2661
2661
  draBusinessCustomReport({
2662
2662
  eventName: 'business',
2663
2663
  errorName: 'h5_getLbsCacheAddress_info_err',
2664
2664
  errorMessage:
2665
2665
  'h5内通过router协议获取浏览器gps获取基于lbs实时用户地址及经纬度信息catch异常',
2666
2666
  extraData: JSON.stringify({
2667
2667
  isJdApp,
2668
2668
  jdAppVersion: jdAppVersionStr,
2669
2669
  }),
2670
2670
  });
2671
2671
  resolve({ realTimeArea: '', ok: false });
2672
2672
  });
2673
2673
  }
2674
2674
  });
2675
2675
  }
2676
2676
  return this.lbsAddressCachePromise;
2677
2677
  }
2678
2678
 
2679
2679
  async updateMPaasConfigAsync(isBeforePageReady: boolean) {
2680
2680
  console.log('updateMPaasConfigAsync isBeforePageReady:', isBeforePageReady);
2681
2681
  if (!isJdApp) {
2682
2682
  return;
2683
2683
  }
2684
2684
  const avifSwitch = await getMPaasConfigByBussinessKey('avifSwitch', isBeforePageReady);
2685
2685
  this.info.sysInfo.dynamicConfig['avifSwitch'] = avifSwitch;
2686
2686
  const hybridHttpSwitch = await getMPaasConfigByBussinessKey(
2687
2687
  'hybridHttpSwitch',
2688
2688
  isBeforePageReady,
2689
2689
  );
2690
2690
  const jshopIsVipShopSwitch = await getMPaasConfigByBussinessKey(
2691
2691
  'jshopIsVipShop',
2692
2692
  isBeforePageReady,
2693
2693
  );
2694
2694
  this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = hybridHttpSwitch;
2695
2695
  this.info.sysInfo.dynamicConfig['jshopIsVipShopSwitch'] = jshopIsVipShopSwitch;
2696
2696
  const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
2697
2697
  'isFollowAppVideoPlayStatus',
2698
2698
  isBeforePageReady,
2699
2699
  );
2700
2700
  console.log(
2701
2701
  'isBeforePageReady:',
2702
2702
  isBeforePageReady,
2703
2703
  'isFollowAppVideoPlayStatus:',
2704
2704
  isFollowAppVideoPlayStatus,
2705
2705
  );
2706
2706
  if (isFollowAppVideoPlayStatus === true || isFollowAppVideoPlayStatus === 'true') {
2707
2707
  this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = true;
2708
2708
  }
2709
2709
  }
2710
2710
 
2711
2711
  async getWifiVideoAutoPlayAsync() {
2712
2712
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
2713
2713
  if (!isJdApp) {
2714
2714
  return;
2715
2715
  }
2716
2716
  const videoPlayStatus = await getWifiVideoAutoPlay().catch((e) => {
2717
2717
  return 0;
2718
2718
  });
2719
2719
  if (Number(videoPlayStatus) === 1) {
2720
2720
  this.info.sysInfo['wifiVideoAutoPlay'] = true;
2721
2721
  }
2722
2722
  }
2723
2723
 
2724
2724
  async getMPaasConfigAsync() {
2725
2725
  this.info.sysInfo.dynamicConfig = {};
2726
2726
  this.info.sysInfo.dynamicConfig['avifSwitch'] = {};
2727
2727
  this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = {};
2728
2728
  this.info.sysInfo.dynamicConfig['jshopIsVipShopSwitch'] = {};
2729
2729
  this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = false;
2730
2730
  return this.updateMPaasConfigAsync(true);
2731
2731
  }
2732
2732
 
2733
2733
  getDynamicConfig(key: string) {
2734
2734
  return this.info.sysInfo?.dynamicConfig?.[key];
2735
2735
  }
2736
2736
  async updateMPaasConfig() {
2737
2737
  console.log('updateMPaasConfig');
2738
2738
  if (
2739
2739
  isIosDevice &&
2740
2740
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
2741
2741
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
2742
2742
  ) {
2743
2743
  try {
2744
2744
  await this.updateMPaasConfigAsync(false);
2745
2745
  } catch (e) {
2746
2746
  console.log('updateMPaasConfigAsync:', e);
2747
2747
  }
2748
2748
  }
2749
2749
  }
2750
2750
 
2751
2751
  toLogin(options) {
2752
2752
  if (isAscfApp) {
2753
2753
  return this.toAscfAppLogin(options);
2754
2754
  }
2755
2755
  return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
2756
2756
  ? this.toWxAppLogin(options)
2757
2757
  : this.toWebLogin(options);
2758
2758
  }
2759
2759
 
2760
2760
  doLogin(options) {
2761
2761
  return this.toLogin(options);
2762
2762
  }
2763
2763
 
2764
2764
  doLoginForJdPin(options = {}) {
2765
2765
  return this.doLogin({
2766
2766
  loginColor: {
2767
2767
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
2768
2768
  dpin: 0,
2769
2769
  },
2770
2770
  ...options,
2771
2771
  });
2772
2772
  }
2773
2773
 
2774
2774
  toWebLogin(options) {
2775
2775
  let params: {
2776
2776
  returnurl: string;
2777
2777
  } = {
2778
2778
  returnurl: '',
2779
2779
  };
2780
2780
  const checkToPcLogin = options ? options?.isPc : isPc;
2781
2781
  const loginUrl = checkToPcLogin
2782
2782
  ? `//passport.jd.com/new/login.aspx`
2783
2783
  : `${domain.mobileLogin}/user/login.action`;
2784
2784
  const defaultParams = {
2785
2785
  appid: '100',
2786
2786
  returnurl: window.location.href,
2787
2787
  };
2788
2788
  if (isString(options)) {
2789
2789
  params = Object.assign({}, defaultParams, {
2790
2790
  returnurl: options,
2791
2791
  });
2792
2792
  } else if (isObject(options)) {
2793
2793
  const { loginColor, ...otherOptions } = options;
2794
2794
  params = Object.assign({}, defaultParams, otherOptions);
2795
2795
  } else {
2796
2796
  params = defaultParams;
2797
2797
  }
2798
2798
  params.returnurl = encodeURIComponent(params.returnurl);
2799
2799
  let getFullUrl = loginUrl + '?' + serialize(params);
2800
2800
  if (checkToPcLogin) {
2801
2801
  getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl');
2802
2802
  }
2803
2803
  return Promise.resolve({
2804
2804
  h5ToUrl: true,
2805
2805
  url: getFullUrl,
2806
2806
  }).then(() => {
2807
2807
  window.location.href = getFullUrl;
2808
2808
  });
2809
2809
  }
2810
2810
 
2811
2811
  toAscfAppLogin(options = {}) {
2812
2812
  console.log('华为元服务中h5登录跳转', options);
2813
2813
  return Promise.resolve(true).then(() => {
2814
2814
  const returnPage = encodeURIComponent(window.location.href);
2815
2815
  if (has && has.ascfweb) {
2816
2816
  has.ascfweb.redirectTo({
2817
2817
  url: `/pages/login/index/index?isH5=1&returnPage=${returnPage}&pageType=h5&source=shopx`,
2818
2818
  });
2819
2819
  }
2820
2820
  });
2821
2821
  }
2822
2822
 
2823
2823
  toWxAppLogin(options = {}) {
2824
2824
  console.log('微信京购小程序中h5登录跳转', options);
2825
2825
  return Promise.resolve(true).then(() => {
2826
2826
  const { loginColor } = Object.assign(
2827
2827
  {},
2828
2828
  {
2829
2829
  loginColor: {
2830
2830
  biz: WXAPP_BIZ_KEY,
2831
2831
  dpin: 1,
2832
2832
  },
2833
2833
  },
2834
2834
  options,
2835
2835
  );
2836
2836
  window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
2837
2837
  loginColor.biz
2838
2838
  }&url=${encodeURIComponent(window.location.href)}`;
2839
2839
  });
2840
2840
  }
2841
2841
 
2842
2842
  getLoginCookie() {
2843
2843
  return Promise.resolve({
2844
2844
  pin: cookie.get('pin') || '',
2845
2845
  });
2846
2846
  }
2847
2847
 
2848
2848
  clearLoginCookie() {
2849
2849
  cookie.remove('pin');
2850
2850
  }
2851
2851
 
2852
2852
  checkStatusAndLogin(options = {}) {
2853
2853
  if (!this.checkStatusAndLoginPromise) {
2854
2854
  this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
2855
2855
  try {
2856
2856
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(options);
2857
2857
  if (getLoginState) {
2858
2858
  resolve(true);
2859
2859
  } else {
2860
2860
  this.toLogin(options);
2861
2861
  reject(false);
2862
2862
  }
2863
2863
  } catch (e) {
2864
2864
  this.toLogin(options);
2865
2865
  reject(false);
2866
2866
  }
2867
2867
  });
2868
2868
  return this.checkStatusAndLoginPromise;
2869
2869
  } else {
2870
2870
  return this.checkStatusAndLoginPromise
2871
2871
  .then(() => {
2872
2872
  return Promise.resolve(true);
2873
2873
  })
2874
2874
  .catch(() => {
2875
2875
  this.toLogin(options);
2876
2876
  return Promise.reject(true);
2877
2877
  });
2878
2878
  }
2879
2879
  }
2880
2880
 
2881
2881
  checkJdStatusAndLogin(
2882
2882
  options = {
2883
2883
  loginColor: {
2884
2884
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
2885
2885
  dpin: 0,
2886
2886
  },
2887
2887
  },
2888
2888
  ) {
2889
2889
  return this.checkStatusAndLogin(options);
2890
2890
  }
2891
2891
 
2892
2892
  doCheckLoginStateAndForApiCheck(options) {
2893
2893
  if (this.info.loginState) {
2894
2894
  return Promise.resolve(true);
2895
2895
  } else {
2896
2896
  return new Promise((resolve, reject) => {
2897
2897
  if (this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState) {
2898
2898
  const getWqAuthToken = cookie.get('wq_auth_token');
2899
2899
  const getWqSkey = cookie.get('wq_skey');
2900
2900
  const getWqUin = cookie.get('wq_uin');
2901
2901
  const isLoginState =
2902
2902
  options?.loginColor?.dpin === 0 ? getWqAuthToken : getWqSkey && getWqUin;
2903
2903
  if (isLoginState) {
2904
2904
  this.info.loginState = true;
2905
2905
  resolve(true);
2906
2906
  } else {
2907
2907
  reject(false);
2908
2908
  }
2909
2909
  } else {
2910
2910
  Taro.request({
2911
2911
  url: api.isLogin,
2912
2912
  jsonp: true,
2913
2913
  timeout: 3000,
2914
2914
  success: (res) => {
2915
2915
  const { statusCode, data } = res;
2916
2916
  if (statusCode === 200 && data?.islogin && Number(data.islogin) === 1) {
2917
2917
  this.info.loginState = true;
2918
2918
  resolve(true);
2919
2919
  } else {
2920
2920
  reject(false);
2921
2921
  }
2922
2922
  },
2923
2923
  fail: (err) => {
2924
2924
  console.log('登录检查异常', err);
2925
2925
  reject(false);
2926
2926
  },
2927
2927
  });
2928
2928
  }
2929
2929
  });
2930
2930
  }
2931
2931
  }
2932
2932
 
2933
2933
  checkLoginStatus(options) {
2934
2934
  return new Promise(async (resolve, reject) => {
2935
2935
  try {
2936
2936
  const getLoginState = await this.doCheckLoginStateAndForApiCheck(options);
2937
2937
  if (getLoginState) {
2938
2938
  const { pin } = await this.getLoginCookie();
2939
2939
  this.info.userInfo = {
2940
2940
  pin,
2941
2941
  encodePin: encodeURIComponent(pin),
2942
2942
  ptkey: '',
2943
2943
  };
2944
2944
  resolve(true);
2945
2945
  } else {
2946
2946
  reject(false);
2947
2947
  }
2948
2948
  } catch (e) {
2949
2949
  reject(false);
2950
2950
  }
2951
2951
  });
2952
2952
  }
2953
2953
 
2954
2954
  updatePageAndLogInfo(updateQuery = {}) {
2955
2955
  const createUpdateQueryInfo: {
2956
2956
  query: {
2957
2957
  shopId?: string | number;
2958
2958
  venderId?: string | number;
2959
2959
  };
2960
2960
  updateShopInfoState: boolean;
2961
2961
  } = Object.assign(
2962
2962
  {},
2963
2963
  {
2964
2964
  query: {},
2965
2965
  updateShopInfoState: false,
2966
2966
  },
2967
2967
  updateQuery,
2968
2968
  );
2969
2969
  console.log(
2970
2970
  '获取当前下发的店铺查询参数',
2971
2971
  updateQuery,
2972
2972
  '获取之前保存的shopInfo店铺查询参数',
2973
2973
  this.info?.shopInfo,
2974
2974
  );
2975
2975
  const { query, updateShopInfoState } = createUpdateQueryInfo;
2976
2976
  const { shopId, venderId, un_area } = query;
2977
2977
  if (updateShopInfoState) {
2978
2978
  this.info.queryInfo = {
2979
2979
  ...this.info.queryInfo,
2980
2980
  ...query,
2981
2981
  };
2982
2982
  if (shopId && venderId) {
2983
2983
  this.info.shopInfo = {
2984
2984
  shopId: `${shopId}`,
2985
2985
  venderId: `${venderId}`,
2986
2986
  };
2987
2987
  }
2988
2988
  } else {
2989
2989
  this.info.queryInfo = {
2990
2990
  ...query,
2991
2991
  };
2992
2992
  if (
2993
2993
  this.info.shopInfo?.shopId &&
2994
2994
  this.info.shopInfo?.venderId &&
2995
2995
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
2996
2996
  ) {
2997
2997
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
2998
2998
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
2999
2999
  console.log(
3000
3000
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
3001
3001
  this.info.queryInfo,
3002
3002
  );
3003
3003
  }
3004
3004
  }
3005
3005
  this.info.queryInfo['shopId'] &&
3006
3006
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
3007
3007
  this.info.queryInfo['venderId'] &&
3008
3008
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
3009
3009
  console.log(
3010
3010
  'h5==获取店铺下发查询参数\n',
3011
3011
  query,
3012
3012
  '\n获取店铺最后查询参数\n',
3013
3013
  this.info.queryInfo,
3014
3014
  '\n是否为更新店铺状态\n',
3015
3015
  updateShopInfoState,
3016
3016
  );
3017
3017
  const changeArea = un_area && un_area.length > 0 ? un_area : isPc && ipLoc_djd ? ipLoc_djd : '';
3018
3018
  if (changeArea) {
3019
3019
  const getBottomAreaStr = changeArea.replace(/-/g, '_');
3020
3020
  this.info.pageInfo.address = getBottomAreaStr;
3021
3021
  this.info.pageInfo.un_area = getBottomAreaStr;
3022
3022
  this.info.pageInfo.addressCommaStr = getBottomAreaStr.replace(/_/g, ',');
3023
3023
  }
3024
3024
  }
3025
3025
 
3026
3026
  dealLoadSdkList() {
3027
3027
  const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
3028
3028
  const businessLoadJsList = window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? [];
3029
3029
  const concatLoadJsList = [].concat(globalLoadJsList, businessLoadJsList);
3030
3030
  let mergeLoadJsList = globalLoadJsList;
3031
3031
  try {
3032
3032
  mergeLoadJsList = concatLoadJsList.reduce((accArr: any[], current: any) => {
3033
3033
  const getFindIndex = accArr.findIndex((item) => item?.fileName === current?.fileName);
3034
3034
  getFindIndex !== -1
3035
3035
  ? (accArr[getFindIndex] = { ...accArr[getFindIndex], ...current })
3036
3036
  : accArr.push(current);
3037
3037
  return accArr;
3038
3038
  }, []);
3039
3039
  } catch (e) {
3040
3040
  console.log('LoadJsList合并错误', e);
3041
3041
  }
3042
3042
  console.log(
3043
3043
  'globalLoadJsList',
3044
3044
  globalLoadJsList,
3045
3045
  'businessLoadJsList',
3046
3046
  businessLoadJsList,
3047
3047
  '两个加载jsList集合合并完成',
3048
3048
  mergeLoadJsList,
3049
3049
  );
3050
3050
  this.loadJsSdkList = mergeLoadJsList;
3051
3051
  return this.loadJsSdkList;
3052
3052
  }
3053
3053
 
3054
3054
  renderNextTickLoadSdk(delayTime = 1000) {
3055
3055
  Taro.nextTick(() => {
3056
3056
  console.log(
3057
3057
  '页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s=======',
3058
3058
  );
3059
3059
  setTimeout(() => {
3060
3060
  this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK, this.loadJsSdkList);
3061
3061
  }, delayTime);
3062
3062
  });
3063
3063
  }
3064
3064
 
3065
3065
  async loadOtherSdk(triggerType = LoadJsInitTriggerType.NOW, loadJsList: any[] = []) {
3066
3066
  const getLoadJsList =
3067
3067
  Array.isArray(loadJsList) && loadJsList.length > 0 ? loadJsList : this.dealLoadSdkList();
3068
3068
  const getLoadFilterList = getLoadJsList.filter((item) => {
3069
3069
  if (isJdAndHarmonyDevice && item.fileName === 'addCartJs') {
3070
3070
  item.initLoadType = undefined;
3071
3071
  }
3072
3072
  const getInitLoadEnvType = item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL;
3073
3073
  let getLoastLoadEventState = true;
3074
3074
  if (getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP) {
3075
3075
  getLoastLoadEventState = isJdApp;
3076
3076
  }
3077
3077
  else if (getInitLoadEnvType === LoadJsInitLoadEnvType.M) {
3078
3078
  getLoastLoadEventState = !isJdApp || !!isJdAndHarmonyDevice;
3079
3079
  }
3080
3080
  const getInitTriggerType =
3081
3081
  isJdApp && item?.initJdAppTriggerType
3082
3082
  ? item?.initTriggerType
3083
3083
  : item?.initTriggerType || LoadJsInitTriggerType.NOW;
3084
3084
  const getInitLinkTriggerWay = window?.PAGE_DATA[item?.initLinkTriggerWay] || false;
3085
3085
  return getLoastLoadEventState && getInitTriggerType === triggerType && getInitLinkTriggerWay;
3086
3086
  });
3087
3087
  console.log(
3088
3088
  '获取当前触发方式',
3089
3089
  triggerType,
3090
3090
  '获取当前最后加载的js集合',
3091
3091
  getLoadFilterList,
3092
3092
  '过滤前的加载集合',
3093
3093
  getLoadJsList,
3094
3094
  );
3095
3095
  const loadTasks =
3096
3096
  getLoadFilterList.length > 0
3097
3097
  ? getLoadFilterList.map((item) => {
3098
3098
  const isLoadState = /sgm/.test(item?.fileName)
3099
3099
  ? window?.shopGlobalSwitch?.openSgm === 'true'
3100
3100
  : true;
3101
3101
  if (!isLoadState) {
3102
3102
  return Promise.resolve(true);
3103
3103
  }
3104
3104
  return this.loadItemSdkPromise(item)
3105
3105
  .then((res) => {
3106
3106
  console.info('当前js地址' + item?.src, '加载状态', res);
3107
3107
  const isFileNameNewDraSdkJs = res?.fileName === 'newDraSdkJs';
3108
3108
  if (isFileNameNewDraSdkJs && window?.dra?.run) {
3109
3109
  const getNewdraEnableShopIdPercentObj =
3110
3110
  window?.PAGE_DATA?.businessData?.newDraEnableShopIdPercent || null;
3111
3111
  const getNewdraEnableVenderIdPercentObj =
3112
3112
  window?.PAGE_DATA?.businessData?.newDraEnableVenderIdPercent || null;
3113
3113
  let canInitDraRun = true;
3114
3114
  if (getNewdraEnableShopIdPercentObj || getNewdraEnableVenderIdPercentObj) {
3115
3115
  canInitDraRun = this.shouldPercentExecuteNewDra(
3116
3116
  this.getNewDraEnablePercentNum(),
3117
3117
  );
3118
3118
  }
3119
3119
  if (canInitDraRun) {
3120
3120
  window.dra.run('init', { aid: res?.aid });
3121
3121
  window.dra.run('start');
3122
3122
  }
3123
3123
  }
3124
3124
  return true;
3125
3125
  })
3126
3126
  .catch((err) => {
3127
3127
  console.info('当前js地址加载异常', item?.src);
3128
3128
  window?.fetchErrorData &&
3129
3129
  window.fetchErrorData({
3130
3130
  title: '公共js加载异常',
3131
3131
  type: 'jsLoad',
3132
3132
  data: err,
3133
3133
  });
3134
3134
  return true;
3135
3135
  });
3136
3136
  })
3137
3137
  : [];
3138
3138
  return loadTasks.length ? Promise.allSettled(loadTasks) : Promise.resolve([]);
3139
3139
  }
3140
3140
 
3141
3141
  shouldPercentExecuteNewDra(percent) {
3142
3142
  if (percent <= 0) return false;
3143
3143
  if (percent >= 100) return true;
3144
3144
  const getRes = Math.random() < percent / 100;
3145
3145
  console.log('获取dra初始化执行的概率为', percent, '执行结果', getRes);
3146
3146
  return getRes;
3147
3147
  }
3148
3148
 
3149
3149
  getNewDraEnablePercentNum() {
3150
3150
  const getNewdraEnableShopIdPercent =
3151
3151
  window?.PAGE_DATA?.businessData?.newDraEnableShopIdPercent || {};
3152
3152
  const getNewdraEnableVenderIdPercent =
3153
3153
  window?.PAGE_DATA?.businessData?.newDraEnableVenderIdPercent || {};
3154
3154
  const getShopId = parseQueryUrlObj?.shopId || '';
3155
3155
  const getVenderId = parseQueryUrlObj?.venderId || '';
3156
3156
  const getShopIdDraEnablePercent = getNewdraEnableShopIdPercent[getShopId]
3157
3157
  ? getNewdraEnableShopIdPercent[getShopId]
3158
3158
  : getNewdraEnableShopIdPercent?.ids?.includes(getShopId)
3159
3159
  ? getNewdraEnableShopIdPercent?.idsNumber
3160
3160
  : -1;
3161
3161
  const getVenderIdDraEnablePercent = getNewdraEnableVenderIdPercent[getVenderId]
3162
3162
  ? getNewdraEnableVenderIdPercent[getVenderId]
3163
3163
  : getNewdraEnableVenderIdPercent?.ids?.includes(getVenderId)
3164
3164
  ? getNewdraEnableVenderIdPercent?.idsNumber
3165
3165
  : -1;
3166
3166
  if (getShopIdDraEnablePercent > -1 || getVenderIdDraEnablePercent > -1) {
3167
3167
  return getShopIdDraEnablePercent || getVenderIdDraEnablePercent;
3168
3168
  }
3169
3169
  return 100;
3170
3170
  }
3171
3171
  loadScriptEle(jsInfo, resolve, reject) {
3172
3172
  const getFileName = jsInfo?.fileName;
3173
3173
  if (getFileName) {
3174
3174
  const getEleId = `J_loadJs_${getFileName}`;
3175
3175
  const getEle = document.getElementById(getEleId);
3176
3176
  if (!getEle) {
3177
3177
  const jsLoadErrorSgmCode = `jsLoadError_${jsInfo?.fileName || 'customJs'}`;
3178
3178
  const _sgmEle = document.createElement('script');
3179
3179
  _sgmEle.id = getEleId;
3180
3180
  _sgmEle.onload = function () {
3181
3181
  resolve({
3182
3182
  ...jsInfo,
3183
3183
  jsTip: 'js加载成功',
3184
3184
  });
3185
3185
  };
3186
3186
  _sgmEle.onerror = function () {
3187
3187
  reject({
3188
3188
  ...jsInfo,
3189
3189
  env: getSgmCustomCode(jsLoadErrorSgmCode),
3190
3190
  jsReqError: '当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误',
3191
3191
  });
3192
3192
  };
3193
3193
  const dataAttrList = ['timeout', 'fileName', 'env'];
3194
3194
  const getJsInfoKeyList = Object.keys(jsInfo);
3195
3195
  getJsInfoKeyList.forEach((key) => {
3196
3196
  if (key === 'async') {
3197
3197
  _sgmEle.async = jsInfo[key];
3198
3198
  } else if (key === 'crossOrigin') {
3199
3199
  _sgmEle.crossOrigin = jsInfo[key];
3200
3200
  } else if (key === 'src') {
3201
3201
  _sgmEle.src = `${jsInfo[key]}`;
3202
3202
  } else if (dataAttrList.includes(key) || /init/.test(key)) {
3203
3203
  _sgmEle.setAttribute(`data-${key}`, jsInfo[key]);
3204
3204
  } else {
3205
3205
  _sgmEle.setAttribute(key, jsInfo[key]);
3206
3206
  }
3207
3207
  });
3208
3208
  document.head.appendChild(_sgmEle);
3209
3209
  } else {
3210
3210
  console.log(`当前${jsInfo?.fileName || 'js'}已经存在页面中,可以直接调用相关方法`, jsInfo);
3211
3211
  resolve({
3212
3212
  ...jsInfo,
3213
3213
  jsTip: 'js本身已存在页面中',
3214
3214
  });
3215
3215
  }
3216
3216
  } else {
3217
3217
  console.warn('当前js资源信息缺少必要的参数fileName,请关注', jsInfo);
3218
3218
  }
3219
3219
  }
3220
3220
 
3221
3221
  loadItemSdkPromise(jsInfo: Record<string, any> = {}): Promise<any> {
3222
3222
  if (jsInfo?.src) {
3223
3223
  const getInitLoadType =
3224
3224
  isJdApp && jsInfo?.initJdAppLoadType
3225
3225
  ? jsInfo?.initJdAppLoadType
3226
3226
  : jsInfo?.initLoadType || LoadJsInitLoadType.ALL;
3227
3227
  if (getInitLoadType !== LoadJsInitLoadType.NONE) {
3228
3228
  const getFileKeyName = jsInfo?.fileName || jsInfo?.src;
3229
3229
  if (!this.loadJsSdkListCachePromise[getFileKeyName]) {
3230
3230
  if (getInitLoadType !== LoadJsInitLoadType.INSERT_ELE) {
3231
3231
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve, reject) => {
3232
3232
  const jsLoadErrorSgmCode = `jsLoadError_${jsInfo?.fileName || 'customJs'}`;
3233
3233
  try {
3234
3234
  const jsXhrRequest = new XMLHttpRequest();
3235
3235
  jsXhrRequest.timeout = jsInfo?.timeout ?? 2000;
3236
3236
  const jsUrl = `${jsInfo?.src}`;
3237
3237
  jsXhrRequest.open('GET', jsUrl, true);
3238
3238
  jsXhrRequest.onreadystatechange = () => {
3239
3239
  if (jsXhrRequest.readyState === 4) {
3240
3240
  const getReqStatus = jsXhrRequest.status;
3241
3241
  const statusText = jsXhrRequest.statusText;
3242
3242
  if ((getReqStatus >= 200 && getReqStatus < 300) || getReqStatus === 304) {
3243
3243
  const getInsetHeadState = getInitLoadType === LoadJsInitLoadType.ALL;
3244
3244
  if (getInsetHeadState) {
3245
3245
  this.loadScriptEle(jsInfo, resolve, reject);
3246
3246
  } else {
3247
3247
  resolve({
3248
3248
  ...jsInfo,
3249
3249
  jsTip: 'js请求成功,暂未插入head节点,业务自行单独插入',
3250
3250
  });
3251
3251
  }
3252
3252
  getReqStatus !== 200 &&
3253
3253
  draBusinessCustomReport({
3254
3254
  eventName: 'business',
3255
3255
  errorName: 'js_load_special_code',
3256
3256
  errorMessage: '当前js加载成功,状态非200,特殊上报观察',
3257
3257
  extraData: JSON.stringify({
3258
3258
  msg: '当前js加载成功,状态非200,特殊上报观察',
3259
3259
  jsReqState: getReqStatus,
3260
3260
  env: getSgmCustomCode('js_load_special_code'),
3261
3261
  data: jsInfo,
3262
3262
  }),
3263
3263
  });
3264
3264
  } else {
3265
3265
  const getRes = {
3266
3266
  ...jsInfo,
3267
3267
  env: getSgmCustomCode(jsLoadErrorSgmCode),
3268
3268
  jsReqError: `请求状态异常,状态码为${getReqStatus},statusText:${statusText}`,
3269
3269
  jsReqState: getReqStatus,
3270
3270
  };
3271
3271
  console.log('当前js请求状态异常,具体信息见', getRes);
3272
3272
  reject(getRes);
3273
3273
  }
3274
3274
  }
3275
3275
  };
3276
3276
  jsXhrRequest.onerror = () => {
3277
3277
  const getRes = {
3278
3278
  ...jsInfo,
3279
3279
  env: getSgmCustomCode(jsLoadErrorSgmCode),
3280
3280
  jsReqError: '请求错误',
3281
3281
  };
3282
3282
  console.log('当前js请求错误', getRes);
3283
3283
  jsXhrRequest.abort();
3284
3284
  reject(getRes);
3285
3285
  };
3286
3286
  jsXhrRequest.ontimeout = () => {
3287
3287
  const getRes = {
3288
3288
  ...jsInfo,
3289
3289
  env: getSgmCustomCode(jsLoadErrorSgmCode),
3290
3290
  jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
3291
3291
  jsReqState: jsXhrRequest.status,
3292
3292
  };
3293
3293
  console.log('当前js请求超时异常', getRes);
3294
3294
  jsXhrRequest.abort();
3295
3295
  reject(getRes);
3296
3296
  };
3297
3297
  jsXhrRequest.send();
3298
3298
  } catch (e) {
3299
3299
  console.log('执行js请求异常', e);
3300
3300
  reject({
3301
3301
  ...jsInfo,
3302
3302
  env: getSgmCustomCode(jsLoadErrorSgmCode),
3303
3303
  jsReqError: '未知异常',
3304
3304
  error: e,
3305
3305
  });
3306
3306
  }
3307
3307
  });
3308
3308
  } else {
3309
3309
  this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve, reject) => {
3310
3310
  return this.loadScriptEle(jsInfo, resolve, reject);
3311
3311
  });
3312
3312
  }
3313
3313
  }
3314
3314
  return this.loadJsSdkListCachePromise[getFileKeyName];
3315
3315
  } else {
3316
3316
  return Promise.resolve({
3317
3317
  ...jsInfo,
3318
3318
  jsTip: 'js加载方式设置为不加载,当前不做处理',
3319
3319
  });
3320
3320
  }
3321
3321
  } else {
3322
3322
  return Promise.reject(jsInfo);
3323
3323
  }
3324
3324
  }
3325
3325
 
3326
3326
  createLanguagePromise() {
3327
3327
  const getLanguageConfig = window?.shopGlobalSwitch?.language || {};
3328
3328
  if (!this.languageCacheProimse) {
3329
3329
  this.languageCacheProimse = new Promise((resolve, reject) => {
3330
3330
  const { fileName, prefixUrl } = getLanguageConfig;
3331
3331
  console.log('getLanguageConfig', getLanguageConfig, 'languageNowType', languageNowType);
3332
3332
  const dealLanguageFile = () => {
3333
3333
  this.getLanguageFilePromise(getLanguageConfig, languageNowType)
3334
3334
  .then((res: any) => {
3335
3335
  if (res && res?.data) {
3336
3336
  this.languageJsonData = res.data;
3337
3337
 
3338
3338
  setTimeout(() => {
3339
3339
  const getOtherLanguageList = languageTypeList.filter(
3340
3340
  (item) => item !== languageNowType,
3341
3341
  );
3342
3342
  getOtherLanguageList.length > 0 &&
3343
3343
  getOtherLanguageList.map((languageTypeKey) => {
3344
3344
  this.getLanguageFilePromise(getLanguageConfig, languageTypeKey);
3345
3345
  });
3346
3346
  }, 3000);
3347
3347
  resolve(res);
3348
3348
  } else {
3349
3349
  reject(res);
3350
3350
  }
3351
3351
  })
3352
3352
  .catch((err) => {
3353
3353
  reject(err);
3354
3354
  });
3355
3355
  };
3356
3356
  if (fileName && prefixUrl) {
3357
3357
  const getLangStorageKey = `jshopx_lang_${languageNowType}`;
3358
3358
  const getLocalLangRes = getTaroStorageKeyValue(getLangStorageKey);
3359
3359
  if (getLocalLangRes) {
3360
3360
  try {
3361
3361
  const getLocalLangJsonData =
3362
3362
  typeof getLocalLangRes === 'string' ? JSON.parse(getLocalLangRes) : getLocalLangRes;
3363
3363
  if (getLocalLangJsonData?.fileName && getLocalLangJsonData?.data) {
3364
3364
  if (getLocalLangJsonData?.fileName === fileName) {
3365
3365
  const geThisLangData = getLocalLangJsonData.data;
3366
3366
  this.languageJsonData = geThisLangData;
3367
3367
  return resolve({
3368
3368
  ...getLanguageConfig,
3369
3369
  languageNowType,
3370
3370
  data: geThisLangData,
3371
3371
  });
3372
3372
  } else {
3373
3373
  dealLanguageFile();
3374
3374
  }
3375
3375
  } else {
3376
3376
  dealLanguageFile();
3377
3377
  }
3378
3378
  } catch (e) {
3379
3379
  return reject({
3380
3380
  languageNowType,
3381
3381
  msg: '转换错误',
3382
3382
  ...getLanguageConfig,
3383
3383
  });
3384
3384
  }
3385
3385
  } else {
3386
3386
  dealLanguageFile();
3387
3387
  }
3388
3388
  } else {
3389
3389
  return reject({
3390
3390
  languageNowType,
3391
3391
  msg: '文件对象下发异常',
3392
3392
  ...getLanguageConfig,
3393
3393
  });
3394
3394
  }
3395
3395
  });
3396
3396
  }
3397
3397
  return this.languageCacheProimse;
3398
3398
  }
3399
3399
 
3400
3400
  getLanguageFilePromise(info, languageTypeKey) {
3401
3401
  const { fileName, prefixUrl, timeout } = info || {};
3402
3402
  const getUrl = `${prefixUrl}${fileName}_${languageTypeKey}.json`;
3403
3403
  return new Promise((resolve, reject) => {
3404
3404
  const langLoadErrorSgmCode = `languageLoadError_${fileName || 'lang.json'}`;
3405
3405
  try {
3406
3406
  const langXhrRequest = new XMLHttpRequest();
3407
3407
  langXhrRequest.timeout = timeout || 2000;
3408
3408
  langXhrRequest.open('GET', getUrl, true);
3409
3409
  langXhrRequest.responseType = 'json';
3410
3410
  langXhrRequest.onreadystatechange = () => {
3411
3411
  if (langXhrRequest.readyState === 4) {
3412
3412
  const getReqStatus = langXhrRequest.status;
3413
3413
  const statusText = langXhrRequest.statusText;
3414
3414
  if ((getReqStatus >= 200 && getReqStatus < 300) || getReqStatus === 304) {
3415
3415
  const getData = langXhrRequest?.response || false;
3416
3416
  if (getData) {
3417
3417
  setTaroStorage(`jshopx_lang_${languageTypeKey}`, {
3418
3418
  fileName,
3419
3419
  data: getData,
3420
3420
  });
3421
3421
  resolve({
3422
3422
  ...info,
3423
3423
  languageTypeKey,
3424
3424
  data: getData,
3425
3425
  });
3426
3426
  } else {
3427
3427
  reject({
3428
3428
  ...info,
3429
3429
  languageTypeKey,
3430
3430
  msg: '数据获取异常',
3431
3431
  });
3432
3432
  }
3433
3433
  } else {
3434
3434
  const getRes = {
3435
3435
  ...info,
3436
3436
  languageTypeKey,
3437
3437
  env: getSgmCustomCode(langLoadErrorSgmCode),
3438
3438
  msg: `请求状态异常,状态码为${getReqStatus},statusText:${statusText}`,
3439
3439
  };
3440
3440
  console.log('当前lang请求状态异常,具体信息见', getRes);
3441
3441
  reject(getRes);
3442
3442
  }
3443
3443
  }
3444
3444
  };
3445
3445
  langXhrRequest.onerror = () => {
3446
3446
  const getRes = {
3447
3447
  ...info,
3448
3448
  env: getSgmCustomCode(langLoadErrorSgmCode),
3449
3449
  msg: '请求错误',
3450
3450
  };
3451
3451
  console.log('当前lang请求错误', getRes);
3452
3452
  langXhrRequest.abort();
3453
3453
  reject(getRes);
3454
3454
  };
3455
3455
  langXhrRequest.ontimeout = () => {
3456
3456
  const getRes = {
3457
3457
  ...info,
3458
3458
  msg: `请求${langXhrRequest.timeout}ms超时异常,状态${langXhrRequest.status}`,
3459
3459
  };
3460
3460
  console.log('执行lang多语言请求超时异常', getRes);
3461
3461
  langXhrRequest.abort();
3462
3462
  reject(getRes);
3463
3463
  };
3464
3464
  langXhrRequest.send();
3465
3465
  } catch (e) {
3466
3466
  console.log('执行lang多语言请求异常', e);
3467
3467
  reject({
3468
3468
  ...info,
3469
3469
  env: getSgmCustomCode(langLoadErrorSgmCode),
3470
3470
  msg: '未知异常',
3471
3471
  error: e,
3472
3472
  });
3473
3473
  }
3474
3474
  });
3475
3475
  }