@conecli/cone-render 0.8.20-shop.230 → 0.8.20-shop.231

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
  isJdAndHarmonyDevice,
13
12
  isJdApp,
14
13
  isWxApp,
15
14
  isWxMiniH5View,
16
15
  isH5AndJingGouMini,
17
16
  urlCookie,
18
17
  sgmCustomReport,
19
18
  draCustomReport,
20
19
  remoteCustomReport,
21
20
  draInterfaceCustomReport,
22
21
  draBusinessCustomReport,
23
22
  isMemberPage,
24
23
  isH5AndJdShopViewH5Scroll,
25
24
  isH5AndJdShopH5CustomScrollView,
26
25
  isAppClassifyPage,
27
26
  isAppHomeForMarketPage,
28
27
  isPc,
29
28
  ipLoc_djd,
30
29
  jdAppVersionCompare,
31
30
  dealNativePixelToCssPixel,
32
31
  isAppStowShop,
33
32
  isJdAndroidX5Core,
34
33
  isTjScence,
35
34
  isH5AdnJxMini,
36
35
  isTjM,
37
36
  isTjJxM,
38
37
  isTJApp,
39
38
  isH5AdnHaoWuJie,
40
39
  tjChannel,
41
40
  parseQueryUrlObj,
42
41
  isIpadDevice,
43
42
  isTabletDevice,
44
43
  checkPadScreenOrientationIsLandscape,
45
44
  isSupportHybridHttpRequest,
46
45
  isLanguageForEn,
47
46
  sColor,
48
47
  draInterfaceDSMCustomReport,
49
48
  isInJdShopView,
50
49
  isDongWebView,
51
50
  isLanguageForHk,
52
51
  languageNowType,
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
  isJdAndroidX5Core,
531
530
  isMin,
532
531
  isWxMin,
533
532
  isWxMinAndWxapp,
534
533
  isJdMinAndHarmony,
535
534
  isJdMin,
536
535
  isH5,
537
536
  isH5AndJdShopView,
538
537
  isChartH5,
539
538
  isH5AndJdShopViewNativeScroll,
540
539
  isH5AndJdShopViewH5Scroll,
541
540
  isH5AndJdShopH5CustomScrollView,
542
541
  isH5AndJingGouMini,
543
542
  isWxMiniH5View,
544
543
  urlCookie,
545
544
  sliceArrToChunkList,
546
545
  dealAddress,
547
546
  objectToUrlEncode,
548
547
  parseQueryUrlString,
549
548
  setLowSmallPicUrl,
550
549
  setTaroStorage,
551
550
  getTaroStorageKeyValue,
552
551
  removeTaroStorageKey,
553
552
  clearTaroStorageKey,
554
553
  getAvifSupport,
555
554
  getWebpSupport,
556
555
  getQualityImage,
557
556
  formatCountForUnit as countStringify,
558
557
  getWxAppCookieStr,
559
558
  getSystemInfos,
560
559
  pxTransformFromData,
561
560
  dealShopContentDataAndReport as dealShopContentData,
562
561
  dateFormat,
563
562
  throttle,
564
563
  lodashThrottle,
565
564
  debounce,
566
565
  addHttps,
567
566
  commonShowSuccessToast as showSuccessToast,
568
567
  commonShowFailToast as showFailToast,
569
568
  commonShowNormalToast as showNormalToast,
570
569
  showShopLoading,
571
570
  hideShopLoading,
572
571
  stopNativeScrollEvent,
573
572
  getAppChannelType,
574
573
  formatTabActiveMenuType,
575
574
  filterUrlQueryData,
576
575
  sgmCustomReport,
577
576
  draCustomReport,
578
577
  remoteCustomReport,
579
578
  draInterfaceCustomReport,
580
579
  draBusinessCustomReport,
581
580
  isMemberPage,
582
581
  getFloorDataToDataDefines,
583
582
  isOpenJdAppUrl,
584
583
  jdOpenAppParams,
585
584
  createJdOpenAppUrl,
586
585
  isEmpty,
587
586
  getJdAppReportPageSource,
588
587
  isAppClassifyPage,
589
588
  isAppHomeForMarketPage,
590
589
  isImageOptimizeEnable,
591
590
  isPc,
592
591
  ipLoc_djd,
593
592
  isTjScence,
594
593
  isH5AdnJxMini,
595
594
  isTjM,
596
595
  isTjJxM,
