@conecli/cone-render 0.10.1-shop-beta.13 → 0.10.1-shop-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro';
2
1
  stopNativeScrollEvent,
3
2
  getAppChannelType,
4
3
  isAndroidDevice,
5
4
  isHarmonyDevice,
6
5
  isH5AndJdShopView,
7
6
  isChartH5,
8
7
  isH5AndJdShopViewNativeScroll,
9
8
  isIosDevice,
10
9
  isJdAndAndroidDevice,
11
10
  isJdAndIosDevice,
12
11
  isJdApp,
13
12
  isWxApp,
14
13
  isWxMiniH5View,
15
14
  isJdAndHarmonyDevice,
16
15
  isNewHarmonyShop,
17
16
  isH5AndJingGouMini,
18
17
  urlCookie,
19
18
  sgmCustomReport,
20
19
  draCustomReport,
21
20
  remoteCustomReport,
22
21
  draInterfaceCustomReport,
23
22
  draBusinessCustomReport,
24
23
  draBusinessCustomLogReport,
25
24
  isMemberPage,
26
25
  isH5AndJdShopViewH5Scroll,
27
26
  isH5AndJdShopH5CustomScrollView,
28
27
  isAppClassifyPage,
29
28
  isAppHomeForMarketPage,
30
29
  isPc,
31
30
  ipLoc_djd,
32
31
  jdAppVersionCompare,
33
32
  isTjScence,
34
33
  isH5AdnJxMini,
35
34
  isTjM,
36
35
  isTjJxM,
37
36
  isTJApp,
38
37
  isH5AdnHaoWuJie,
39
38
  tjChannel,
40
39
  dealNativePixelToCssPixel,
41
40
  isAppStowShop,
42
41
  isJdAndroidX5Core,
43
42
  parseQueryUrlObj,
44
43
  isIpadDevice,
45
44
  isTabletDevice,
46
45
  checkPadScreenOrientationIsLandscape,
47
46
  isSupportHybridHttpRequest,
48
47
  isLanguageForEn,
49
48
  sColor,
50
49
  draInterfaceDSMCustomReport,
51
50
  isInJdShopView,
52
51
  isDongWebView,
53
52
  isLanguageForHk,
54
53
  languageNowType,
55
54
  addHttps,
56
55
  clearTaroStorageKey,
57
56
  countStringify as h5CountStringify,
58
57
  dateFormat,
59
58
  dealAddress,
60
59
  dealShopContentData as originDealShopContentData,
61
60
  debounce,
62
61
  filterUrlQueryData,
63
62
  formatTabActiveMenuType,
64
63
  getAvifSupport,
65
64
  getWebpSupport,
66
65
  getTaroStorageKeyValue,
67
66
  getWxAppCookieStr,
68
67
  isH5,
69
68
  isDynamic,
70
69
  isMin,
71
70
  isJdMin,
72
71
  isWxMin,
73
72
  isWxMinAndWxapp,
74
73
  isJdMinAndHarmony,
75
74
  lodashThrottle,
76
75
  objectToUrlEncode,
77
76
  parseQueryUrlString,
78
77
  removeTaroStorageKey,
79
78
  setLowSmallPicUrl,
80
79
  setTaroStorage,
81
80
  showFailToast,
82
81
  showNormalToast,
83
82
  showSuccessToast,
84
83
  sliceArrToChunkList,
85
84
  throttle,
86
85
  getQualityImageNew,
87
86
  getQualityImageOld,
88
87
  isOpenJdAppUrl,
89
88
  jdOpenAppParams,
90
89
  createJdOpenAppUrl,
91
90
  isEmpty,
92
91
  getJdAppReportPageSource,
93
92
  dealJdOpenAppData,
94
93
  getBorderStyle,
95
94
  const getNum = Number(num);
96
95
  let _changeLayoutWidth = layoutWidth;
97
96
  if (!_changeLayoutWidth) {
98
97
  _changeLayoutWidth =
99
98
  _ShopSystemInfo && _ShopSystemInfo?.windowWidth
100
99
  ? _ShopSystemInfo.windowWidth
101
100
  : Taro.getSystemInfoSync()?.windowWidth;
102
101
  }
103
102
  return _ShopSystemInfo?.isJdTabletDevice && !layoutWidth
104
103
  ? Math.floor(getNum * 1.2 * (_changeLayoutWidth / 720))
105
104
  : Math.round((getNum / widthSize) * _changeLayoutWidth);
106
105
  const getRootFontSize = (40 * (systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth)) / 750;
107
106
  let getRealRootFontSize = getRootFontSize > 40 ? 40 : getRootFontSize < 20 ? 20 : getRootFontSize;
108
107
  if (_ShopSystemInfo?.isJdTabletDevice) {
109
108
  getRealRootFontSize = Math.floor(
110
109
  24 * ((systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth) / 720),
111
110
  );
112
111
  }
113
112
  return Math.ceil(
114
113
  (((parseInt(String(changeSize), 10) / 40) * 750) / designWidth) * getRealRootFontSize,
115
114
  );
116
115
  console.log(
117
116
  '获取系统宽度systemInfo?.windowWidth',
118
117
  systemInfo?.windowWidth,
119
118
  'taroToTransformRoutimePXNumber(changeWidth)',
120
119
  taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
121
120
  );
122
121
  return buildType === BUILD_TYPE.CLASSIFY && systemInfo?.windowWidth
123
122
  ? systemInfo?.windowWidth - taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
124
123
  : systemInfo?.windowWidth ?? 0;
125
124
  const systemInfo = _ShopSystemInfo || Taro.getSystemInfoSync();
126
125
  console.log(
127
126
  '获取系统宽度systemInfo?.windowWidth',
128
127
  systemInfo?.windowWidth,
129
128
  'taroToTransformRoutimePXNumber(changeWidth)',
130
129
  taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
131
130
  );
132
131
  const containerWidth =
133
132
  isClassify && systemInfo?.windowWidth
134
133
  ? systemInfo?.windowWidth - taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
135
134
  : (systemInfo?.windowWidth ?? 0);
136
135
  if (global?.info?.sysInfo) {
137
136
  global.info.sysInfo['containerWidth'] = containerWidth;
138
137
  }
139
138
  return (
140
139
  isJdApp &&
141
140
  (parseQueryUrlObj['device'] === 'tablet' || Math.min(rootEleWidth, window.screen.height) >= 720)
142
141
  );
143
142
  const systemInfo = Taro.getSystemInfoSync();
