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