@conecli/cone-render 0.9.1-shop2.25 → 0.9.1-shop2.27

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