144
143
  if (params && params?.pageWidth && params?.pageHeight) {
145
144
  systemInfo.windowWidth = params?.pageWidth;
146
145
  systemInfo.windowHeight = params?.pageHeight;
147
146
  console.warn('松果app内获取重置系统信息宽度值', params, ',systemInfo信息集合为', systemInfo);
148
147
  } else {
149
148
  if (isPc) {
150
149
  systemInfo.windowWidth = 375;
151
150
  } else {
152
151
  const getWinWidth = window.innerWidth;
153
152
  const getWinHeight = window.innerHeight;
154
153
  const getScreenWidth = window.screen.width;
155
154
  const getScreenHeight = window.screen.height;
156
155
  const getRootEleInitWidth = params?.rootEleInitWidth || 0;
157
156
  const isReplaceSystemWidth = params?.replaceSystemWidth || false;
158
157
  systemInfo.isJdTabletDevice = checkIsJdTabletDevice(getRootEleInitWidth);
159
158
  systemInfo.isJdTabletLandscape =
160
159
  systemInfo.isJdTabletDevice &&
161
160
  checkPadScreenOrientationIsLandscape(getRootEleInitWidth, getScreenWidth, getScreenHeight);
162
161
  if (!systemInfo.isJdTabletDevice && isReplaceSystemWidth) {
163
162
  if (systemInfo?.windowWidth <= 0) {
164
163
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth);
165
164
  systemInfo.windowHeight = getScreenHeight;
166
165
  console.warn(
167
166
  '====初始化获取当前设备不是pad,但是触发屏幕宽高最小值600,系统获取宽度为0,进行重置系统宽度为根元素宽度与屏幕宽度最小值====',
168
167
  systemInfo.windowWidth,
169
168
  'getRootEleInitWidth',
170
169
  getRootEleInitWidth,
171
170
  'getScreenWidth',
172
171
  getScreenWidth,
173
172
  'getScreenHeight',
174
173
  getScreenHeight,
175
174
  );
176
175
  draBusinessCustomReport({
177
176
  type: 'jdapp_pad_width_error_info',
178
177
  errMsg: `松果app内获取当前设备不是pad,触发屏幕宽高最小值600,系统信息宽度为0,进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
179
178
  originReqDataStr: JSON.stringify({
180
179
  isJdApp,
181
180
  isAndroidDevice,
182
181
  getScreenWidth,
183
182
  getScreenHeight,
184
183
  getWinWidth,
185
184
  getWinHeight,
186
185
  getRootEleInitWidth,
187
186
  }),
188
187
  });
189
188
  }
190
189
  } else {
191
190
  if (isJdApp && isAndroidDevice && !systemInfo.isJdTabletDevice && systemInfo) {
192
191
  const isLandscape = getScreenWidth >= getScreenHeight;
193
192
  const { windowWidth, windowHeight, screenWidth, screenHeight } = systemInfo;
194
193
  if (windowWidth <= 0) {
195
194
  systemInfo.initWindowWidth = windowWidth;
196
195
  if (isLandscape) {
197
196
  systemInfo.windowWidth = getScreenHeight;
198
197
  systemInfo.windowHeight = getScreenWidth;
199
198
  systemInfo.screenWidth = getScreenHeight;
200
199
  systemInfo.screenHeight = getScreenWidth;
201
200
  } else {
202
201
  systemInfo.windowWidth = getScreenWidth;
203
202
  systemInfo.windowHeight = getScreenHeight;
204
203
  systemInfo.screenWidth = getScreenWidth;
205
204
  systemInfo.screenHeight = getScreenHeight;
206
205
  }
207
206
  console.warn(
208
207
  `松果安卓app内获取系统信息宽度异常为小于等于0,是否为横屏${isLandscape},进行重置,taro获取窗口宽度值${windowWidth},重置后的宽度值${systemInfo.windowWidth},taro获取窗口高度值${windowHeight},重置后的高度值${systemInfo.windowHeight},根元素宽度值${getRootEleInitWidth}`,
209
208
  );
210
209
  draBusinessCustomReport({
211
210
  type: 'android_jdapp_width_error_info',
212
211
  errMsg: `松果安卓app内获取系统信息宽度为小于等于0,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
213
212
  originReqDataStr: JSON.stringify({
214
213
  isJdApp,
215
214
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
216
215
  getScreenWidth,
217
216
  getScreenHeight,
218
217
  getWinWidth,
219
218
  getWinHeight,
220
219
  getRootEleInitWidth,
221
220
  }),
222
221
  });
223
222
  sgmCustomReport({
224
223
  type: 2,
225
224
  code: 'android_jdapp_width_error_info',
226
225
  msg: {
227
226
  title: `松果安卓app内获取系统信息宽度为小于等于0,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
228
227
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
229
228
  taroSysInfo: systemInfo,
230
229
  },
231
230
  });
232
231
  } else {
233
232
  let _getChangeWinWidthState = false;
234
233
  if (getWinWidth > 0 && windowWidth > 0 && windowWidth > getWinWidth) {
235
234
  if (isLandscape) {
236
235
  systemInfo.windowWidth = getScreenHeight;
237
236
  systemInfo.windowHeight = getScreenWidth;
238
237
  systemInfo.screenWidth = getScreenHeight;
239
238
  systemInfo.screenHeight = getScreenWidth;
240
239
  } else {
241
240
  systemInfo.windowWidth = getScreenWidth;
242
241
  systemInfo.windowHeight = getScreenHeight;
243
242
  systemInfo.screenWidth = getScreenWidth;
244
243
  systemInfo.screenHeight = getScreenHeight;
245
244
  }
246
245
  _getChangeWinWidthState = true;
247
246
  }
248
247
  _getChangeWinWidthState &&
249
248
  console.warn(
250
249
  `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,taro获取窗口宽度值${windowWidth},重置后的宽度值${systemInfo.windowWidth},taro获取屏幕宽度值${screenWidth},重置后的宽度值${systemInfo.screenWidth}`,
251
250
  );
252
251
  if (_getChangeWinWidthState) {
253
252
  draBusinessCustomReport({
254
253
  type: 'android_jdapp_width_error_info_2',
255
254
  title: `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
256
255
  originReqDataStr: JSON.stringify({
257
256
  isJdApp,
258
257
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
259
258
  getScreenWidth,
260
259
  getScreenHeight,
261
260
  getWinWidth,
262
261
  getWinHeight,
263
262
  getRootEleInitWidth,
264
263
  }),
265
264
  });
266
265
  sgmCustomReport({
267
266
  type: 2,
268
267
  code: 'android_jdapp_width_error_info_2',
269
268
  msg: {
270
269
  title: `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
271
270
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
272
271
  taroSysInfo: systemInfo,
273
272
  },
274
273
  });
275
274
  }
276
275
  }
277
276
  }
278
277
  }
279
278
 
280
279
  if (systemInfo.isJdTabletDevice) {
281
280
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth, getScreenHeight);
282
281
  systemInfo.windowHeight = Math.max(getScreenWidth, getScreenHeight);
283
282
  if (systemInfo.isJdTabletLandscape) {
284
283
  const getRenderCenterState = window?.PAGE_DATA?.businessData?.fitPadCenterRenderLowVersion
285
284
  ? jdAppVersionCompare(window.PAGE_DATA.businessData.fitPadCenterRenderLowVersion) < 0
286
285
  : false;
287
286
  if (getRenderCenterState && window?.PAGE_DATA) {
288
287
  window.PAGE_DATA.isFitJdPadRenderCenter = true;
289
288
  }
290
289
  if (window?.PAGE_DATA?.isFitJdPadRenderCenter) {
291
290
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth, getScreenHeight);
292
291
  systemInfo.windowHeight = Math.max(
293
292
  getRootEleInitWidth,
294
293
  getScreenWidth,
295
294
  getScreenHeight,
296
295
  );
297
296
  } else {
298
297
  systemInfo.windowWidth = Math.max(getRootEleInitWidth, getScreenWidth, getScreenHeight);
299
298
  systemInfo.windowHeight = Math.min(
300
299
  getRootEleInitWidth,
301
300
  getScreenWidth,
302
301
  getScreenHeight,
303
302
  );
304
303
  }
305
304
  }
306
305
  console.warn(
307
306
  '====初始化获取当前设备是否是平板设备,是否横屏====',
308
307
  systemInfo.isJdTabletDevice,
309
308
  systemInfo.isJdTabletLandscape,
310
309
  '屏幕信息',
311
310
  window.screen,
312
311
  'getScreenWidth',
313
312
  getScreenWidth,
314
313
  'getScreenHeight',
315
314
  getScreenHeight,
316
315
  'getRootEleInitWidth',
317
316
  getRootEleInitWidth,
318
317
  '当前是否要求居中展示,居中展示那么宽高值要对调',
319
318
  window?.PAGE_DATA?.isFitJdPadRenderCenter,
320
319
  '当前pad最终展示的窗口宽度',
321
320
  systemInfo.windowWidth,
322
321
  );
323
322
  }
324
323
  }
325
324
  }
326
325
  systemInfo['containerWidth'] = getContainerWidth(buildType, systemInfo);
327
326
  console.warn('====获取系统信息=====', systemInfo);
328
327
  return systemInfo;
329
328
  let result: boolean | null = null;
330
329
  return function () {
331
330
  if (result === null) {
332
331
  const appVersionCheckPass = jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0;
333
332
  if (!isJdApp) {
334
333
  console.warn('🚗 ~~ file: utils.ts:191 站外H5默认打开图片优化~');
335
334
  isIgnoreOptimizeFromServer = true;
336
335
  result = true;
337
336
  return true;
338
337
  }
339
338
  const enableAvifOptimize = appVersionCheckPass;
340
339
  if (enableAvifOptimize) {
341
340
  const configData = global?.getDynamicConfig('avifSwitch');
342
341
  const {
343
342
  globalOn = true,
344
343
  ignoreOptimizeFromServer = false,
345
344
  page = {},
346
345
  grayscale = {},
347
346
  whiteList = [],
348
347
  blackList = [],
349
348
  } = configData || {};
350
349
  const { shopId = '0', venderId = '0' } = parseQueryUrlObj;
351
350
  let imageEnableResult = true;
352
351
  isIgnoreOptimizeFromServer = ignoreOptimizeFromServer;
353
352
  if (
354
353
  blackList.find((item) => item.sId === Number(shopId) || item.vId === Number(venderId))
355
354
  ) {
356
355
  imageEnableResult = false;
357
356
  } else if (
358
357
  whiteList.find((item) => item.sId === Number(shopId) || item.vId === Number(venderId))
359
358
  ) {
360
359
  isIgnoreOptimizeFromServer = true;
361
360
  imageEnableResult = true;
362
361
  } else if (grayscale[buildType] && isInGrayscale(grayscale[buildType])) {
363
362
  isIgnoreOptimizeFromServer = true;
364
363
  imageEnableResult = true;
365
364
  } else {
366
365
  imageEnableResult = globalOn === true || page[buildType] === true;
367
366
  if (globalOn === true) {
368
367
  isIgnoreOptimizeFromServer = true;
369
368
  } else if (page[buildType] === true) {
370
369
  } else {
371
370
  }
372
371
  }
373
372
  result = imageEnableResult;
374
373
  return imageEnableResult;
375
374
  } else {
376
375
  result = false;
377
376
  return false;
378
377
  }
379
378
  } else {
380
379
  return result;
381
380
  }
382
381
  };
383
382
  if (typeof options === 'object' && isImageOptimizeEnable()) {
384
383
  return getQualityImageNew(imgUrl, {
385
384
  ...options,
386
385
  needCompress: !global?.info?.pageInfo?.isVipShop
387
386
  }, isIgnoreOptimizeFromServer);
388
387
  } else {
389
388
  return getQualityImageOld(imgUrl, options);
390
389
  }
391
390
  const getSystemInfo = getSystemAndContainerWidthInfo(params) || {
392
391
  windowWidth: window.innerWidth,
393
392
  containerWidth: getContainerWidth(buildType, {
394
393
  windowWidth: window.innerWidth,
395
394
  }),
396
395
  screenWidth: window.innerWidth,
397
396
  platform: '',
398
397
  model: '',
399
398
  system: '',
400
399
  };
401
400
  return getSystemInfo;
402
401
  const params = Object.assign(
403
402
  {},
404
403
  {
405
404
  title: '',
406
405
  duration: 1500,
407
406
  },
408
407
  options,
409
408
  );
410
409
  params.duration = params.duration / 1000;
411
410
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
412
411
  const showSuccessType = isIosDevice ? ToastIosType.SUCCESS : ToastAndroidType.SUCCESS;
413
412
  const duration = isAndroidDevice ? 0 : params.duration;
414
413
  nativePageShowToast(options.title, showSuccessType, duration);
415
414
  console.log('执行原生toast success');
416
415
  } else {
417
416
  showSuccessToast(options);
418
417
  }
419
418
  const params = Object.assign(
420
419
  {},
421
420
  {
422
421
  title: '',
423
422
  duration: 1500,
424
423
  },
425
424
  options,
426
425
  );
427
426
  params.duration = params.duration / 1000;
428
427
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
429
428
  const showSuccessType = isIosDevice ? ToastIosType.FAIL : ToastAndroidType.FAIL;
430
429
  const duration = isAndroidDevice ? 0 : params.duration;
431
430
  nativePageShowToast(options.title, showSuccessType, duration);
432
431
  console.log('执行原生toast fail');
433
432
  } else {
434
433
  console.log('执行H5 toast fail');
435
434
  showFailToast(options);
436
435
  }
437
436
  const params = Object.assign(
438
437
  {},
439
438
  {
440
439
  title: '',
441
440
  duration: 1500,
442
441
  },
443
442
  options,
444
443
  );
445
444
  params.duration = params.duration / 1000;
446
445
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
447
446
  const showSuccessType = isIosDevice ? ToastIosType.NORMAL : ToastAndroidType.NORMAL;
448
447
  const duration = isAndroidDevice ? 0 : params.duration;
449
448
  nativePageShowToast(options.title, showSuccessType, duration);
450
449
  } else {
451
450
  showNormalToast(options);
452
451
  }
453
452
  if (isLanguageForEn) {
454
453
  count = Number(count);
455
454
  if (count >= 1000000000) {
456
455
  return (count / 1000000000).toFixed(fixedNum) + 'B';
457
456
  } else if (count >= 1000000) {
458
457
  return (count / 1000000).toFixed(fixedNum) + 'M';
459
458
  } else if (count >= 1000) {
460
459
  return (count / 1000).toFixed(fixedNum) + 'K';
461
460
  } else {
462
461
  return count;
463
462
  }
464
463
  } else {
465
464
  return h5CountStringify(count, fixedNum, unit, maxNum);
466
465
  }
467
466
  const createLoadingEle = document.createElement('div');
468
467
  createLoadingEle.id = 'J_shopLoading';
469
468
  createLoadingEle.className = `d-shop-loading flexible-center-box ${customClassName}`;
470
469
  createLoadingEle.innerHTML = `<div class='d-loading-content'>
471
470
  <span class='d-shop-loading-icon'></span>
472
471
  <p class='d-shop-text'>${text}</p>
473
472
  </div>`;
474
473
  const getEle = document.body ? document.body : document.getElementsByTagName('body')[0];
475
474
  getEle.appendChild(createLoadingEle);
476
475
  const getEle = document.getElementById('J_shopLoading');
477
476
  getEle && getEle.remove();
478
477
  const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getReviseSystemInfo(params);
479
478
  if (!systemInfo.system && window) {
480
479
  systemInfo.system = window.navigator.userAgent;
481
480
  systemInfo.isChrome = !!systemInfo?.system.match(/chrome/i);
482
481
  }
483
482
  const isIOS = !!systemInfo?.system.match(/ios/i);
484
483
  const isAndroid = !!systemInfo?.system.match(/android/i);
485
484
  systemInfo.navBarHeight = 0;
486
485
  systemInfo.statusBarHeight = 0;
487
486
  systemInfo.capsulePosition = null;
488
487
  systemInfo.isIOS = isIOS;
489
488
  systemInfo.isAndroid = isAndroid;
490
489
  _ShopSystemInfo = systemInfo;
491
490
  return systemInfo;
492
491
  return originDealShopContentData(pageData, sgmCustomReport, isvdev);
493
492
  const numScale = Number(scale);
494
493
  if (isNaN(numScale)) {
495
494
  console.warn(
496
495
  `The 'scale' parameter of the 'isInGrayscale' function is invalid! Expected a number, but received ${scale}`,
497
496
  );
498
497
  return false;
499
498
  }
500
499
  const { venderId } = global.info.queryInfo || {};
501
500
  const id = venderId;
502
501
  if (!id && numScale !== 1) {
503
502
  return false;
504
503
  }
505
504
  const useScale = Math.max(0, Math.min(1, numScale));
506
505
  const isMatch = numScale === 1 || Math.floor(Number(id) % (1 / useScale)) === 0;
507
506
  if (reportKey) {
508
507
  sgmCustomReport({
509
508
  code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
510
509
  msg: '灰度调用',
511
510
  });
512
511
  console.log(
513
512
  `基于KEY[${reportKey}]的灰度调用1次~`,
514
513
  getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
515
514
  );
516
515
  if (isMatch) {
517
516
  sgmCustomReport({
518
517
  code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
519
518
  msg: '灰度命中',
520
519
  });
521
520
  console.log(
522
521
  `基于KEY[${reportKey}]的命中1次灰度!`,
523
522
  getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
524
523
  );
525
524
  }
526
525
  }
527
526
  return isMatch;
528
527
  isJdApp,
529
528
  isWxApp,
530
529
  isIosDevice,
531
530
  isAndroidDevice,
532
531
  isHarmonyDevice,
533
532
  isJdAndIosDevice,
534
533
  isJdAndAndroidDevice,
535
534
  isJdAndHarmonyDevice,
536
535
  isNewHarmonyShop,
537
536
  isJdAndroidX5Core,
538
537
  isMin,
539
538
  isWxMin,
540
539
  isWxMinAndWxapp,
541
540
  isJdMinAndHarmony,
542
541
  isJdMin,
543
542
  isH5,
544
543
  isDynamic,
545
544
  isH5AndJdShopView,
546
545
  isChartH5,
547
546
  isH5AndJdShopViewNativeScroll,
548
547
  isH5AndJdShopViewH5Scroll,
549
548
  isH5AndJdShopH5CustomScrollView,
550
549
  isH5AndJingGouMini,
551
550
  isWxMiniH5View,
552
551
  urlCookie,
553
552
  sliceArrToChunkList,
554
553
  dealAddress,
555
554
  objectToUrlEncode,
556
555
  parseQueryUrlString,
557
556
  setLowSmallPicUrl,
558
557
  setTaroStorage,
559
558
  getTaroStorageKeyValue,
560
559
  removeTaroStorageKey,
561
560
  clearTaroStorageKey,
562
561
  getAvifSupport,
563
562
  getWebpSupport,
564
563
  getQualityImage,
565
564
  formatCountForUnit as countStringify,
566
565
  getWxAppCookieStr,
567
566
  getSystemInfos,
568
567
  pxTransformFromData,
569
568
  dealShopContentDataAndReport as dealShopContentData,
570
569
  dateFormat,
571
570
  throttle,
572
571
  lodashThrottle,
573
572
  debounce,
574
573
  addHttps,
575
574
  commonShowSuccessToast as showSuccessToast,
576
575
  commonShowFailToast as showFailToast,
577
576
  commonShowNormalToast as showNormalToast,
578
577
  showShopLoading,
579
578
  hideShopLoading,
580
579
  stopNativeScrollEvent,
581
580
  getAppChannelType,
582
581
  formatTabActiveMenuType,
583
582
  filterUrlQueryData,
584
583
  sgmCustomReport,
585
584
  draCustomReport,
586
585
  remoteCustomReport,
587
586
  draInterfaceCustomReport,
588
587
  draBusinessCustomReport,
589
588
  draBusinessCustomLogReport,
590
589
  isMemberPage,
591
590
  getFloorDataToDataDefines,
592
591
  isOpenJdAppUrl,
593
592
  jdOpenAppParams,
594
593
  createJdOpenAppUrl,
595
594
  isEmpty,
596
595
  getJdAppReportPageSource,
597
596
  isAppClassifyPage,
598
597
  isAppHomeForMarketPage,
599
598
  isImageOptimizeEnable,
600
599
  isPc,
601
600
  ipLoc_djd,
602
601
  isTjScence,
603
602
  isH5AdnJxMini,
604
603
  isTjM,
605
604
  isTjJxM,
606
605
  isTJApp,
607
606
  isH5AdnHaoWuJie,
608
607
  tjChannel,
609
608
  dealJdOpenAppData,
610
609
  jdAppVersionCompare,
611
610
  dealNativePixelToCssPixel,
612
611
  isAppStowShop,
613
612
  getSgmCustomCode,
614
613
  handleSgmCodeTaroVersion,
615
614
  isInGrayscale,
616
615
  isIpadDevice,
617
616
  getBorderStyle,
618
617
  isSupportHybridHttpRequest,
619
618
  isLanguageForEn,
620
619
  sColor,
621
620
  draInterfaceDSMCustomReport,
622
621
  isTabletDevice,
623
622
  taroToTransformRoutimePXNumber,
624
623
  updateContainerWidth,
625
624
  isInJdShopView,
626
625
  isDongWebView,
627
626
  isLanguageForHk,
628
627
  languageNowType,
628
+ import Taro from '@tarojs/taro';
629
629
  stopNativeScrollEvent,
630
630
  getAppChannelType,
631
631
  isAndroidDevice,
632
632
  isHarmonyDevice,
633
633
  isH5AndJdShopView,
634
634
  isChartH5,
635
635
  isH5AndJdShopViewNativeScroll,
636
636
  isIosDevice,
637
637
  isJdAndAndroidDevice,
638
638
  isJdAndIosDevice,
639
639
  isJdApp,
640
640
  isWxApp,
641
641
  isWxMiniH5View,
642
642
  isJdAndHarmonyDevice,
643
643
  isNewHarmonyShop,
644
644
  isH5AndJingGouMini,
645
645
  urlCookie,
646
646
  sgmCustomReport,
647
647
  draCustomReport,
648
648
  remoteCustomReport,
649
649
  draInterfaceCustomReport,
650
650
  draBusinessCustomReport,
651
651
  draBusinessCustomLogReport,
652
652
  isMemberPage,
653
653
  isH5AndJdShopViewH5Scroll,
654
654
  isH5AndJdShopH5CustomScrollView,
655
655
  isAppClassifyPage,
656
656
  isAppHomeForMarketPage,
657
657
  isPc,
658
658
  ipLoc_djd,
659
659
  jdAppVersionCompare,
660
660
  isTjScence,
661
661
  isH5AdnJxMini,
662
662
  isTjM,
663
663
  isTjJxM,
664
664
  isTJApp,
665
665
  isH5AdnHaoWuJie,
666
666
  tjChannel,
667
667
  dealNativePixelToCssPixel,
668
668
  isAppStowShop,
669
669
  isJdAndroidX5Core,
670
670
  parseQueryUrlObj,
671
671
  isIpadDevice,
672
672
  isTabletDevice,
673
673
  checkPadScreenOrientationIsLandscape,
674
674
  isSupportHybridHttpRequest,
675
675
  isLanguageForEn,
676
676
  sColor,
677
677
  draInterfaceDSMCustomReport,
678
678
  isInJdShopView,
679
679
  isDongWebView,
680
680
  isLanguageForHk,
681
681
  languageNowType,
682
682
  addHttps,
683
683
  clearTaroStorageKey,
684
684
  countStringify as h5CountStringify,
685
685
  dateFormat,
686
686
  dealAddress,
687
687
  dealShopContentData as originDealShopContentData,
688
688
  debounce,
689
689
  filterUrlQueryData,
690
690
  formatTabActiveMenuType,
691
691
  getAvifSupport,
692
692
  getWebpSupport,
693
693
  getTaroStorageKeyValue,
694
694
  getWxAppCookieStr,
695
695
  isH5,
696
696
  isDynamic,
697
697
  isMin,
698
698
  isJdMin,
699
699
  isWxMin,
700
700
  isWxMinAndWxapp,
701
701
  isJdMinAndHarmony,
702
702
  lodashThrottle,
703
703
  objectToUrlEncode,
704
704
  parseQueryUrlString,
705
705
  removeTaroStorageKey,
706
706
  setLowSmallPicUrl,
707
707
  setTaroStorage,
708
708
  showFailToast,
709
709
  showNormalToast,
710
710
  showSuccessToast,
711
711
  sliceArrToChunkList,
712
712
  throttle,
713
713
  getQualityImageNew,
714
714
  getQualityImageOld,
715
715
  isOpenJdAppUrl,
716
716
  jdOpenAppParams,
717
717
  createJdOpenAppUrl,
718
718
  isEmpty,
719
719
  getJdAppReportPageSource,
720
720
  dealJdOpenAppData,
721
721
  getBorderStyle,
722
722
  isInHarmonyBlacklistByModuleFlag,
723
723
  const getNum = Number(num);
724
724
  let _changeLayoutWidth = layoutWidth;
725
725
  if (!_changeLayoutWidth) {
726
726
  _changeLayoutWidth =
727
727
  _ShopSystemInfo && _ShopSystemInfo?.windowWidth
728
728
  ? _ShopSystemInfo.windowWidth
729
729
  : Taro.getSystemInfoSync()?.windowWidth;
730
730
  }
731
731
  return _ShopSystemInfo?.isJdTabletDevice && !layoutWidth
732
732
  ? Math.floor(getNum * 1.2 * (_changeLayoutWidth / 720))
733
733
  : Math.round((getNum / widthSize) * _changeLayoutWidth);
734
734
  const getRootFontSize = (40 * (systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth)) / 750;
735
735
  let getRealRootFontSize = getRootFontSize > 40 ? 40 : getRootFontSize < 20 ? 20 : getRootFontSize;
736
736
  if (_ShopSystemInfo?.isJdTabletDevice) {
737
737
  getRealRootFontSize = Math.floor(
738
738
  24 * ((systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth) / 720),
739
739
  );
740
740
  }
741
741
  return Math.ceil(
742
742
  (((parseInt(String(changeSize), 10) / 40) * 750) / designWidth) * getRealRootFontSize,
743
743
  );
744
744
  console.log(
745
745
  '获取系统宽度systemInfo?.windowWidth',
746
746
  systemInfo?.windowWidth,
747
747
  'taroToTransformRoutimePXNumber(changeWidth)',
748
748
  taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
749
749
  );
750
750
  return buildType === BUILD_TYPE.CLASSIFY && systemInfo?.windowWidth
751
751
  ? systemInfo?.windowWidth - taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
752
752
  : systemInfo?.windowWidth ?? 0;
753
753
  const systemInfo = _ShopSystemInfo || Taro.getSystemInfoSync();
754
754
  console.log(
755
755
  '获取系统宽度systemInfo?.windowWidth',
756
756
  systemInfo?.windowWidth,
757
757
  'taroToTransformRoutimePXNumber(changeWidth)',
758
758
  taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
759
759
  );
760
760
  const containerWidth =
761
761
  isClassify && systemInfo?.windowWidth
762
762
  ? systemInfo?.windowWidth - taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
763
763
  : systemInfo?.windowWidth ?? 0;
764
764
  if (global?.info?.sysInfo) {
765
765
  global.info.sysInfo['containerWidth'] = containerWidth;
766
766
  }
767
767
  return (
768
768
  isJdApp &&
769
769
  (parseQueryUrlObj['device'] === 'tablet' || Math.min(rootEleWidth, window.screen.height) >= 720)
770
770
  );
771
771
  const systemInfo = Taro.getSystemInfoSync();
772
772
  if (params && params?.pageWidth && params?.pageHeight) {
773
773
  systemInfo.windowWidth = params?.pageWidth;
774
774
  systemInfo.windowHeight = params?.pageHeight;
775
775
  console.warn('松果app内获取重置系统信息宽度值', params, ',systemInfo信息集合为', systemInfo);
776
776
  } else {
777
777
  if (isPc) {
778
778
  systemInfo.windowWidth = 375;
779
779
  } else {
780
780
  const getWinWidth = window.innerWidth;
781
781
  const getWinHeight = window.innerHeight;
782
782
  const getScreenWidth = window.screen.width;
783
783
  const getScreenHeight = window.screen.height;
784
784
  const getRootEleInitWidth = params?.rootEleInitWidth || 0;
785
785
  const isReplaceSystemWidth = params?.replaceSystemWidth || false;
786
786
  systemInfo.isJdTabletDevice = checkIsJdTabletDevice(getRootEleInitWidth);
787
787
  systemInfo.isJdTabletLandscape =
788
788
  systemInfo.isJdTabletDevice &&
789
789
  checkPadScreenOrientationIsLandscape(getRootEleInitWidth, getScreenWidth, getScreenHeight);
790
790
  if (!systemInfo.isJdTabletDevice && isReplaceSystemWidth) {
791
791
  if (systemInfo?.windowWidth <= 0) {
792
792
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth);
793
793
  systemInfo.windowHeight = getScreenHeight;
794
794
  console.warn(
795
795
  '====初始化获取当前设备不是pad,但是触发屏幕宽高最小值600,系统获取宽度为0,进行重置系统宽度为根元素宽度与屏幕宽度最小值====',
796
796
  systemInfo.windowWidth,
797
797
  'getRootEleInitWidth',
798
798
  getRootEleInitWidth,
799
799
  'getScreenWidth',
800
800
  getScreenWidth,
801
801
  'getScreenHeight',
802
802
  getScreenHeight,
803
803
  );
804
804
  draBusinessCustomReport({
805
805
  type: 'jdapp_pad_width_error_info',
806
806
  errMsg: `松果app内获取当前设备不是pad,触发屏幕宽高最小值600,系统信息宽度为0,进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
807
807
  originReqDataStr: JSON.stringify({
808
808
  isJdApp,
809
809
  isAndroidDevice,
810
810
  getScreenWidth,
811
811
  getScreenHeight,
812
812
  getWinWidth,
813
813
  getWinHeight,
814
814
  getRootEleInitWidth,
815
815
  }),
816
816
  });
817
817
  }
818
818
  } else {
819
819
  if (isJdApp && isAndroidDevice && !systemInfo.isJdTabletDevice && systemInfo) {
820
820
  const isLandscape = getScreenWidth >= getScreenHeight;
821
821
  const { windowWidth, windowHeight, screenWidth, screenHeight } = systemInfo;
822
822
  if (windowWidth <= 0) {
823
823
  systemInfo.initWindowWidth = windowWidth;
824
824
  if (isLandscape) {
825
825
  systemInfo.windowWidth = getScreenHeight;
826
826
  systemInfo.windowHeight = getScreenWidth;
827
827
  systemInfo.screenWidth = getScreenHeight;
828
828
  systemInfo.screenHeight = getScreenWidth;
829
829
  } else {
830
830
  systemInfo.windowWidth = getScreenWidth;
831
831
  systemInfo.windowHeight = getScreenHeight;
832
832
  systemInfo.screenWidth = getScreenWidth;
833
833
  systemInfo.screenHeight = getScreenHeight;
834
834
  }
835
835
  console.warn(
836
836
  `松果安卓app内获取系统信息宽度异常为小于等于0,是否为横屏${isLandscape},进行重置,taro获取窗口宽度值${windowWidth},重置后的宽度值${systemInfo.windowWidth},taro获取窗口高度值${windowHeight},重置后的高度值${systemInfo.windowHeight},根元素宽度值${getRootEleInitWidth}`,
837
837
  );
838
838
  draBusinessCustomReport({
839
839
  type: 'android_jdapp_width_error_info',
840
840
  errMsg: `松果安卓app内获取系统信息宽度为小于等于0,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
841
841
  originReqDataStr: JSON.stringify({
842
842
  isJdApp,
843
843
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
844
844
  getScreenWidth,
845
845
  getScreenHeight,
846
846
  getWinWidth,
847
847
  getWinHeight,
848
848
  getRootEleInitWidth,
849
849
  }),
850
850
  });
851
851
  sgmCustomReport({
852
852
  type: 2,
853
853
  code: 'android_jdapp_width_error_info',
854
854
  msg: {
855
855
  title: `松果安卓app内获取系统信息宽度为小于等于0,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
856
856
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
857
857
  taroSysInfo: systemInfo,
858
858
  },
859
859
  });
860
860
  } else {
861
861
  let _getChangeWinWidthState = false;
862
862
  if (getWinWidth > 0 && windowWidth > 0 && windowWidth > getWinWidth) {
863
863
  if (isLandscape) {
864
864
  systemInfo.windowWidth = getScreenHeight;
865
865
  systemInfo.windowHeight = getScreenWidth;
866
866
  systemInfo.screenWidth = getScreenHeight;
867
867
  systemInfo.screenHeight = getScreenWidth;
868
868
  } else {
869
869
  systemInfo.windowWidth = getScreenWidth;
870
870
  systemInfo.windowHeight = getScreenHeight;
871
871
  systemInfo.screenWidth = getScreenWidth;
872
872
  systemInfo.screenHeight = getScreenHeight;
873
873
  }
874
874
  _getChangeWinWidthState = true;
875
875
  }
876
876
  _getChangeWinWidthState &&
877
877
  console.warn(
878
878
  `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,taro获取窗口宽度值${windowWidth},重置后的宽度值${systemInfo.windowWidth},taro获取屏幕宽度值${screenWidth},重置后的宽度值${systemInfo.screenWidth}`,
879
879
  );
880
880
  if (_getChangeWinWidthState) {
881
881
  draBusinessCustomReport({
882
882
  type: 'android_jdapp_width_error_info_2',
883
883
  title: `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
884
884
  originReqDataStr: JSON.stringify({
885
885
  isJdApp,
886
886
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
887
887
  getScreenWidth,
888
888
  getScreenHeight,
889
889
  getWinWidth,
890
890
  getWinHeight,
891
891
  getRootEleInitWidth,
892
892
  }),
893
893
  });
894
894
  sgmCustomReport({
895
895
  type: 2,
896
896
  code: 'android_jdapp_width_error_info_2',
897
897
  msg: {
898
898
  title: `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
899
899
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
900
900
  taroSysInfo: systemInfo,
901
901
  },
902
902
  });
903
903
  }
904
904
  }
905
905
  }
906
906
  }
907
907
 
908
908
  if (systemInfo.isJdTabletDevice) {
909
909
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth, getScreenHeight);
910
910
  systemInfo.windowHeight = Math.max(getScreenWidth, getScreenHeight);
911
911
  if (systemInfo.isJdTabletLandscape) {
912
912
  const getRenderCenterState = window?.PAGE_DATA?.businessData?.fitPadCenterRenderLowVersion
913
913
  ? jdAppVersionCompare(window.PAGE_DATA.businessData.fitPadCenterRenderLowVersion) < 0
914
914
  : false;
915
915
  if (getRenderCenterState && window?.PAGE_DATA) {
916
916
  window.PAGE_DATA.isFitJdPadRenderCenter = true;
917
917
  }
918
918
  if (window?.PAGE_DATA?.isFitJdPadRenderCenter) {
919
919
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth, getScreenHeight);
920
920
  systemInfo.windowHeight = Math.max(
921
921
  getRootEleInitWidth,
922
922
  getScreenWidth,
923
923
  getScreenHeight,
924
924
  );
925
925
  } else {
926
926
  systemInfo.windowWidth = Math.max(getRootEleInitWidth, getScreenWidth, getScreenHeight);
927
927
  systemInfo.windowHeight = Math.min(
928
928
  getRootEleInitWidth,
929
929
  getScreenWidth,
930
930
  getScreenHeight,
931
931
  );
932
932
  }
933
933
  }