597
596
  isTJApp,
598
597
  isH5AdnHaoWuJie,
599
598
  tjChannel,
600
599
  dealJdOpenAppData,
601
600
  jdAppVersionCompare,
602
601
  dealNativePixelToCssPixel,
603
602
  isAppStowShop,
604
603
  getSgmCustomCode,
605
604
  handleSgmCodeTaroVersion,
606
605
  isInGrayscale,
607
606
  isIpadDevice,
608
607
  getBorderStyle,
609
608
  isSupportHybridHttpRequest,
610
609
  isLanguageForEn,
611
610
  sColor,
612
611
  draInterfaceDSMCustomReport,
613
612
  isTabletDevice,
614
613
  taroToTransformRoutimePXNumber,
615
614
  updateContainerWidth,
616
615
  isInJdShopView,
617
616
  isDongWebView,
618
617
  isLanguageForHk,
619
618
  languageNowType,
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
  isJdAndHarmonyDevice,
631
631
  isJdApp,
632
632
  isWxApp,
633
633
  isWxMiniH5View,
634
634
  isH5AndJingGouMini,
635
635
  urlCookie,
636
636
  sgmCustomReport,
637
637
  draCustomReport,
638
638
  remoteCustomReport,
639
639
  draInterfaceCustomReport,
640
640
  draBusinessCustomReport,
641
641
  draBusinessCustomLogReport,
642
642
  isMemberPage,
643
643
  isH5AndJdShopViewH5Scroll,
644
644
  isH5AndJdShopH5CustomScrollView,
645
645
  isAppClassifyPage,
646
646
  isAppHomeForMarketPage,
647
647
  isPc,
648
648
  ipLoc_djd,
649
649
  jdAppVersionCompare,
650
650
  dealNativePixelToCssPixel,
651
651
  isAppStowShop,
652
652
  isJdAndroidX5Core,
653
653
  isTjScence,
654
654
  isH5AdnJxMini,
655
655
  isTjM,
656
656
  isTjJxM,
657
657
  isTJApp,
658
658
  isH5AdnHaoWuJie,
659
659
  tjChannel,
660
660
  parseQueryUrlObj,
661
661
  isIpadDevice,
662
662
  isTabletDevice,
663
663
  checkPadScreenOrientationIsLandscape,
664
664
  isSupportHybridHttpRequest,
665
665
  isLanguageForEn,
666
666
  sColor,
667
667
  draInterfaceDSMCustomReport,
668
668
  isInJdShopView,
669
669
  isDongWebView,
670
670
  isLanguageForHk,
671
671
  languageNowType,
672
672
  addHttps,
673
673
  clearTaroStorageKey,
674
674
  countStringify as h5CountStringify,
675
675
  dateFormat,
676
676
  dealAddress,
677
677
  dealShopContentData as originDealShopContentData,
678
678
  debounce,
679
679
  filterUrlQueryData,
680
680
  formatTabActiveMenuType,
681
681
  getAvifSupport,
682
682
  getWebpSupport,
683
683
  getTaroStorageKeyValue,
684
684
  getWxAppCookieStr,
685
685
  isH5,
686
686
  isMin,
687
687
  isJdMin,
688
688
  isWxMin,
689
689
  isWxMinAndWxapp,
690
690
  isJdMinAndHarmony,
691
691
  lodashThrottle,
692
692
  objectToUrlEncode,
693
693
  parseQueryUrlString,
694
694
  removeTaroStorageKey,
695
695
  setLowSmallPicUrl,
696
696
  setTaroStorage,
697
697
  showFailToast,
698
698
  showNormalToast,
699
699
  showSuccessToast,
700
700
  sliceArrToChunkList,
701
701
  throttle,
702
702
  getQualityImageNew,
703
703
  getQualityImageOld,
704
704
  isOpenJdAppUrl,
705
705
  jdOpenAppParams,
706
706
  createJdOpenAppUrl,
707
707
  isEmpty,
708
708
  getJdAppReportPageSource,
709
709
  dealJdOpenAppData,
710
710
  getBorderStyle,
711
711
  const getNum = Number(num);
712
712
  let _changeLayoutWidth = layoutWidth;
713
713
  if (!_changeLayoutWidth) {
714
714
  _changeLayoutWidth =
715
715
  _ShopSystemInfo && _ShopSystemInfo?.windowWidth
716
716
  ? _ShopSystemInfo.windowWidth
717
717
  : Taro.getSystemInfoSync()?.windowWidth;
718
718
  }
