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

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