@conecli/cone-render 0.9.1-shop2.32 → 0.9.1-shop2.33

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