719
719
  return _ShopSystemInfo?.isJdTabletDevice && !layoutWidth
720
720
  ? Math.floor(getNum * 1.2 * (_changeLayoutWidth / 720))
721
721
  : Math.round((getNum / widthSize) * _changeLayoutWidth);
722
722
  const getRootFontSize = (40 * (systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth)) / 750;
723
723
  let getRealRootFontSize = getRootFontSize > 40 ? 40 : getRootFontSize < 20 ? 20 : getRootFontSize;
724
724
  if (_ShopSystemInfo?.isJdTabletDevice) {
725
725
  getRealRootFontSize = Math.floor(
726
726
  24 * ((systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth) / 720),
727
727
  );
728
728
  }
729
729
  return Math.ceil(
730
730
  (((parseInt(String(changeSize), 10) / 40) * 750) / designWidth) * getRealRootFontSize,
731
731
  );
732
732
  console.log(
733
733
  '获取系统宽度systemInfo?.windowWidth',
734
734
  systemInfo?.windowWidth,
735
735
  'taroToTransformRoutimePXNumber(changeWidth)',
736
736
  taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
737
737
  );
738
738
  return buildType === BUILD_TYPE.CLASSIFY && systemInfo?.windowWidth
739
739
  ? systemInfo?.windowWidth - taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
740
740
  : (systemInfo?.windowWidth ?? 0);
741
741
  const systemInfo = _ShopSystemInfo || Taro.getSystemInfoSync();
742
742
  console.log(
743
743
  '获取系统宽度systemInfo?.windowWidth',
744
744
  systemInfo?.windowWidth,
745
745
  'taroToTransformRoutimePXNumber(changeWidth)',
746
746
  taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
747
747
  );
748
748
  const containerWidth =
749
749
  isClassify && systemInfo?.windowWidth
750
750
  ? systemInfo?.windowWidth - taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
751
751
  : (systemInfo?.windowWidth ?? 0);
752
752
  if (global?.info?.sysInfo) {
753
753
  global.info.sysInfo['containerWidth'] = containerWidth;
754
754
  }
755
755
  return (
756
756
  isJdApp &&
757
757
  (parseQueryUrlObj['device'] === 'tablet' || Math.min(rootEleWidth, window.screen.height) >= 720)
758
758
  );
759
759
  const systemInfo = Taro.getSystemInfoSync();
