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