@conecli/cone-render 0.10.1-shop3.122 → 0.10.1-shop3.124

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