760
760
  if (params && params?.pageWidth && params?.pageHeight) {
761
761
  systemInfo.windowWidth = params?.pageWidth;
762
762
  systemInfo.windowHeight = params?.pageHeight;
763
763
  console.warn('松果app内获取重置系统信息宽度值', params, ',systemInfo信息集合为', systemInfo);
764
764
  } else {
765
765
  if (isPc) {
766
766
  systemInfo.windowWidth = 375;
767
767
  } else {
768
768
  const getWinWidth = window.innerWidth;
769
769
  const getWinHeight = window.innerHeight;
770
770
  const getScreenWidth = window.screen.width;
771
771
  const getScreenHeight = window.screen.height;
772
772
  const getRootEleInitWidth = params?.rootEleInitWidth || 0;
773
773
  const isReplaceSystemWidth = params?.replaceSystemWidth || false;
774
774
  systemInfo.isJdTabletDevice = checkIsJdTabletDevice(getRootEleInitWidth);
775
775
  systemInfo.isJdTabletLandscape =
776
776
  systemInfo.isJdTabletDevice &&
777
777
  checkPadScreenOrientationIsLandscape(getRootEleInitWidth, getScreenWidth, getScreenHeight);
778
778
  if (!systemInfo.isJdTabletDevice && isReplaceSystemWidth) {
779
779
  if (systemInfo?.windowWidth <= 0) {
780
780
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth);
781
781
  systemInfo.windowHeight = getScreenHeight;
782
782
  console.warn(
783
783
  '====初始化获取当前设备不是pad,但是触发屏幕宽高最小值600,系统获取宽度为0,进行重置系统宽度为根元素宽度与屏幕宽度最小值====',
784
784
  systemInfo.windowWidth,
785
785
  'getRootEleInitWidth',
786
786
  getRootEleInitWidth,
787
787
  'getScreenWidth',
788
788
  getScreenWidth,
789
789
  'getScreenHeight',
790
790
  getScreenHeight,
791
791
  );
792
792
  draBusinessCustomReport({
793
793
  type: 'jdapp_pad_width_error_info',
794
794
  errMsg: `松果app内获取当前设备不是pad,触发屏幕宽高最小值600,系统信息宽度为0,进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
795
795
  originReqDataStr: JSON.stringify({
796
796
  isJdApp,
797
797
  isAndroidDevice,
798
798
  getScreenWidth,
799
799
  getScreenHeight,
800
800
  getWinWidth,
801
801
  getWinHeight,
802
802
  getRootEleInitWidth,
803
803
  }),
804
804
  });
805
805
  }
806
806
  } else {
807
807
  if (isJdApp && isAndroidDevice && !systemInfo.isJdTabletDevice && systemInfo) {
808
808
  const isLandscape = getScreenWidth >= getScreenHeight;
809
809
  const { windowWidth, windowHeight, screenWidth, screenHeight } = systemInfo;
810
810
  if (windowWidth <= 0) {
811
811
  systemInfo.initWindowWidth = windowWidth;
812
812
  if (isLandscape) {
813
813
  systemInfo.windowWidth = getScreenHeight;
814
814
  systemInfo.windowHeight = getScreenWidth;
815
815
  systemInfo.screenWidth = getScreenHeight;
816
816
  systemInfo.screenHeight = getScreenWidth;
817
817
  } else {
818
818
  systemInfo.windowWidth = getScreenWidth;
819
819
  systemInfo.windowHeight = getScreenHeight;
820
820
  systemInfo.screenWidth = getScreenWidth;
821
821
  systemInfo.screenHeight = getScreenHeight;
822
822
  }
823
823
  console.warn(
824
824
  `松果安卓app内获取系统信息宽度异常为小于等于0,是否为横屏${isLandscape},进行重置,taro获取窗口宽度值${windowWidth},重置后的宽度值${systemInfo.windowWidth},taro获取窗口高度值${windowHeight},重置后的高度值${systemInfo.windowHeight},根元素宽度值${getRootEleInitWidth}`,
825
825
  );
826
826
  draBusinessCustomReport({
827
827
  type: 'android_jdapp_width_error_info',
828
828
  errMsg: `松果安卓app内获取系统信息宽度为小于等于0,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
829
829
  originReqDataStr: JSON.stringify({
830
830
  isJdApp,
831
831
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
832
832
  getScreenWidth,
833
833
  getScreenHeight,
834
834
  getWinWidth,
835
835
  getWinHeight,
836
836
  getRootEleInitWidth,
837
837
  }),
838
838
  });
839
839
  sgmCustomReport({
840
840
  type: 2,
841
841
  code: 'android_jdapp_width_error_info',
842
842
  msg: {
843
843
  title: `松果安卓app内获取系统信息宽度为小于等于0,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
844
844
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
845
845
  taroSysInfo: systemInfo,
846
846
  },
847
847
  });
848
848
  } else {
849
849
  let _getChangeWinWidthState = false;
850
850
  if (getWinWidth > 0 && windowWidth > 0 && windowWidth > getWinWidth) {
851
851
  if (isLandscape) {
852
852
  systemInfo.windowWidth = getScreenHeight;
853
853
  systemInfo.windowHeight = getScreenWidth;
854
854
  systemInfo.screenWidth = getScreenHeight;
855
855
  systemInfo.screenHeight = getScreenWidth;
856
856
  } else {
857
857
  systemInfo.windowWidth = getScreenWidth;
858
858
  systemInfo.windowHeight = getScreenHeight;
859
859
  systemInfo.screenWidth = getScreenWidth;
860
860
  systemInfo.screenHeight = getScreenHeight;
861
861
  }
862
862
  _getChangeWinWidthState = true;
863
863
  }
864
864
  _getChangeWinWidthState &&
865
865
  console.warn(
866
866
  `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,taro获取窗口宽度值${windowWidth},重置后的宽度值${systemInfo.windowWidth},taro获取屏幕宽度值${screenWidth},重置后的宽度值${systemInfo.screenWidth}`,
867
867
  );
868
868
  if (_getChangeWinWidthState) {
869
869
  draBusinessCustomReport({
870
870
  type: 'android_jdapp_width_error_info_2',
871
871
  title: `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
872
872
  originReqDataStr: JSON.stringify({
873
873
  isJdApp,
874
874
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
875
875
  getScreenWidth,
876
876
  getScreenHeight,
877
877
  getWinWidth,
878
878
  getWinHeight,
879
879
  getRootEleInitWidth,
880
880
  }),
881
881
  });
882
882
  sgmCustomReport({
883
883
  type: 2,
884
884
  code: 'android_jdapp_width_error_info_2',
885
885
  msg: {
886
886
  title: `松果安卓app内获取系统信息宽度异常,是否为横屏${isLandscape},进行重置,通过window获取的结果,getWinWidth:${getWinWidth},getScreenWidth: ${getScreenWidth},getWinHeight:${getWinHeight},getScreenHeight: ${getScreenHeight},根元素宽度值:${getRootEleInitWidth}`,
887
887
  initData: `Taro.getSystemInfo获取窗口宽度值${windowWidth},高度值${windowHeight},获取屏幕宽度值${screenWidth},高度值${screenHeight}`,
888
888
  taroSysInfo: systemInfo,
889
889
  },
890
890
  });
891
891
  }
892
892
  }
893
893
  }
894
894
  }