934
934
  console.warn(
935
935
  '====初始化获取当前设备是否是平板设备,是否横屏====',
936
936
  systemInfo.isJdTabletDevice,
937
937
  systemInfo.isJdTabletLandscape,
938
938
  '屏幕信息',
939
939
  window.screen,
940
940
  'getScreenWidth',
941
941
  getScreenWidth,
942
942
  'getScreenHeight',
943
943
  getScreenHeight,
944
944
  'getRootEleInitWidth',
945
945
  getRootEleInitWidth,
946
946
  '当前是否要求居中展示,居中展示那么宽高值要对调',
947
947
  window?.PAGE_DATA?.isFitJdPadRenderCenter,
948
948
  '当前pad最终展示的窗口宽度',
949
949
  systemInfo.windowWidth,
950
950
  );
951
951
  }
952
952
  }
953
953
  }
954
954
  systemInfo['containerWidth'] = getContainerWidth(buildType, systemInfo);
955
955
  console.warn('====获取系统信息=====', systemInfo);
956
956
  return systemInfo;
957
957
  let result: boolean | null = null;
958
958
  return function () {
959
959
  if (result === null) {
960
960
  const appVersionCheckPass = jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0;
961
961
  if (!isJdApp) {
962
962
  console.warn('🚗 ~~ file: utils.ts:191 站外H5默认打开图片优化~');
963
963
  isIgnoreOptimizeFromServer = true;
964
964
  result = true;
965
965
  return true;
966
966
  }
967
967
  const enableAvifOptimize = appVersionCheckPass;
968
968
  if (enableAvifOptimize) {
969
969
  const configData = global?.getDynamicConfig('avifSwitch');
970
970
  const {
971
971
  globalOn = true,
972
972
  ignoreOptimizeFromServer = false,
973
973
  page = {},
974
974
  grayscale = {},
975
975
  whiteList = [],
976
976
  blackList = [],
977
977
  } = configData || {};
978
978
  const { shopId = '0', venderId = '0' } = parseQueryUrlObj;
979
979
  let imageEnableResult = true;
980
980
  isIgnoreOptimizeFromServer = ignoreOptimizeFromServer;
981
981
  if (
982
982
  blackList.find((item) => item.sId === Number(shopId) || item.vId === Number(venderId))
983
983
  ) {
984
984
  imageEnableResult = false;
985
985
  } else if (
986
986
  whiteList.find((item) => item.sId === Number(shopId) || item.vId === Number(venderId))
987
987
  ) {
988
988
  isIgnoreOptimizeFromServer = true;
989
989
  imageEnableResult = true;
990
990
  } else if (grayscale[buildType] && isInGrayscale(grayscale[buildType])) {
991
991
  isIgnoreOptimizeFromServer = true;
992
992
  imageEnableResult = true;
993
993
  } else {
994
994
  imageEnableResult = globalOn === true || page[buildType] === true;
995
995
  if (globalOn === true) {
996
996
  isIgnoreOptimizeFromServer = true;
997
997
  } else if (page[buildType] === true) {
998
998
  } else {
999
999
  }
1000
1000
  }
1001
1001
  result = imageEnableResult;
1002
1002
  return imageEnableResult;
1003
1003
  } else {
1004
1004
  result = false;
1005
1005
  return false;
1006
1006
  }
1007
1007
  } else {
1008
1008
  return result;
1009
1009
  }
1010
1010
  };
