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

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