895
895
 
896
896
  if (systemInfo.isJdTabletDevice) {
897
897
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth, getScreenHeight);
898
898
  systemInfo.windowHeight = Math.max(getScreenWidth, getScreenHeight);
899
899
  if (systemInfo.isJdTabletLandscape) {
900
900
  const getRenderCenterState = window?.PAGE_DATA?.businessData?.fitPadCenterRenderLowVersion
901
901
  ? jdAppVersionCompare(window.PAGE_DATA.businessData.fitPadCenterRenderLowVersion) < 0
902
902
  : false;
903
903
  if (getRenderCenterState && window?.PAGE_DATA) {
904
904
  window.PAGE_DATA.isFitJdPadRenderCenter = true;
905
905
  }
906
906
  if (window?.PAGE_DATA?.isFitJdPadRenderCenter) {
907
907
  systemInfo.windowWidth = Math.min(getRootEleInitWidth, getScreenWidth, getScreenHeight);
908
908
  systemInfo.windowHeight = Math.max(
909
909
  getRootEleInitWidth,
910
910
  getScreenWidth,
911
911
  getScreenHeight,
912
912
  );
913
913
  } else {
914
914
  systemInfo.windowWidth = Math.max(getRootEleInitWidth, getScreenWidth, getScreenHeight);
915
915
  systemInfo.windowHeight = Math.min(
916
916
  getRootEleInitWidth,
917
917
  getScreenWidth,
918
918
  getScreenHeight,
919
919
  );
920
920
  }
921
921
  }
922
922
  console.warn(
923
923
  '====初始化获取当前设备是否是平板设备,是否横屏====',
924
924
  systemInfo.isJdTabletDevice,
925
925
  systemInfo.isJdTabletLandscape,
926
926
  '屏幕信息',
927
927
  window.screen,
928
928
  'getScreenWidth',
929
929
  getScreenWidth,
930
930
  'getScreenHeight',
931
931
  getScreenHeight,
932
932
  'getRootEleInitWidth',
933
933
  getRootEleInitWidth,
934
934
  '当前是否要求居中展示,居中展示那么宽高值要对调',
935
935
  window?.PAGE_DATA?.isFitJdPadRenderCenter,
936
936
  '当前pad最终展示的窗口宽度',
937
937
  systemInfo.windowWidth,
938
938
  );
939
939
  }
940
940
  }
941
941
  }
942
942
  systemInfo['containerWidth'] = getContainerWidth(buildType, systemInfo);
943
943
  console.warn('====获取系统信息=====', systemInfo);
944
944
  return systemInfo;
945
945
  let result: boolean | null = null;