1011
1011
  if (typeof options === 'object' && isImageOptimizeEnable()) {
1012
1012
  return getQualityImageNew(imgUrl, {
1013
1013
  ...options,
1014
1014
  needCompress: !global?.info?.pageInfo?.isVipShop
1015
1015
  }, isIgnoreOptimizeFromServer);
1016
1016
  } else {
1017
1017
  return getQualityImageOld(imgUrl, options);
1018
1018
  }
1019
1019
  const getSystemInfo = getSystemAndContainerWidthInfo(params) || {
1020
1020
  windowWidth: window.innerWidth,
1021
1021
  containerWidth: getContainerWidth(buildType, {
1022
1022
  windowWidth: window.innerWidth,
1023
1023
  }),
1024
1024
  screenWidth: window.innerWidth,
1025
1025
  platform: '',
1026
1026
  model: '',
1027
1027
  system: '',
1028
1028
  };
1029
1029
  return getSystemInfo;
1030
1030
  const params = Object.assign(
1031
1031
  {},
1032
1032
  {
1033
1033
  title: '',
1034
1034
  duration: 1500,
1035
1035
  },
1036
1036
  options,
1037
1037
  );
1038
1038
  params.duration = params.duration / 1000;
1039
1039
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
1040
1040
  const showSuccessType = isIosDevice ? ToastIosType.SUCCESS : ToastAndroidType.SUCCESS;
