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