946
946
  return function () {
947
947
  if (result === null) {
948
948
  const appVersionCheckPass = jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0;
949
949
  if (!isJdApp) {
950
950
  console.warn('🚗 ~~ file: utils.ts:191 站外H5默认打开图片优化~');
951
951
  isIgnoreOptimizeFromServer = true;
952
952
  result = true;
953
953
  return true;
954
954
  }
955
955
  const enableAvifOptimize = appVersionCheckPass;
956
956
  if (enableAvifOptimize) {
957
957
  const configData = global?.getDynamicConfig('avifSwitch');
958
958
  const {
959
959
  globalOn = true,
960
960
  ignoreOptimizeFromServer = false,
961
961
  page = {},
962
962
  grayscale = {},
963
963
  whiteList = [],
964
964
  blackList = [],
965
965
  } = configData || {};
966
966
  const { shopId = '0', venderId = '0' } = parseQueryUrlObj;
967
967
  let imageEnableResult = true;
968
968
  isIgnoreOptimizeFromServer = ignoreOptimizeFromServer;
969
969
  if (
970
970
  blackList.find((item) => item.sId === Number(shopId) || item.vId === Number(venderId))
971
971
  ) {
972
972
  imageEnableResult = false;
973
973
  } else if (
974
974
  whiteList.find((item) => item.sId === Number(shopId) || item.vId === Number(venderId))
975
975
  ) {
976
976
  isIgnoreOptimizeFromServer = true;
977
977
  imageEnableResult = true;
978
978
  } else if (grayscale[buildType] && isInGrayscale(grayscale[buildType])) {
979
979
  isIgnoreOptimizeFromServer = true;
980
980
  imageEnableResult = true;
981
981
  } else {
982
982
  imageEnableResult = globalOn === true || page[buildType] === true;
983
983
  if (globalOn === true) {
984
984
  isIgnoreOptimizeFromServer = true;
985
985
  } else if (page[buildType] === true) {
986
986
  } else {
987
987
  }
988
988
  }
989
989
  result = imageEnableResult;
990
990
  return imageEnableResult;
991
991
  } else {
992
992
  result = false;
993
993
  return false;
994
994
  }
995
995
  } else {
996
996
  return result;
997
997
  }
998
998
  };
999
999
  if (typeof options === 'object' && isImageOptimizeEnable()) {
1000
1000
  return getQualityImageNew(imgUrl, options, isIgnoreOptimizeFromServer);
1001
1001
  } else {
1002
1002
  return getQualityImageOld(imgUrl, options);
1003
1003
  }
1004
1004
  const getSystemInfo = getSystemAndContainerWidthInfo(params) || {
1005
1005
  windowWidth: window.innerWidth,
1006
1006
  containerWidth: getContainerWidth(buildType, {
1007
1007
  windowWidth: window.innerWidth,
1008
1008
  }),
1009
1009
  screenWidth: window.innerWidth,
1010
1010
  platform: '',
1011
1011
  model: '',
1012
1012
  system: '',
1013
1013
  };
1014
1014
  return getSystemInfo;
1015
1015
  const params = Object.assign(
1016
1016
  {},
1017
1017
  {
1018
1018
  title: '',
1019
1019
  duration: 1500,
1020
1020
  },
1021
1021
  options,
1022
1022
  );
1023
1023
  params.duration = params.duration / 1000;
1024
1024
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
1025
1025
  const showSuccessType = isIosDevice ? ToastIosType.SUCCESS : ToastAndroidType.SUCCESS;
1026
1026
  const duration = isAndroidDevice ? 0 : params.duration;
1027
1027
  nativePageShowToast(options.title, showSuccessType, duration);
1028
1028
  console.log('执行原生toast success');
1029
1029
  } else {
1030
1030
  showSuccessToast(options);
1031
1031
  }
1032
1032
  const params = Object.assign(
1033
1033
  {},
1034
1034
  {
1035
1035
  title: '',
1036
1036
  duration: 1500,
1037
1037
  },
1038
1038
  options,
1039
1039
  );
1040
1040
  params.duration = params.duration / 1000;
1041
1041
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
1042
1042
  const showSuccessType = isIosDevice ? ToastIosType.FAIL : ToastAndroidType.FAIL;
1043
1043
  const duration = isAndroidDevice ? 0 : params.duration;
1044
1044
  nativePageShowToast(options.title, showSuccessType, duration);
1045
1045
  console.log('执行原生toast fail');
1046
1046
  } else {
1047
1047
  console.log('执行H5 toast fail');
1048
1048
  showFailToast(options);
1049
1049
  }
1050
1050
  const params = Object.assign(
1051
1051
  {},
1052
1052
  {
1053
1053
  title: '',
1054
1054
  duration: 1500,
1055
1055
  },
1056
1056
  options,
1057
1057
  );
1058
1058
  params.duration = params.duration / 1000;