1041
1041
  const duration = isAndroidDevice ? 0 : params.duration;
1042
1042
  nativePageShowToast(options.title, showSuccessType, duration);
1043
1043
  console.log('执行原生toast success');
1044
1044
  } else {
1045
1045
  showSuccessToast(options);
1046
1046
  }
1047
1047
  const params = Object.assign(
1048
1048
  {},
1049
1049
  {
1050
1050
  title: '',
1051
1051
  duration: 1500,
1052
1052
  },
1053
1053
  options,
1054
1054
  );
1055
1055
  params.duration = params.duration / 1000;
1056
1056
  if (isJdApp && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
1057
1057
  const showSuccessType = isIosDevice ? ToastIosType.FAIL : ToastAndroidType.FAIL;
1058
1058
  const duration = isAndroidDevice ? 0 : params.duration;
1059
1059
  nativePageShowToast(options.title, showSuccessType, duration);
1060
1060
  console.log('执行原生toast fail');
1061
1061
  } else {
1062
1062
  console.log('执行H5 toast fail');
1063
1063
  showFailToast(options);
1064
1064
  }
1065
1065
  const params = Object.assign(
1066
1066
  {},
1067
1067
  {
1068
1068
  title: '',
1069
1069
  duration: 1500,
1070
1070
  },
1071
1071
  options,
1072
1072
  );
