@conecli/cone-render 0.10.1-shop3.20 → 0.10.1-shop3.21

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