@conecli/cone-render 0.10.1-shop3.6 → 0.10.1-shop3.7

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