@conecli/cone-render 0.9.1-shop2.24 → 0.9.1-shop2.26

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