1059
1059
  if (isJdApp && !isJdAndHarmonyDevice && !window?.PAGE_DATA?.businessData?.hideNativeToast) {
1060
1060
  const showSuccessType = isIosDevice ? ToastIosType.NORMAL : ToastAndroidType.NORMAL;
1061
1061
  const duration = isAndroidDevice ? 0 : params.duration;
1062
1062
  nativePageShowToast(options.title, showSuccessType, duration);
1063
1063
  } else {
1064
1064
  showNormalToast(options);
1065
1065
  }
1066
1066
  if (isLanguageForEn) {
1067
1067
  count = Number(count);
1068
1068
  if (count >= 1000000000) {
1069
1069
  return (count / 1000000000).toFixed(fixedNum) + 'B';
1070
1070
  } else if (count >= 1000000) {
1071
1071
  return (count / 1000000).toFixed(fixedNum) + 'M';
1072
1072
  } else if (count >= 1000) {
1073
1073
  return (count / 1000).toFixed(fixedNum) + 'K';
1074
1074
  } else {
1075
1075
  return count;
1076
1076
  }
1077
1077
  } else {
1078
1078
  return h5CountStringify(count, fixedNum, unit, maxNum);
1079
1079
  }
1080
1080
  const createLoadingEle = document.createElement('div');
1081
1081
  createLoadingEle.id = 'J_shopLoading';
1082
1082
  createLoadingEle.className = `d-shop-loading flexible-center-box ${customClassName}`;
1083
1083
  createLoadingEle.innerHTML = `<div class='d-loading-content'>
1084
1084
  <span class='d-shop-loading-icon'></span>
1085
1085
  <p class='d-shop-text'>${text}</p>
1086
1086
  </div>`;
1087
1087
  const getEle = document.body ? document.body : document.getElementsByTagName('body')[0];
1088
1088
  getEle.appendChild(createLoadingEle);
1089
1089
  const getEle = document.getElementById('J_shopLoading');
1090
1090
  getEle && getEle.remove();
1091
1091
  const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getReviseSystemInfo(params);
1092
1092
  if (!systemInfo.system && window) {
1093
1093
  systemInfo.system = window.navigator.userAgent;
1094
1094
  systemInfo.isChrome = !!systemInfo?.system.match(/chrome/i);
1095
1095
  }
1096
1096
  const isIOS = !!systemInfo?.system.match(/ios/i);
1097
1097
  const isAndroid = !!systemInfo?.system.match(/android/i);
1098
1098
  systemInfo.navBarHeight = 0;
1099
1099
  systemInfo.statusBarHeight = 0;
1100
1100
  systemInfo.capsulePosition = null;
1101
1101
  systemInfo.isIOS = isIOS;
1102
1102
  systemInfo.isAndroid = isAndroid;
1103
1103
  _ShopSystemInfo = systemInfo;
1104
1104
  return systemInfo;
1105
1105
  return originDealShopContentData(pageData, sgmCustomReport, isvdev);
1106
1106
  const numScale = Number(scale);
1107
1107
  if (isNaN(numScale)) {
1108
1108
  console.warn(
1109
1109
  `The 'scale' parameter of the 'isInGrayscale' function is invalid! Expected a number, but received ${scale}`,
1110
1110
  );
1111
1111
  return false;
1112
1112
  }
1113
1113
  const { venderId } = global.info.queryInfo || {};
1114
1114
  const id = venderId;
1115
1115
  if (!id && numScale !== 1) {
1116
1116
  return false;
1117
1117
  }
1118
1118
  const useScale = Math.max(0, Math.min(1, numScale));
1119
1119
  const isMatch = numScale === 1 || Math.floor(Number(id) % (1 / useScale)) === 0;
1120
1120
  if (reportKey) {
1121
1121
  sgmCustomReport({
1122
1122
  code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
1123
1123
  msg: '灰度调用',
1124
1124
  });
1125
1125
  console.log(
1126
1126
  `基于KEY[${reportKey}]的灰度调用1次~`,
1127
1127
  getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
1128
1128
  );
1129
1129
  if (isMatch) {
1130
1130
  sgmCustomReport({
1131
1131
  code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
1132
1132
  msg: '灰度命中',
1133
1133
  });
1134
1134
  console.log(
1135
1135
  `基于KEY[${reportKey}]的命中1次灰度!`,
1136
1136
  getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
1137
1137
  );
1138
1138
  }
1139
1139
  }
1140
1140
  return isMatch;
1141
1141
  isJdApp,
1142
1142
  isWxApp,
