@conecli/cone-render 0.10.1-shop3.25 → 0.10.1-shop3.26

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