@conecli/cone-render 0.10.1-shop3.22 → 0.10.1-shop3.23

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