1143
1143
  isIosDevice,
1144
1144
  isAndroidDevice,
1145
1145
  isHarmonyDevice,
1146
1146
  isJdAndIosDevice,
1147
1147
  isJdAndAndroidDevice,
1148
1148
  isJdAndHarmonyDevice,
1149
1149
  isJdAndroidX5Core,
1150
1150
  isMin,
1151
1151
  isWxMin,
1152
1152
  isWxMinAndWxapp,
1153
1153
  isJdMinAndHarmony,
1154
1154
  isJdMin,
1155
1155
  isH5,
1156
1156
  isH5AndJdShopView,
1157
1157
  isChartH5,
1158
1158
  isH5AndJdShopViewNativeScroll,
1159
1159
  isH5AndJdShopViewH5Scroll,
1160
1160
  isH5AndJdShopH5CustomScrollView,
1161
1161
  isH5AndJingGouMini,
1162
1162
  isWxMiniH5View,
1163
1163
  urlCookie,
1164
1164
  sliceArrToChunkList,
1165
1165
  dealAddress,
1166
1166
  objectToUrlEncode,
1167
1167
  parseQueryUrlString,
1168
1168
  setLowSmallPicUrl,
1169
1169
  setTaroStorage,
1170
1170
  getTaroStorageKeyValue,
1171
1171
  removeTaroStorageKey,
1172
1172
  clearTaroStorageKey,
1173
1173
  getAvifSupport,
1174
1174
  getWebpSupport,
1175
1175
  getQualityImage,
1176
1176
  formatCountForUnit as countStringify,
1177
1177
  getWxAppCookieStr,
1178
1178
  getSystemInfos,
1179
1179
  pxTransformFromData,
1180
1180
  dealShopContentDataAndReport as dealShopContentData,
1181
1181
  dateFormat,
1182
1182
  throttle,
1183
1183
  lodashThrottle,
1184
1184
  debounce,
1185
1185
  addHttps,
1186
1186
  commonShowSuccessToast as showSuccessToast,
1187
1187
  commonShowFailToast as showFailToast,
1188
1188
  commonShowNormalToast as showNormalToast,
1189
1189
  showShopLoading,
1190
1190
  hideShopLoading,
1191
1191
  stopNativeScrollEvent,
1192
1192
  getAppChannelType,
1193
1193
  formatTabActiveMenuType,
1194
1194
  filterUrlQueryData,
1195
1195
  sgmCustomReport,
1196
1196
  draCustomReport,
1197
1197
  remoteCustomReport,
1198
1198
  draInterfaceCustomReport,
1199
1199
  draBusinessCustomReport,
1200
1200
  draBusinessCustomLogReport,
1201
1201
  isMemberPage,
1202
1202
  getFloorDataToDataDefines,
1203
1203
  isOpenJdAppUrl,
1204
1204
  jdOpenAppParams,
1205
1205
  createJdOpenAppUrl,
1206
1206
  isEmpty,
1207
1207
  getJdAppReportPageSource,
1208
1208
  isAppClassifyPage,
1209
1209
  isAppHomeForMarketPage,
1210
1210
  isImageOptimizeEnable,
1211
1211
  isPc,
1212
1212
  ipLoc_djd,
1213
1213
  isTjScence,
1214
1214
  isH5AdnJxMini,
1215
1215
  isTjM,
1216
1216
  isTjJxM,
1217
1217
  isTJApp,
1218
1218
  isH5AdnHaoWuJie,
1219
1219
  tjChannel,
1220
1220
  dealJdOpenAppData,
1221
1221
  jdAppVersionCompare,
1222
1222
  dealNativePixelToCssPixel,
1223
1223
  isAppStowShop,
1224
1224
  getSgmCustomCode,
1225
1225
  handleSgmCodeTaroVersion,
1226
1226
  isInGrayscale,
1227
1227
  isIpadDevice,
1228
1228
  getBorderStyle,
1229
1229
  isSupportHybridHttpRequest,
1230
1230
  isLanguageForEn,
1231
1231
  sColor,
1232
1232
  draInterfaceDSMCustomReport,
1233
1233
  isTabletDevice,
1234
1234
  taroToTransformRoutimePXNumber,
1235
1235
  updateContainerWidth,
1236
1236
  isInJdShopView,
1237
1237
  isDongWebView,
1238
1238
  isLanguageForHk,
1239
1239
  languageNowType,