1073
1073
  params.duration = params.duration / 1000;
1074
1074
  if (isJdApp && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
1075
1075
  const showSuccessType = isIosDevice ? ToastIosType.NORMAL : ToastAndroidType.NORMAL;
1076
1076
  const duration = isAndroidDevice ? 0 : params.duration;
1077
1077
  nativePageShowToast(options.title, showSuccessType, duration);
1078
1078
  } else {
1079
1079
  showNormalToast(options);
1080
1080
  }
1081
1081
  if (isLanguageForEn) {
1082
1082
  count = Number(count);
1083
1083
  if (count >= 1000000000) {
1084
1084
  return (count / 1000000000).toFixed(fixedNum) + 'B';
1085
1085
  } else if (count >= 1000000) {
1086
1086
  return (count / 1000000).toFixed(fixedNum) + 'M';
1087
1087
  } else if (count >= 1000) {
1088
1088
  return (count / 1000).toFixed(fixedNum) + 'K';
1089
1089
  } else {
1090
1090
  return count;
1091
1091
  }
1092
1092
  } else {
1093
1093
  return h5CountStringify(count, fixedNum, unit, maxNum);
1094
1094
  }
1095
1095
  const createLoadingEle = document.createElement('div');
1096
1096
  createLoadingEle.id = 'J_shopLoading';
