@conecli/cone-render 0.10.1-shop3.73 → 0.10.1-shop3.74

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