1097
1097
  createLoadingEle.className = `d-shop-loading flexible-center-box ${customClassName}`;
1098
1098
  createLoadingEle.innerHTML = `<div class='d-loading-content'>
1099
1099
  <span class='d-shop-loading-icon'></span>
1100
1100
  <p class='d-shop-text'>${text}</p>
1101
1101
  </div>`;
1102
1102
  const getEle = document.body ? document.body : document.getElementsByTagName('body')[0];
1103
1103
  getEle.appendChild(createLoadingEle);
1104
1104
  const getEle = document.getElementById('J_shopLoading');
1105
1105
  getEle && getEle.remove();
1106
1106
  const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getReviseSystemInfo(params);
1107
1107
  if (!systemInfo.system && window) {
1108
1108
  systemInfo.system = window.navigator.userAgent;
1109
1109
  systemInfo.isChrome = !!systemInfo?.system.match(/chrome/i);
1110
1110
  }
1111
1111
  const isIOS = !!systemInfo?.system.match(/ios/i);
1112
1112
  const isAndroid = !!systemInfo?.system.match(/android/i);
1113
1113
  systemInfo.navBarHeight = 0;
1114
1114
  systemInfo.statusBarHeight = 0;
1115
1115
  systemInfo.capsulePosition = null;
1116
1116
  systemInfo.isIOS = isIOS;
1117
1117
  systemInfo.isAndroid = isAndroid;
1118
1118
  _ShopSystemInfo = systemInfo;
1119
1119
  return systemInfo;
1120
1120
  const result = originDealShopContentData(pageData, sgmCustomReport, isvdev);
1121
1121
  if (isJdAndHarmonyDevice && isNewHarmonyShop) {
1122
1122
  result.shopContentContainerListData = result.shopContentContainerListData.filter(
1123
1123
  (item) =>
1124
1124
  item.floors.length > 0 &&
1125
1125
  !isInHarmonyBlacklistByModuleFlag(item.containerId, result.shopContentContainerListData),
1126
1126
  );
1127
1127
  }
1128
1128
  return result;
1129
1129
  const numScale = Number(scale);
1130
1130
  if (isNaN(numScale)) {
1131
1131
  console.warn(
1132
1132
  `The 'scale' parameter of the 'isInGrayscale' function is invalid! Expected a number, but received ${scale}`,
1133
1133
  );
1134
1134
  return false;
1135
1135
  }
1136
1136
  const { venderId } = global.info.queryInfo || {};
1137
1137
  const id = venderId;
1138
1138
  if (!id && numScale !== 1) {
1139
1139
  return false;
1140
1140
  }
1141
1141
  const useScale = Math.max(0, Math.min(1, numScale));
1142
1142
  const isMatch = numScale === 1 || Math.floor(Number(id) % (1 / useScale)) === 0;
1143
1143
  if (reportKey) {
1144
1144
  sgmCustomReport({
1145
1145
  code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
1146
1146
  msg: '灰度调用',
1147
1147
  });
1148
1148
  console.log(
1149
1149
  `基于KEY[${reportKey}]的灰度调用1次~`,
1150
1150
  getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
1151
1151
  );
1152
1152
  if (isMatch) {
1153
1153
  sgmCustomReport({
1154
1154
  code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
1155
1155
  msg: '灰度命中',
1156
1156
  });
1157
1157
  console.log(
1158
1158
  `基于KEY[${reportKey}]的命中1次灰度!`,
1159
1159
  getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
1160
1160
  );
1161
1161
  }
1162
1162
  }
1163
1163
  return isMatch;
1164
1164
  isJdApp,
1165
1165
  isWxApp,
1166
1166
  isIosDevice,
1167
1167
  isAndroidDevice,
1168
1168
  isHarmonyDevice,
1169
1169
  isJdAndIosDevice,
1170
1170
  isJdAndAndroidDevice,
1171
1171
  isJdAndHarmonyDevice,
1172
1172
  isNewHarmonyShop,
1173
1173
  isJdAndroidX5Core,
1174
1174
  isMin,
1175
1175
  isWxMin,
1176
1176
  isWxMinAndWxapp,
1177
1177
  isJdMinAndHarmony,
1178
1178
  isJdMin,
1179
1179
  isH5,
1180
1180
  isDynamic,
1181
1181
  isH5AndJdShopView,
1182
1182
  isChartH5,
1183
1183
  isH5AndJdShopViewNativeScroll,
1184
1184
  isH5AndJdShopViewH5Scroll,
1185
1185
  isH5AndJdShopH5CustomScrollView,
1186
1186
  isH5AndJingGouMini,
1187
1187
  isWxMiniH5View,
1188
1188
  urlCookie,
1189
1189
  sliceArrToChunkList,
1190
1190
  dealAddress,
1191
1191
  objectToUrlEncode,
1192
1192
  parseQueryUrlString,
1193
1193
  setLowSmallPicUrl,
1194
1194
  setTaroStorage,
1195
1195
  getTaroStorageKeyValue,
1196
1196
  removeTaroStorageKey,
1197
1197
  clearTaroStorageKey,
1198
1198
  getAvifSupport,
1199
1199
  getWebpSupport,
1200
1200
  getQualityImage,
1201
1201
  formatCountForUnit as countStringify,
1202
1202
  getWxAppCookieStr,
1203
1203
  getSystemInfos,
1204
1204
  pxTransformFromData,
1205
1205
  dealShopContentDataAndReport as dealShopContentData,
1206
1206
  dateFormat,
1207
1207
  throttle,
1208
1208
  lodashThrottle,
1209
1209
  debounce,
1210
1210
  addHttps,
1211
1211
  commonShowSuccessToast as showSuccessToast,
1212
1212
  commonShowFailToast as showFailToast,
1213
1213
  commonShowNormalToast as showNormalToast,
1214
1214
  showShopLoading,
1215
1215
  hideShopLoading,
1216
1216
  stopNativeScrollEvent,
1217
1217
  getAppChannelType,
1218
1218
  formatTabActiveMenuType,
1219
1219
  filterUrlQueryData,
1220
1220
  sgmCustomReport,
1221
1221
  draCustomReport,
1222
1222
  remoteCustomReport,
1223
1223
  draInterfaceCustomReport,
1224
1224
  draBusinessCustomReport,
1225
1225
  draBusinessCustomLogReport,
1226
1226
  isMemberPage,
1227
1227
  getFloorDataToDataDefines,
1228
1228
  isOpenJdAppUrl,
1229
1229
  jdOpenAppParams,
1230
1230
  createJdOpenAppUrl,
1231
1231
  isEmpty,
1232
1232
  getJdAppReportPageSource,
1233
1233
  isAppClassifyPage,
1234
1234
  isAppHomeForMarketPage,
1235
1235
  isImageOptimizeEnable,
1236
1236
  isPc,
1237
1237
  ipLoc_djd,
1238
1238
  isTjScence,
1239
1239
  isH5AdnJxMini,
1240
1240
  isTjM,
1241
1241
  isTjJxM,
1242
1242
  isTJApp,
1243
1243
  isH5AdnHaoWuJie,
1244
1244
  tjChannel,
1245
1245
  dealJdOpenAppData,
1246
1246
  jdAppVersionCompare,
1247
1247
  dealNativePixelToCssPixel,
1248
1248
  isAppStowShop,
1249
1249
  getSgmCustomCode,
1250
1250
  handleSgmCodeTaroVersion,
1251
1251
  isInGrayscale,
1252
1252
  isIpadDevice,
1253
1253
  getBorderStyle,
1254
1254
  isSupportHybridHttpRequest,
1255
1255
  isLanguageForEn,
1256
1256
  sColor,
1257
1257
  draInterfaceDSMCustomReport,
1258
1258
  isTabletDevice,
1259
1259
  taroToTransformRoutimePXNumber,
1260
1260
  updateContainerWidth,
1261
1261
  isInJdShopView,
1262
1262
  isDongWebView,
1263
1263
  isLanguageForHk,
1264
1264
  languageNowType,