@conecli/cone-render 0.10.1-beta.4 → 0.10.1-beta.5

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.
Files changed (50) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/common/index.weapp.ts +1 -1
  5. package/dist/common/sgmCustomCode.ts +1 -1
  6. package/dist/components/ErrorBoundary.tsx +1 -1
  7. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  8. package/dist/components/base/CustomVideo/index.tsx +1 -1
  9. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  10. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  11. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  12. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  13. package/dist/components/base/LazyLoadImage/index.h5.module.scss +3 -0
  14. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  15. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  16. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  17. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  18. package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
  19. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  20. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  21. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  22. package/dist/components/floorItem.tsx +1 -1
  23. package/dist/components/remoteFloorItem.tsx +1 -1
  24. package/dist/interface/common.ts +1 -1
  25. package/dist/interface/component.ts +1 -1
  26. package/dist/interface/service.ts +1 -1
  27. package/dist/jumpEventReport/base.ts +1 -1
  28. package/dist/jumpEventReport/const.ts +1 -1
  29. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  30. package/dist/jumpEventReport/web.base.ts +1 -1
  31. package/dist/jumpEventReport/web.jd.ts +1 -1
  32. package/dist/modules/ContainerFloorList/index.h5.module.scss +1 -0
  33. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  34. package/dist/open/api/device.ts +1 -1
  35. package/dist/open/api/request.ts +1 -1
  36. package/dist/open/api/shopMember.ts +1 -1
  37. package/dist/open/api/util.ts +1 -1
  38. package/dist/open/components/index.ts +1 -1
  39. package/dist/sass/app.h5.scss +5 -0
  40. package/dist/sass/base.scss +45 -0
  41. package/dist/service/requestServer.ts +1 -1
  42. package/dist/utils/connectNativeJsBridge.ts +1 -1
  43. package/dist/utils/h5Utils.ts +1 -1
  44. package/dist/utils/index.h5.ts +1 -1
  45. package/dist/utils/index.ts +1 -1
  46. package/dist/utils/index.weapp.ts +1 -1
  47. package/dist/utils/sgmCodeUtils.ts +1 -1
  48. package/dist/utils/taroRenderUtil.ts +1 -1
  49. package/dist/utils/utils.ts +1 -1
  50. package/package.json +24 -23
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  SHOP_MENU_ID_TYPE,
3
2
  SHOP_MENU_ID_QUERY_NAME,
4
3
  SECTION_HOME_TAB_TYPE,
5
4
  SECTION_HOME_TAB_NAME_TYPE,
6
5
  SECTION_HOME_TAB_QUERY_TYPE,
7
6
  CHANNEL_TYPE,
8
7
  JDShopViewBusinessPathType,
9
8
  FloorModuleType,
10
9
  RemoteLoadFloorList,
11
10
  MPAAS_CONFIG_APP_VERSION,
12
11
  getBundleUrl,
13
12
  getBundleFileName,
14
13
  formatPackResult,
15
14
  SgmCustomCode,
16
15
  NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG,
17
16
  key: string,
18
17
  value: string | object,
19
18
  successBack?: any,
20
19
  failBack?: any,
21
20
  return Taro.setStorage({
22
21
  key: key,
23
22
  data: value,
24
23
  success: successBack,
25
24
  fail: failBack,
26
25
  })
27
26
  return Taro.getStorageSync(key)
28
27
  return Taro.removeStorage({
29
28
  key: key,
30
29
  })
31
30
  return Taro.clearStorage()
32
31
  if (isH5) {
33
32
  const avifCache = getTaroStorageKeyValue(KEY_AVIF)
34
33
  if (avifCache === null || avifCache === '') {
35
34
  const img = new Image()
36
35
  img.onload = function () {
37
36
  if (img.height > 0 && img.width > 0) {
38
37
  setTaroStorage(KEY_AVIF, '1')
39
38
  } else {
40
39
  setTaroStorage(KEY_AVIF, '0')
41
40
  }
42
41
  }
43
42
  img.onerror = () => {
44
43
  setTaroStorage(KEY_AVIF, '0')
45
44
  }
46
45
  img.src =
47
46
  'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A='
48
47
  }
49
48
  const webpCache = getTaroStorageKeyValue(KEY_WEBP)
50
49
  if (webpCache === null || webpCache === '') {
51
50
  const img = new Image()
52
51
  img.onload = function () {
53
52
  if (img.height > 0 && img.width > 0) {
54
53
  setTaroStorage(KEY_WEBP, '1')
55
54
  } else {
56
55
  setTaroStorage(KEY_WEBP, '0')
57
56
  }
58
57
  }
59
58
  img.onerror = () => {
60
59
  setTaroStorage(KEY_WEBP, '0')
61
60
  }
62
61
  img.src =
63
62
  'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAUAmJaQAA3AA/vz0AAA='
64
63
  }
65
64
  }
66
65
  const resultList: Array<any> = [],
67
66
  arrLen = arr.length
68
67
  if (arrLen) {
69
68
  if (arrLen > size) {
70
69
  for (let i = 0; i < arrLen; i = i + size) {
71
70
  resultList.push(arr.slice(i, i + size))
72
71
  }
73
72
  } else {
74
73
  resultList.push(arr)
75
74
  }
76
75
  }
77
76
  return resultList
78
77
  let _address = ids
79
78
  const _areaAreaSplit = ids.split('.')
80
79
  const _areaAreaSplit2 = ids.split('_')
81
80
  _address = _areaAreaSplit.length === 2 ? _areaAreaSplit[0] : _address
82
81
  _address = _areaAreaSplit2.length === 3 ? `${_areaAreaSplit2}_0` : _address
83
82
  return _address
84
83
  let paramStr = ''
85
84
  obj &&
86
85
  Object.keys(obj).forEach((key, index) => {
87
86
  const getValue = `${obj[key]}`
88
87
  .replace(/undefined/, '')
89
88
  .replace(/null/, '')
90
89
  paramStr += `${index === 0 ? '' : '&'}${key}=${encodeURIComponent(
91
90
  getValue,
92
91
  )}`
93
92
  })
94
93
  return paramStr
95
94
  const result = {}
96
95
  if (
97
96
  !urlOrQueryStr ||
98
97
  ('string' !== typeof urlOrQueryStr && String !== urlOrQueryStr.constructor)
99
98
  ) {
100
99
  return result
101
100
  }
102
101
  if (urlOrQueryStr.indexOf('?') > -1) {
103
102
  const queryStr = urlOrQueryStr.split('?')
104
103
  const queryItemList =
105
104
  queryStr && queryStr.length > 1 ? queryStr[1].split('&') : []
106
105
  const queryItemListLen = queryItemList.length
107
106
  queryItemListLen > 0 &&
108
107
  queryItemList.forEach((item) => {
109
108
  const thisItemList = item.split('=')
110
109
  result[thisItemList[0]] = thisItemList[1]
111
110
  })
112
111
  } else {
113
112
  const queryItemList =
114
113
  urlOrQueryStr.indexOf('&') > -1
115
114
  ? urlOrQueryStr.split('&')
116
115
  : [urlOrQueryStr]
117
116
  const queryItemListLen = queryItemList.length
118
117
  queryItemListLen > 0 &&
119
118
  queryItemList.forEach((item) => {
120
119
  const thisItemList = item.split('=')
121
120
  result[thisItemList[0]] = thisItemList[1]
122
121
  })
123
122
  }
124
123
  return result
125
124
  url: string,
126
125
  size?: {
127
126
  w: number
128
127
  h: number
129
128
  },
130
129
  quality?: number,
131
130
  if (url && size) {
132
131
  const _w = Math.floor(size.w)
133
132
  const _h = Math.floor(size.h)
134
133
  if (url.match(/gif$/i)) {
135
134
  return url
136
135
  } else {
137
136
  if (_w > 0 && _h > 0) {
138
137
  url = url.replace('jfs/', `s${_w}x${_h}_jfs/`)
139
138
  }
140
139
  url += quality != null ? `!q${quality}.dpg` : '.dpg'
141
140
  }
142
141
  }
143
142
  return url
144
143
  url: string,
145
144
  jfsImgInfo: UtilsInterFace.getJfsImageInfo = {},
146
145
  if (url.match(/\.(jpg|png|dpg)$/i)) {
147
146
  const { width, height, quality } = jfsImgInfo
148
147
  if (typeof width === 'number' || typeof height === 'number') {
149
148
  url = url.replace(
150
149
  '/jfs/',
151
150
  `/s${Math.floor(width || 0)}x${Math.floor(height || 0)}_jfs/`,
152
151
  )
153
152
  }
154
153
  if (
155
154
  typeof quality === 'number' &&
156
155
  quality > 0 &&
157
156
  quality < 100 &&
158
157
  url.match(/\.jpg$/i)
159
158
  ) {
160
159
  url += `!q${quality}.dpg`
161
160
  }
162
161
  }
163
162
  return addHttps(url)
164
163
  if (imgUrl) {
165
164
  if (
166
165
  !imgUrl.match(
167
166
  /(storage\.360buyimg\.com)|(jdcloud-oss\.com)|(imgcps\.jd\.com)|((\w+)\.300hu\.com)|(thirdwx\.qlogo\.cn)|(!q)|gif|dpg$/i,
168
167
  )
169
168
  ) {
170
169
  if (!imgUrl.includes('360buyimg.com')) {
171
170
  imgUrl = '//m.360buyimg.com/cms/' + imgUrl
172
171
  }
173
172
  if (quality != 100)
174
173
  imgUrl += /\.png/.test(imgUrl) ? '.dpg' : `!q${quality}`
175
174
  }
176
175
  imgUrl = imgUrl.match(/^\/\//) ? `https:${imgUrl}` : imgUrl
177
176
  }
178
177
  return imgUrl
179
178
  const result = value % step
180
179
  return result === 0 ? value : Math.ceil(value / step) * step
181
180
  const MAX = 3.5
182
181
  return Math.min(window?.devicePixelRatio ?? 2, MAX)
183
182
  isSkuImage: boolean
184
183
  size: number
185
184
  imgUrl: string,
186
185
  options: QualityOptions,
187
186
  isIgnoreOptimizeFromServer: boolean = false,
188
187
  if (!imgUrl) {
189
188
  console.error(
190
189
  'The input parameter imageUrl for the getQualityImage() cannot be empty!',
191
190
  )
192
191
  return imgUrl
193
192
  }
194
193
  if (isIgnoreOptimizeFromServer) {
195
194
  imgUrl = imgUrl.replace(/\.(jpe?g|png).*/, '.$1')
196
195
  }
197
196
  if (!/^((https?):)?\/\//.test(imgUrl)) {
198
197
  imgUrl = '//m.360buyimg.com/cms/' + imgUrl
199
198
  }
200
199
  const imgServerRegExp = /(img|m)\d{0,2}\.360buyimg\.com\/.*\.(jpe?g|png)/i
201
200
  if (!imgServerRegExp.test(imgUrl)) {
202
201
  return imgUrl
203
202
  }
204
203
  imgUrl = /^\/\//.test(imgUrl) ? `https:${imgUrl}` : imgUrl
205
204
  const { isSkuImage, size } = options || {}
206
205
  const needReduceSize = isSkuImage && size
207
206
  if (needReduceSize) {
208
207
  const devicePixelRatio = getDevicePixelRatio()
209
208
  const useWidth = getValueByStep(size * devicePixelRatio, 40)
210
209
  imgUrl = imgUrl.replace(/\/[^\/]*jfs\//, `/s${useWidth}x${useWidth}_jfs/`)
211
210
  }
212
211
  const needCompress = !global?.info?.pageInfo?.isVipShop
213
212
  const result = imgUrl.match(/\/\w+\.(jpe?g|png)$/)
214
213
  if (needCompress && result) {
215
214
  if (getAvifSupport() === '1') {
216
215
  imgUrl += '.avif'
217
216
  } else if (getWebpSupport() === '1') {
218
217
  imgUrl += '.webp'
219
218
  } else if (/jpe?g/.test(result[1])) {
220
219
  imgUrl += '!q80'
221
220
  }
222
221
  }
223
222
  if (needReduceSize) {
224
223
  imgUrl += '!z2'
225
224
  }
226
225
  return imgUrl
227
226
  if (imgUrl) {
228
227
  if (
229
228
  !imgUrl.match(
230
229
  /(storage\.360buyimg\.com)|(jdcloud-oss\.com)|((\w+)\.300hu\.com)|(thirdwx\.qlogo\.cn)|(!q)|gif|dpg$/i,
231
230
  )
232
231
  ) {
233
232
  if (!imgUrl.includes('360buyimg.com')) {
234
233
  imgUrl = '//m.360buyimg.com/cms/' + imgUrl
235
234
  }
236
235
  if (quality != 100)
237
236
  imgUrl += /\.png/.test(imgUrl) ? '.dpg' : `!q${quality}`
238
237
  }
239
238
  imgUrl = imgUrl.match(/^\/\//) ? `https:${imgUrl}` : imgUrl
240
239
  }
241
240
  return imgUrl
242
241
  return getTaroStorageKeyValue(KEY_AVIF) || '0'
243
242
  return getTaroStorageKeyValue(KEY_WEBP) || '0'
244
243
  count: number,
245
244
  fixedNum = 2,
246
245
  unit = '万',
247
246
  maxNum = 10000,
248
247
  count = Number(count)
249
248
  if (count > maxNum) {
250
249
  return (count / maxNum).toFixed(fixedNum) + unit
251
250
  }
252
251
  return count
253
252
  const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfo || {
254
253
  platform: '',
255
254
  model: '',
256
255
  system: '',
257
256
  }
258
257
  const isIOS = !!systemInfo.system.match(/ios/i)
259
258
  const isAndroid = !!systemInfo.system.match(/android/i)
260
259
  if (!systemInfo.statusBarHeight) {
261
260
  systemInfo.statusBarHeight = screenHeight - windowHeight - 20
262
261
  systemInfo.navBarExtendHeight = 0
263
262
  } else {
264
263
  if (isIOS) {
265
264
  systemInfo.navBarExtendHeight = 4
266
265
  } else {
267
266
  systemInfo.navBarExtendHeight = 0
268
267
  }
269
268
  }
270
269
  let rect = Taro.getMenuButtonBoundingClientRect
271
270
  ? Taro.getMenuButtonBoundingClientRect()
272
271
  : null
273
272
  if (!rect || !rect.width || !rect.top || !rect.left || !rect.height) {
274
273
  let gap = 0
275
274
  let width = 96
276
275
  if (systemInfo.platform === 'android') {
277
276
  gap = 8
278
277
  width = 96
279
278
  } else if (systemInfo.platform === 'devtools') {
280
279
  if (isIOS) {
281
280
  gap = 5.5
282
281
  } else {
283
282
  gap = 7.5
284
283
  }
285
284
  } else {
286
285
  gap = 4
287
286
  width = 88
288
287
  }
289
288
  rect = {
290
289
  bottom: systemInfo.statusBarHeight + gap + 32,
291
290
  height: 32,
292
291
  left: systemInfo.windowWidth - width - 10,
293
292
  right: systemInfo.windowWidth - 10,
294
293
  top: systemInfo.statusBarHeight + gap,
295
294
  width,
296
295
  }
297
296
  }
298
297
  const gap = rect.top - systemInfo.statusBarHeight
299
298
  systemInfo.navBarTopToStatusBar = gap
300
299
  systemInfo.navBarHeight = 2 * gap + rect.height
301
300
  systemInfo.capsulePosition = rect
302
301
  systemInfo.isIOS = isIOS
303
302
  systemInfo.isAndroid = isAndroid
304
303
  return systemInfo
305
304
  if (str.match(/^\/\//)) {
306
305
  str = 'https:' + str
307
306
  }
308
307
  return str
309
308
  dateTimeOrdate: Date | string | number | null,
310
309
  format = 'yyyy-MM-dd HH:mm:ss',
311
310
  noPadStart = {
312
311
  M: '0',
313
312
  d: '0',
314
313
  H: '0',
315
314
  m: '0',
316
315
  s: '0',
317
316
  },
318
317
  let dateResult = ''
319
318
  const padStarts = Object.assign(
320
319
  {
321
320
  M: '0',
322
321
  d: '0',
323
322
  H: '0',
324
323
  m: '0',
325
324
  s: '0',
326
325
  },
327
326
  noPadStart,
328
327
  )
329
328
  if (dateTimeOrdate) {
330
329
  let changeDateTimeOrdate = dateTimeOrdate
331
330
  const getChangeDateTimeToNumber = Number(changeDateTimeOrdate)
332
331
  if (getChangeDateTimeToNumber) {
333
332
  changeDateTimeOrdate = getChangeDateTimeToNumber
334
333
  } else {
335
334
  changeDateTimeOrdate = `${changeDateTimeOrdate}`
336
335
  .replace(/-/g, '/')
337
336
  .replace(/\./g, '/')
338
337
  }
339
338
  const nowDate =
340
339
  dateTimeOrdate instanceof Date
341
340
  ? dateTimeOrdate
342
341
  : new Date(changeDateTimeOrdate)
343
342
  const dateMap = {
344
343
  y: `${nowDate.getFullYear()}`,
345
344
  M: `${nowDate.getMonth() + 1}`.padStart(2, padStarts['M']),
346
345
  d: `${nowDate.getDate()}`.padStart(2, padStarts['d']),
347
346
  H: `${nowDate.getHours()}`.padStart(2, padStarts['H']),
348
347
  m: `${nowDate.getMinutes()}`.padStart(2, padStarts['m']),
349
348
  s: `${nowDate.getSeconds()}`.padStart(2, padStarts['s']),
350
349
  }
351
350
  const regDate = new RegExp('y+|M+|d+|H+|m+|s+', 'g')
352
351
  const regYear = new RegExp('y')
353
352
  dateResult = format.replace(regDate, (v) => {
354
353
  let changeValue = v
355
354
  if (regYear.test(changeValue)) {
356
355
  const thisYear = dateMap.y
357
356
  const subValueLen = 4 - changeValue.length
358
357
  changeValue = thisYear.substr(subValueLen)
359
358
  } else {
360
359
  const dateKey = v.substr(0, 1)
361
360
  changeValue = dateMap[dateKey]
362
361
  }
363
362
  return changeValue
364
363
  })
365
364
  }
366
365
  return dateResult
367
366
  let timer: any = null
368
367
  let startTime = Date.now()
369
368
  return function () {
370
369
  const curTime = Date.now()
371
370
  const remaining = delay - (curTime - startTime)
372
371
  const context = this
373
372
  const args = arguments
374
373
  clearTimeout(timer)
375
374
  if (remaining <= 0) {
376
375
  func.apply(context, args)
377
376
  startTime = Date.now()
378
377
  } else {
379
378
  timer = setTimeout(func, remaining)
380
379
  }
381
380
  }
382
381
  let context, args, result
383
382
  let timeout = null
384
383
  let previous = 0
385
384
  if (!options) options = {}
386
385
  const later = function () {
387
386
  previous = options.leading === false ? 0 : Date.now()
388
387
  timeout = null
389
388
  result = func.apply(context, args)
390
389
  if (!timeout) context = args = null
391
390
  }
392
391
  return function () {
393
392
  const now = Date.now()
394
393
  if (!previous && options.leading === false) previous = now
395
394
  const remaining = wait - (now - previous)
396
395
  context = this
397
396
  args = arguments
398
397
  if (remaining <= 0 || remaining > wait) {
399
398
  if (timeout) {
400
399
  clearTimeout(timeout)
401
400
  timeout = null
402
401
  }
403
402
  previous = now
404
403
  result = func.apply(context, args)
405
404
  if (!timeout) context = args = null
406
405
  } else if (!timeout && options.trailing !== false) {
407
406
  timeout = setTimeout(later, remaining)
408
407
  }
409
408
  return result
410
409
  }
411
410
  let timer: any = null
412
411
  return function () {
413
412
  const context: any = this
414
413
  const args = arguments
415
414
  timer && clearTimeout(timer)
416
415
  timer = setTimeout(function () {
417
416
  fn.apply(context, args)
418
417
  }, delay)
419
418
  }
420
419
  if (txt) {
421
420
  txt = txt.trim()
422
421
  const reg = new RegExp(/[\d-]+/)
423
422
  const res = reg.exec(txt)
424
423
  if (res && res.length > 0) {
425
424
  let tel = res[0]
426
425
  if (tel && delSeparator) {
427
426
  tel = tel.replace(/-/g, '')
428
427
  }
429
428
  return tel
430
429
  }
431
430
  }
432
431
  return ''
433
432
  if (rgb) {
434
433
  const reg = /^(rgb|RGB)/
435
434
  const color = rgb
436
435
  if (reg.test(color)) {
437
436
  let strHex = '#'
438
437
  const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',')
439
438
  for (let i = 0; i < colorArr.length; i++) {
440
439
  let hex = Number(colorArr[i]).toString(16)
441
440
  if (hex === '0') {
442
441
  hex += hex
443
442
  }
444
443
  strHex += hex
445
444
  }
446
445
  return strHex
447
446
  } else {
448
447
  return String(color)
449
448
  }
450
449
  } else {
451
450
  return ''
452
451
  }
453
452
  if (hex) {
454
453
  const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
455
454
  let color = hex.toLowerCase()
456
455
  if (reg.test(color)) {
457
456
  if (color.length === 4) {
458
457
  let colorNew = '#'
459
458
  for (let i = 1; i < 4; i += 1) {
460
459
  colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1))
461
460
  }
462
461
  color = colorNew
463
462
  }
464
463
  const colorChange: number[] = []
465
464
  for (let i = 1; i < 7; i += 2) {
466
465
  colorChange.push(parseInt('0x' + color.slice(i, i + 2)))
467
466
  }
468
467
  if (returnList) {
469
468
  return colorChange
470
469
  } else {
471
470
  return 'RGB(' + colorChange.join(',') + ')'
472
471
  }
473
472
  } else {
474
473
  return color
475
474
  }
476
475
  } else {
477
476
  return ''
478
477
  }
479
478
  n: number,
480
479
  m: number,
481
480
  filterNum: number | undefined = undefined,
482
481
  const c = m - n + 1
483
482
  const res = Math.floor(Math.random() * c + n)
484
483
  if (filterNum && filterNum == res) {
485
484
  console.log('随机数二次开始', res, filterNum)
486
485
  return getRandom(n, m, filterNum)
487
486
  } else {
488
487
  return res
489
488
  }
490
489
  wqCookieStr: string
491
490
  wqCookie: {
492
491
  pin?: string
493
492
  visitkey?: string
494
493
  [key: string]: any
495
494
  }
496
495
  const {
497
496
  jdpin,
498
497
  pinStatus,
499
498
  visitkey,
500
499
  unionid,
501
500
  skey,
502
501
  __jda,
503
502
  __jdv,
504
503
  __wga,
505
504
  wid,
506
505
  wq_skey,
507
506
  wq_uin,
508
507
  wq_auth_token,
509
508
  wxapp_scene,
510
509
  wq_unionid,
511
510
  wxapp_openid,
512
511
  wxapp_version,
513
512
  wxapp_type,
514
513
  appType,
515
514
  } = cookie
516
515
  const ret: string[] = []
517
516
  const getUserCookieObj = {}
518
517
  const createUseCookieArr = [
519
518
  jdpin,
520
519
  pinStatus,
521
520
  visitkey,
522
521
  unionid,
523
522
  skey,
524
523
  __jda,
525
524
  __jdv,
526
525
  __wga,
527
526
  wid,
528
527
  wq_skey,
529
528
  wq_uin,
530
529
  wq_auth_token,
531
530
  wxapp_scene,
532
531
  wq_unionid,
533
532
  wxapp_openid,
534
533
  wxapp_version,
535
534
  wxapp_type,
536
535
  appType,
537
536
  ]
538
537
  createUseCookieArr.forEach((keyItem) => {
539
538
  if (keyItem && keyItem['name']) {
540
539
  let { name, value } = keyItem
541
540
  name = name === 'jdpin' ? 'pin' : name
542
541
  name === 'pin' && ret.push(`pt_pin=${encodeURIComponent(value)}`)
543
542
  ret.push(`${name}=${encodeURIComponent(value)}`)
544
543
  getUserCookieObj[name] = value
545
544
  }
546
545
  })
547
546
  return {
548
547
  wqCookieStr: ret.join(';'),
549
548
  wqCookie: getUserCookieObj,
550
549
  }
551
550
  num,
552
551
  widthSize = 375,
553
552
  layoutWidth = windowWidth,
554
553
  const getNum = Number(num)
555
554
  return Math.round((getNum / widthSize) * layoutWidth)
556
555
  let checkState = false
557
556
  const couponFloorModuleType = floorData?.floorExtInfo?.moduleFlag
558
557
  if (couponFloorModuleType === FloorModuleType.COUPON) {
559
558
  try {
560
559
  const dataDefines = getFloorDataToDataDefines(floorData)
561
560
  const couponDataDefine = dataDefines
562
561
  ? dataDefines.filter((item) => {
563
562
  return item.type === 'coupon'
564
563
  })
565
564
  : [],
566
565
  couponList = couponDataDefine[0]?.nodeText?.data
567
566
  ? couponDataDefine[0]?.nodeText?.data
568
567
  : [],
569
568
  couponLength = couponList.length,
570
569
  numShowPerLine = couponDataDefine[0]?.nodeText?.numShowPerLine
571
570
  ? couponDataDefine[0]?.nodeText?.numShowPerLine
572
571
  : 0
573
572
  if (numShowPerLine === 0 && couponLength > 3) {
574
573
  checkState = true
575
574
  }
576
575
  } catch (e) {
577
576
  checkState = false
578
577
  }
579
578
  return checkState
580
579
  }
581
580
  const {
582
581
  containers = [],
583
582
  floors = [],
584
583
  clearFirstContaierMarginTop = false,
585
584
  isLuxuryShop = false,
586
585
  isShowNativeImmersivePlayer = false,
587
586
  screenHeight = null,
588
587
  screenWidth = null,
589
588
  bottomBarHeight = null,
590
589
  } = pageData
591
590
  console.log('dealShopContentData:', pageData, 'isvdev:', isvdev)
592
591
  const getThisTimeKey = Date.now()
593
592
  let shopContentContainerListData = containers?.filter(
594
593
  (item) => (!isvdev && item.typeCode !== 'mShopHeader') || isvdev,
595
594
  )
596
595
  const shopContentFloorListData = floors?.filter(
597
596
  ({ floorPosition }) =>
598
597
  (!isvdev && floorPosition !== 'header' && floorPosition !== 'footer') ||
599
598
  isvdev,
600
599
  )
601
600
  const unableIsvContainerListData = getUnableIsvContainerListData(
602
601
  shopContentFloorListData,
603
602
  shopContentContainerListData,
604
603
  exceptionReportFn,
605
604
  )
606
605
  shopContentContainerListData.forEach((item, index) => {
607
606
  item.key = `${getThisTimeKey + index}`
608
607
  item.floors = []
609
608
  item.includeUids &&
610
609
  item.includeUids.forEach((floorUid) => {
611
610
  const getFloorData = shopContentFloorListData.find(
612
611
  (floorItem) => floorItem.uid === floorUid,
613
612
  )
614
613
  if (getFloorData) {
615
614
  const changeFloorData = {
616
615
  containerId: item.containerId,
617
616
  containerIndex: index,
618
617
  ...getFloorData,
619
618
  }
620
619
  const getCheckMoreCouponState =
621
620
  checkCouponAndChangeContainerSetData(getFloorData)
622
621
  if (getCheckMoreCouponState) {
623
622
  item.marginLeft && (item.marginLeft = 0)
624
623
  item.marginRight && (item.marginRight = 0)
625
624
  item.borderRadius && (item.borderRadius = 0)
626
625
  }
627
626
  if (getFloorData?.floorExtInfo?.floorLoadWay === 2) {
628
627
  const getSysFloorToLoadTypeRes = isIsvFloorUseable(
629
628
  getFloorData,
630
629
  exceptionReportFn,
631
630
  )
632
631
  !getSysFloorToLoadTypeRes &&
633
632
  (getFloorData.floorExtInfo.floorLoadWay = 1)
634
633
  }
635
634
  item.floors.push(changeFloorData)
636
635
  }
637
636
  })
638
637
  if (
639
638
  ((!isvdev && index === 0) || (isvdev && index === 1)) &&
640
639
  item?.containerPosition == 'content' &&
641
640
  item?.marginBottom > 0 &&
642
641
  !clearFirstContaierMarginTop
643
642
  ) {
644
643
  item.marginTop = item.marginBottom
645
644
  }
646
645
  })
647
646
  shopContentContainerListData = shopContentContainerListData.filter(
648
647
  (item) =>
649
648
  item.floors.length > 0 &&
650
649
  unableIsvContainerListData.every(
651
650
  (containerItem) => containerItem.containerId != item.containerId,
652
651
  ),
653
652
  )
654
653
  console.log(
655
654
  'dealShopContentData isWxMinAndWxapp:',
656
655
  isWxMinAndWxapp,
657
656
  'weappJumpToH5:',
658
657
  pageData?.homeExtInfo?.weappJumpToH5,
659
658
  )
660
659
  if (isProd && isWxMinAndWxapp) {
661
660
  shopContentContainerListData = shopContentContainerListData.filter(
662
661
  (item) =>
663
662
  item.floors.length > 0 &&
664
663
  !isIsvContainer(
665
664
  item.containerId,
666
665
  shopContentFloorListData,
667
666
  shopContentContainerListData,
668
667
  ),
669
668
  )
670
669
  }
671
670
  shopContentContainerListData = [].concat(shopContentContainerListData)
672
671
  return {
673
672
  shopContentContainerListData,
674
673
  shopContentFloorListData,
675
674
  }
676
675
  const changeOpts = {
677
676
  title: '',
678
677
  icon: 'success',
679
678
  duration: 1500,
680
679
  mask: true,
681
680
  ...options,
682
681
  }
683
682
  if (changeOpts.title.length > 7) {
684
683
  showNormalToast(options)
685
684
  } else {
686
685
  Taro.showToast(changeOpts as any)
687
686
  }
688
687
  const changeOpts = {
689
688
  title: '',
690
689
  icon: 'error',
691
690
  duration: 1500,
692
691
  mask: true,
693
692
  ...options,
694
693
  }
695
694
  if (changeOpts.title.length > 7) {
696
695
  showNormalToast(options)
697
696
  } else {
698
697
  Taro.showToast(changeOpts as any)
699
698
  }
700
699
  Taro.showToast({
701
700
  title: '',
702
701
  icon: 'none',
703
702
  duration: 1500,
704
703
  mask: true,
705
704
  ...options,
706
705
  })
707
706
  return Taro.showLoading({
708
707
  title: text,
709
708
  })
710
709
  return new Promise(() => {
711
710
  Taro.nextTick(() => {
712
711
  setTimeout(() => {
713
712
  Taro.hideLoading(options)
714
713
  }, 300)
715
714
  })
716
715
  })
717
716
  return CHANNEL_TYPE[JDShopViewBusinessPathType.HOME]
718
717
  const {
719
718
  tabActive = SECTION_HOME_TAB_NAME_TYPE[
720
719
  SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
721
720
  ],
722
721
  sceneId,
723
722
  } = query
724
723
  let changeTabActive = tabActive
725
724
  if (sceneId) {
726
725
  if (isH5) {
727
726
  if (sceneId == '1002') {
728
727
  changeTabActive =
729
728
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT]
730
729
  }
731
730
  else if (sceneId == '1003') {
732
731
  changeTabActive =
733
732
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_ACTIVITY]
734
733
  }
735
734
  } else if (isWxMinAndWxapp) {
736
735
  if (sceneId == '1001' || sceneId == '1002') {
737
736
  changeTabActive =
738
737
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT]
739
738
  }
740
739
  else if (sceneId == '1003') {
741
740
  changeTabActive =
742
741
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]
743
742
  }
744
743
  }
745
744
  }
746
745
  if (SECTION_HOME_TAB_QUERY_TYPE[changeTabActive]) {
747
746
  return {
748
747
  menuType: SHOP_MENU_ID_TYPE.HOME,
749
748
  tabActiveType: SECTION_HOME_TAB_QUERY_TYPE[changeTabActive],
750
749
  queryMenuTabActiveStr: `${SHOP_MENU_ID_TYPE.HOME}@${SECTION_HOME_TAB_QUERY_TYPE[changeTabActive]}`,
751
750
  }
752
751
  } else if (SHOP_MENU_ID_QUERY_NAME[changeTabActive]) {
753
752
  return {
754
753
  menuType: SHOP_MENU_ID_QUERY_NAME[changeTabActive],
755
754
  tabActiveType: 0,
756
755
  queryMenuTabActiveStr: `${SHOP_MENU_ID_QUERY_NAME[changeTabActive]}@0`,
757
756
  }
758
757
  } else {
759
758
  return {
760
759
  menuType: SHOP_MENU_ID_TYPE.HOME,
761
760
  tabActiveType: SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN,
762
761
  queryMenuTabActiveStr: `${SHOP_MENU_ID_TYPE.HOME}@${SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN}`,
763
762
  }
764
763
  }
765
764
  const deleteKeyList = [
766
765
  '$taroTimestamp',
767
766
  'cookie',
768
767
  'wdref',
769
768
  'navStart',
770
769
  'originOpts',
771
770
  'originParams',
772
771
  'originUrl',
773
772
  'referer',
774
773
  'stamp',
775
774
  ]
776
775
  let changeQueryData: any = { ...queryData }
777
776
  const qrCodeScene = changeQueryData?.scene ? changeQueryData?.scene : false
778
777
  const sceneQuery =
779
778
  qrCodeScene && typeof qrCodeScene == 'string'
780
779
  ? parseQueryUrlString(decodeURIComponent(qrCodeScene))
781
780
  : {}
782
781
  changeQueryData = { ...changeQueryData, ...sceneQuery }
783
782
  deleteKeyList.forEach((key) => {
784
783
  changeQueryData[key] && delete changeQueryData[key]
785
784
  })
786
785
  changeQueryData['shopid'] &&
787
786
  (changeQueryData['shopId'] = changeQueryData['shopid']) &&
788
787
  delete changeQueryData['shopid']
789
788
  changeQueryData['venderid'] &&
790
789
  (changeQueryData['venderId'] = changeQueryData['venderid']) &&
791
790
  delete changeQueryData['venderid']
792
791
  changeQueryData['vendorId'] &&
793
792
  (changeQueryData['venderId'] = changeQueryData['vendorId']) &&
794
793
  delete changeQueryData['vendorId']
795
794
  return changeQueryData
796
795
  let isUsable = false
797
796
  const modularPackResult = floorData?.floorExtInfo?.modularPackResult
798
797
  const modularPackResultObj = formatPackResult(modularPackResult)
799
798
  const bundleUrl = getBundleUrl(modularPackResultObj)
800
799
  const bundleFileName = getBundleFileName(modularPackResultObj)
801
800
  if (bundleUrl && bundleFileName) {
802
801
  isUsable = true
803
802
  }
804
803
  if (!isUsable && typeof exceptionReportFn === 'function') {
805
804
  exceptionReportFn({
806
805
  code: `${NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG}${SgmCustomCode.REMOTEMODULE_DATA}`,
807
806
  msg: {
808
807
  msg: `店铺h5楼层隐藏不显示。原因:模块数据不完备,楼层过滤。`,
809
808
  floorIdx: floorData?.floorIdx,
810
809
  uid: floorData?.uid,
811
810
  shopId: floorData?.floorExtInfo?.shopId,
812
811
  moduleId: floorData?.moduleId,
813
812
  moduleDesignerType: floorData?.floorExtInfo?.moduleDesignerType,
814
813
  floorLoadWay: floorData?.floorExtInfo?.floorLoadWay,
815
814
  floorKind: floorData?.floorExtInfo?.floorKind,
816
815
  middleTemplateId: floorData?.middleTemplateId,
817
816
  modularPackResult: modularPackResult,
818
817
  },
819
818
  })
820
819
  }
821
820
  return isUsable
822
821
  const objContainer = containerListData.find(
823
822
  (item) => item.containerId === containerId,
824
823
  )
825
824
  return (
826
825
  objContainer?.includeUids?.some((itemUid) => {
827
826
  const objectFloor = floorListData.find(
828
827
  (floorItem) => itemUid === floorItem.uid,
829
828
  )
830
829
  return RemoteLoadFloorList.includes(objectFloor?.floorExtInfo?.moduleFlag)
831
830
  }) ?? false
832
831
  )
833
832
  floorListData,
834
833
  containerListData,
835
834
  exceptionReportFn?,
836
835
  const unableIsvFloorListData = floorListData.filter(
837
836
  (floorItem) =>
838
837
  RemoteLoadFloorList.includes(floorItem?.floorExtInfo?.moduleFlag) &&
839
838
  !isIsvFloorUseable(floorItem, exceptionReportFn),
840
839
  )
841
840
  const unableIsvFloorUidList = unableIsvFloorListData.map(
842
841
  (floorItem) => floorItem.uid,
843
842
  )
844
843
  const unableIsvContainerListData = containerListData.filter(
845
844
  (item) =>
846
845
  item.includeUids &&
847
846
  item.includeUids.every(
848
847
  (itemUid) => unableIsvFloorUidList.indexOf(itemUid) != -1,
849
848
  ),
850
849
  )
851
850
  return unableIsvContainerListData
852
851
  return -2
853
852
  return customObj
854
853
  return /openApp\.jdMobile:\/\/virtual\?params=/i.test(openAppUrl)
855
854
  let getParams = false
856
855
  if (isOpenJdAppUrl(openAppUrl)) {
857
856
  try {
858
857
  getParams = openAppUrl.replace(
859
858
  /openApp\.jdMobile:\/\/virtual\?params=/i,
860
859
  '',
861
860
  )
862
861
  getParams = JSON.parse(String(getParams))
863
862
  } catch (e) {
864
863
  console.log(e)
865
864
  }
866
865
  }
867
866
  return getParams
868
867
  const getLastParams = Object.assign({}, openParams)
869
868
  return `openapp.jdmobile://virtual?params=${JSON.stringify(getLastParams)}`
870
869
  if (val === null || val === '' || typeof val === 'undefined') {
871
870
  return true
872
871
  }
873
872
  return false
874
873
  const {
875
874
  moduleId = 'none',
876
875
  entrance = 'none',
877
876
  sourceType = 'none',
878
877
  sourceValue = 'none',
879
878
  } = params
880
879
  if (isIosDevice) {
881
880
  return `${moduleId}#${entrance}`
882
881
  } else if (isAndroidDevice) {
883
882
  return `${sourceType}#${sourceValue}`
884
883
  }
885
884
  return 'none#none'
886
885
  if (data && typeof data === 'object') {
887
886
  let getOpenAppData = { ...data }
888
887
  try {
889
888
  const { sourceInfo, designerId, templateId, source } = getOpenAppData
890
889
  if (designerId && templateId) {
891
890
  getOpenAppData = Object.assign({}, getOpenAppData, {
892
891
  sourceInfo: {
893
892
  entrance: '设计师预览',
894
893
  },
895
894
  })
896
895
  } else if (sourceInfo) {
897
896
  const { entrance } = sourceInfo
898
897
  getOpenAppData.sourceInfo.entrance =
899
898
  entrance && entrance.length > 0 ? entrance : '其他'
900
899
  } else if (source && !sourceInfo) {
901
900
  if (typeof source === 'object') {
902
901
  const { sourceType, entrance, sourceValue, moduleId } = source
903
902
  getOpenAppData = Object.assign({}, getOpenAppData, {
904
903
  sourceInfo: {
905
904
  entrance: sourceType || entrance || '其他',
906
905
  moduleId: sourceValue || moduleId || '-100',
907
906
  },
908
907
  })
909
908
  } else {
910
909
  getOpenAppData = Object.assign({}, getOpenAppData, {
911
910
  sourceInfo: {
912
911
  entrance: source,
913
912
  },
914
913
  })
915
914
  }
916
915
  } else {
917
916
  getOpenAppData = Object.assign({}, getOpenAppData, {
918
917
  sourceInfo: {
919
918
  entrance: '其他',
920
919
  },
921
920
  })
922
921
  }
923
922
  } catch (e) {
924
923
  console.log(e)
925
924
  }
926
925
  return getOpenAppData
927
926
  }
928
927
  return data
929
928
  return displayObj
930
929
  if (typeof input === 'string') {
931
930
  try {
932
931
  return JSON.parse(input)
933
932
  } catch (e) {
934
933
  console.error('JSON解析失败', e)
935
934
  return {}
936
935
  }
937
936
  }
938
937
  return input || {}
939
938
  return false
940
939
  isJdApp,
941
940
  isWxApp,
942
941
  isIosDevice,
943
942
  isAndroidDevice,
944
943
  isJdAndIosDevice,
945
944
  isJdAndAndroidDevice,
946
945
  isWxMin,
947
946
  isWxMinAndWxapp,
948
947
  isJdMin,
949
948
  isMin,
950
949
  isJdMinAndHarmony,
951
950
  isH5,
952
951
  isH5AndJdShopView,
953
952
  isImageOptimizeEnable,
954
953
  isChartH5,
955
954
  isH5AndJdShopViewNativeScroll,
956
955
  isH5AndJdShopViewH5Scroll,
957
956
  isH5AndJdShopH5CustomScrollView,
958
957
  isWxMiniH5View,
959
958
  sliceArrToChunkList,
960
959
  dealAddress,
961
960
  objectToUrlEncode,
962
961
  parseQueryUrlString,
963
962
  setLowSmallPicUrl,
964
963
  getJfsImage,
965
964
  getQualityImage,
966
965
  countStringify,
967
966
  setTaroStorage,
968
967
  getTaroStorageKeyValue,
969
968
  removeTaroStorageKey,
970
969
  clearTaroStorageKey,
971
970
  getSystemInfos,
972
971
  addHttps,
973
972
  dateFormat,
974
973
  throttle,
975
974
  lodashThrottle,
976
975
  debounce,
977
976
  getTelephone,
978
977
  rgbToHex,
979
978
  hexToRgb,
980
979
  getRandom,
981
980
  getWxAppCookieStr,
982
981
  pxTransformFromData,
983
982
  dealShopContentData,
984
983
  showSuccessToast,
985
984
  showFailToast,
986
985
  showNormalToast,
987
986
  showShopLoading,
988
987
  hideShopLoading,
989
988
  getAppChannelType,
990
989
  formatTabActiveMenuType,
991
990
  filterUrlQueryData,
992
991
  getAvifSupport,
993
992
  getWebpSupport,
994
993
  isMemberPage,
995
994
  sgmCustomReport,
996
995
  isOpenJdAppUrl,
997
996
  jdOpenAppParams,
998
997
  createJdOpenAppUrl,
999
998
  dealJdOpenAppData,
1000
999
  isEmpty,
1001
1000
  getJdAppReportPageSource,
1002
1001
  isAppClassifyPage,
1003
1002
  getQualityImageNew,
1004
1003
  getQualityImageOld,
1005
1004
  isPc,
1006
1005
  ipLoc_djd,
1007
1006
  jdAppVersionCompare,
1008
1007
  dealNativePixelToCssPixel,
1009
1008
  isAppStowShop,
1009
+ import Taro from "@tarojs/taro";
1010
1010
  SHOP_MENU_ID_TYPE,
1011
1011
  SHOP_MENU_ID_QUERY_NAME,
1012
1012
  SECTION_HOME_TAB_TYPE,
1013
1013
  SECTION_HOME_TAB_NAME_TYPE,
1014
1014
  SECTION_HOME_TAB_QUERY_TYPE,
1015
1015
  CHANNEL_TYPE,
1016
1016
  JDShopViewBusinessPathType,
1017
1017
  FloorModuleType,
1018
1018
  RemoteLoadFloorList,
1019
1019
  MPAAS_CONFIG_APP_VERSION,
1020
1020
  FLOOR_KIND,
1021
1021
  getBundleUrl,
1022
1022
  getBundleFileName,
1023
1023
  formatPackResult,
1024
1024
  getTaroVersion,
1025
1025
  SgmCustomCode,
1026
1026
  NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG,
1027
1027
  key: string,
1028
1028
  value: string | object,
1029
1029
  successBack?: any,
1030
1030
  failBack?: any,
1031
1031
  return Taro.setStorage({
1032
1032
  key: key,
1033
1033
  data: value,
1034
1034
  success: successBack,
1035
1035
  fail: failBack,
1036
1036
  })
1037
1037
  return Taro.getStorageSync(key);
1038
1038
  return Taro.removeStorage({
1039
1039
  key: key,
1040
1040
  });
1041
1041
  return Taro.clearStorage();
1042
1042
  if (isH5) {
1043
1043
  const avifCache = getTaroStorageKeyValue(KEY_AVIF);
1044
1044
  if (avifCache === null || avifCache === "" || forceUpdate) {
1045
1045
  const img = new Image();
1046
1046
  img.onload = function () {
1047
1047
  if (img.height > 0 && img.width > 0) {
1048
1048
  setTaroStorage(KEY_AVIF, "1");
1049
1049
  } else {
1050
1050
  setTaroStorage(KEY_AVIF, "0");
1051
1051
  }
1052
1052
  };
1053
1053
  img.onerror = () => {
1054
1054
  setTaroStorage(KEY_AVIF, "0");
1055
1055
  };
1056
1056
  img.src =
1057
1057
  "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";
1058
1058
  }
1059
1059
  const webpCache = getTaroStorageKeyValue(KEY_WEBP);
1060
1060
  if (webpCache === null || webpCache === "" || forceUpdate) {
1061
1061
  const img = new Image();
1062
1062
  img.onload = function () {
1063
1063
  if (img.height > 0 && img.width > 0) {
1064
1064
  setTaroStorage(KEY_WEBP, "1");
1065
1065
  } else {
1066
1066
  setTaroStorage(KEY_WEBP, "0");
1067
1067
  }
1068
1068
  };
1069
1069
  img.onerror = () => {
1070
1070
  setTaroStorage(KEY_WEBP, "0");
1071
1071
  };
1072
1072
  img.src =
1073
1073
  "data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAUAmJaQAA3AA/vz0AAA=";
1074
1074
  }
1075
1075
  }
1076
1076
  imageFormatSupport(false);
1077
1077
  setTimeout(imageFormatSupport, 5000);
1078
1078
  const resultList: Array<any> = [],
1079
1079
  arrLen = arr.length;
1080
1080
  if (arrLen) {
1081
1081
  if (arrLen > size) {
1082
1082
  for (let i = 0; i < arrLen; i = i + size) {
1083
1083
  resultList.push(arr.slice(i, i + size));
1084
1084
  }
1085
1085
  } else {
1086
1086
  resultList.push(arr);
1087
1087
  }
1088
1088
  }
1089
1089
  return resultList;
1090
1090
  let _address = ids;
1091
1091
  const _areaAreaSplit = ids.split(".");
1092
1092
  const _areaAreaSplit2 = ids.split("_");
1093
1093
  _address = _areaAreaSplit.length === 2 ? _areaAreaSplit[0] : _address;
1094
1094
  _address = _areaAreaSplit2.length === 3 ? `${_areaAreaSplit2}_0` : _address;
1095
1095
  return _address;
1096
1096
  let paramStr = "";
1097
1097
  obj &&
1098
1098
  Object.keys(obj).forEach((key, index) => {
1099
1099
  const getValue = `${obj[key]}`
1100
1100
  .replace(/undefined/, "")
1101
1101
  .replace(/null/, "");
1102
1102
  paramStr += `${index === 0 ? "" : "&"}${key}=${encodeURIComponent(
1103
1103
  getValue
1104
1104
  )}`;
1105
1105
  });
1106
1106
  return paramStr;
1107
1107
  const result = {};
1108
1108
  if (
1109
1109
  !urlOrQueryStr ||
1110
1110
  ("string" !== typeof urlOrQueryStr && String !== urlOrQueryStr.constructor)
1111
1111
  ) {
1112
1112
  return result;
1113
1113
  }
1114
1114
  if (urlOrQueryStr.indexOf("?") > -1) {
1115
1115
  const queryStr = urlOrQueryStr.split("?");
1116
1116
  const queryItemList =
1117
1117
  queryStr && queryStr.length > 1 ? queryStr[1].split("&") : [];
1118
1118
  const queryItemListLen = queryItemList.length;
1119
1119
  queryItemListLen > 0 &&
1120
1120
  queryItemList.forEach((item) => {
1121
1121
  const thisItemList = item.split("=");
1122
1122
  result[thisItemList[0]] = thisItemList[1];
1123
1123
  });
1124
1124
  } else {
1125
1125
  const queryItemList =
1126
1126
  urlOrQueryStr.indexOf("&") > -1
1127
1127
  ? urlOrQueryStr.split("&")
1128
1128
  : [urlOrQueryStr];
1129
1129
  const queryItemListLen = queryItemList.length;
1130
1130
  queryItemListLen > 0 &&
1131
1131
  queryItemList.forEach((item) => {
1132
1132
  const thisItemList = item.split("=");
1133
1133
  result[thisItemList[0]] = thisItemList[1];
1134
1134
  });
1135
1135
  }
1136
1136
  return result;
1137
1137
  url: string,
1138
1138
  size?: {
1139
1139
  w: number;
1140
1140
  h: number;
1141
1141
  },
1142
1142
  quality?: number
1143
1143
  if (url && size) {
1144
1144
  const _w = Math.floor(size.w);
1145
1145
  const _h = Math.floor(size.h);
1146
1146
  if (url.match(/gif$/i)) {
1147
1147
  return url;
1148
1148
  } else {
1149
1149
  if (_w > 0 && _h > 0) {
1150
1150
  url = url.replace("jfs/", `s${_w}x${_h}_jfs/`);
1151
1151
  }
1152
1152
  url += quality != null ? `!q${quality}.dpg` : ".dpg";
1153
1153
  }
1154
1154
  }
1155
1155
  return url;
1156
1156
  url: string,
1157
1157
  jfsImgInfo: UtilsInterFace.getJfsImageInfo = {}
1158
1158
  if (url.match(/\.(jpg|png|dpg)$/i)) {
1159
1159
  const { width, height, quality } = jfsImgInfo;
1160
1160
  if (typeof width === "number" || typeof height === "number") {
1161
1161
  url = url.replace(
1162
1162
  "/jfs/",
1163
1163
  `/s${Math.floor(width || 0)}x${Math.floor(height || 0)}_jfs/`
1164
1164
  );
1165
1165
  }
1166
1166
  if (
1167
1167
  typeof quality === "number" &&
1168
1168
  quality > 0 &&
1169
1169
  quality < 100 &&
1170
1170
  url.match(/\.jpg$/i)
1171
1171
  ) {
1172
1172
  url += `!q${quality}.dpg`;
1173
1173
  }
1174
1174
  }
1175
1175
  return addHttps(url);
1176
1176
  if (imgUrl) {
1177
1177
  if (
1178
1178
  !imgUrl.match(
1179
1179
  /(storage\.360buyimg\.com)|(jdcloud-oss\.com)|(imgcps\.jd\.com)|((\w+)\.300hu\.com)|(thirdwx\.qlogo\.cn)|(!q)|gif|dpg$/i
1180
1180
  )
1181
1181
  ) {
1182
1182
  if (!imgUrl.includes("360buyimg.com")) {
1183
1183
  imgUrl = "//m.360buyimg.com/cms/" + imgUrl;
1184
1184
  }
1185
1185
  if (quality != 100)
1186
1186
  imgUrl += /\.png/.test(imgUrl) ? ".dpg" : `!q${quality}`;
1187
1187
  }
1188
1188
  imgUrl = imgUrl.match(/^\/\//) ? `https:${imgUrl}` : imgUrl;
1189
1189
  }
1190
1190
  return imgUrl;
1191
1191
  const result = value % step;
1192
1192
  return result === 0 ? value : Math.ceil(value / step) * step;
1193
1193
  const MAX = 3.5;
1194
1194
  return Math.min(window?.devicePixelRatio ?? 2, MAX);
1195
1195
  isSkuImage: boolean;
1196
1196
  size: number;
1197
1197
  imgUrl: string,
1198
1198
  options: QualityOptions,
1199
1199
  isIgnoreOptimizeFromServer: boolean = false
1200
1200
  if (!imgUrl) {
1201
1201
  console.error(
1202
1202
  "The input parameter imageUrl for the getQualityImage() cannot be empty!"
1203
1203
  );
1204
1204
  return imgUrl;
1205
1205
  }
1206
1206
  console.warn(
1207
1207
  "� ~~ file: utils.ts:369 ~~ getQualityImageNew ~~ isIgnoreOptimizeFromServer:",
1208
1208
  isIgnoreOptimizeFromServer
1209
1209
  );
1210
1210
  if (isIgnoreOptimizeFromServer) {
1211
1211
  imgUrl = imgUrl.replace(/\.(jpe?g|png).*/, ".$1");
1212
1212
  }
1213
1213
  if (!/^((https?):)?\/\//.test(imgUrl)) {
1214
1214
  imgUrl = "//m.360buyimg.com/cms/" + imgUrl;
1215
1215
  }
1216
1216
  const imgServerRegExp = /(img|m)\d{0,2}\.360buyimg\.com\/.*\.(jpe?g|png)/i;
1217
1217
  if (!imgServerRegExp.test(imgUrl)) {
1218
1218
  return imgUrl;
1219
1219
  }
1220
1220
  imgUrl = /^\/\//.test(imgUrl) ? `https:${imgUrl}` : imgUrl;
1221
1221
  const { isSkuImage, size } = options || {};
1222
1222
  const needReduceSize = isSkuImage && size;
1223
1223
  if (needReduceSize) {
1224
1224
  const devicePixelRatio = getDevicePixelRatio();
1225
1225
  const useWidth = getValueByStep(size * devicePixelRatio, 40);
1226
1226
  imgUrl = imgUrl.replace(/\/[^\/]*jfs\//, `/s${useWidth}x${useWidth}_jfs/`);
1227
1227
  }
1228
1228
  const needCompress = !global?.info?.pageInfo?.isVipShop;
1229
1229
  const result = imgUrl.match(/\/\w+\.(jpe?g|png)$/);
1230
1230
  if (needCompress && result) {
1231
1231
  if (getAvifSupport() === "1") {
1232
1232
  imgUrl += ".avif";
1233
1233
  } else if (getWebpSupport() === "1") {
1234
1234
  imgUrl += ".webp";
1235
1235
  } else if (/jpe?g/.test(result[1])) {
1236
1236
  imgUrl += "!q80";
1237
1237
  }
1238
1238
  }
1239
1239
  if (needReduceSize) {
1240
1240
  imgUrl += "!z2";
1241
1241
  }
1242
1242
  return imgUrl;
1243
1243
  if (imgUrl) {
1244
1244
  if (
1245
1245
  !imgUrl.match(
1246
1246
  /(storage\.360buyimg\.com)|(jdcloud-oss\.com)|((\w+)\.300hu\.com)|(thirdwx\.qlogo\.cn)|(!q)|gif|dpg$/i
1247
1247
  )
1248
1248
  ) {
1249
1249
  if (!imgUrl.includes("360buyimg.com")) {
1250
1250
  imgUrl = "//m.360buyimg.com/cms/" + imgUrl;
1251
1251
  }
1252
1252
  if (quality != 100)
1253
1253
  imgUrl += /\.png/.test(imgUrl) ? ".dpg" : `!q${quality}`;
1254
1254
  }
1255
1255
  imgUrl = imgUrl.match(/^\/\//) ? `https:${imgUrl}` : imgUrl;
1256
1256
  }
1257
1257
  return imgUrl;
1258
1258
  return getTaroStorageKeyValue(KEY_AVIF) || "0";
1259
1259
  return getTaroStorageKeyValue(KEY_WEBP) || "0";
1260
1260
  count: number,
1261
1261
  fixedNum = 1,
1262
1262
  unit = "万",
1263
1263
  maxNum = 10000
1264
1264
  count = Number(count);
1265
1265
  const getMaxNum = count > 100000000 ? 100000000 : maxNum;
1266
1266
  const getUnit = count > 100000000 ? "亿" : unit;
1267
1267
  if (count >= getMaxNum) {
1268
1268
  return (count / getMaxNum).toFixed(fixedNum) + getUnit;
1269
1269
  }
1270
1270
  return count;
1271
1271
  const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfo || {
1272
1272
  platform: "",
1273
1273
  model: "",
1274
1274
  system: "",
1275
1275
  };
1276
1276
  const isIOS = !!systemInfo.system.match(/ios/i);
1277
1277
  const isAndroid = !!systemInfo.system.match(/android/i);
1278
1278
  if (!systemInfo.statusBarHeight) {
1279
1279
  systemInfo.statusBarHeight = screenHeight - windowHeight - 20;
1280
1280
  systemInfo.navBarExtendHeight = 0;
1281
1281
  } else {
1282
1282
  if (isIOS) {
1283
1283
  systemInfo.navBarExtendHeight = 4;
1284
1284
  } else {
1285
1285
  systemInfo.navBarExtendHeight = 0;
1286
1286
  }
1287
1287
  }
1288
1288
  let rect = Taro.getMenuButtonBoundingClientRect
1289
1289
  ? Taro.getMenuButtonBoundingClientRect()
1290
1290
  : null;
1291
1291
  if (!rect || !rect.width || !rect.top || !rect.left || !rect.height) {
1292
1292
  let gap = 0;
1293
1293
  let width = 96;
1294
1294
  if (systemInfo.platform === "android") {
1295
1295
  gap = 8;
1296
1296
  width = 96;
1297
1297
  } else if (systemInfo.platform === "devtools") {
1298
1298
  if (isIOS) {
1299
1299
  gap = 5.5;
1300
1300
  } else {
1301
1301
  gap = 7.5;
1302
1302
  }
1303
1303
  } else {
1304
1304
  gap = 4;
1305
1305
  width = 88;
1306
1306
  }
1307
1307
  rect = {
1308
1308
  bottom: systemInfo.statusBarHeight + gap + 32,
1309
1309
  height: 32,
1310
1310
  left: systemInfo.windowWidth - width - 10,
1311
1311
  right: systemInfo.windowWidth - 10,
1312
1312
  top: systemInfo.statusBarHeight + gap,
1313
1313
  width,
1314
1314
  };
1315
1315
  }
1316
1316
  const gap = rect.top - systemInfo.statusBarHeight;
1317
1317
  systemInfo.navBarTopToStatusBar = gap;
1318
1318
  systemInfo.navBarHeight = 2 * gap + rect.height;
1319
1319
  systemInfo.capsulePosition = rect;
1320
1320
  systemInfo.isIOS = isIOS;
1321
1321
  systemInfo.isAndroid = isAndroid;
1322
1322
  return systemInfo;
1323
1323
  if (str.match(/^\/\//)) {
1324
1324
  str = "https:" + str;
1325
1325
  }
1326
1326
  return str;
1327
1327
  dateTimeOrdate: Date | string | number | null,
1328
1328
  format = "yyyy-MM-dd HH:mm:ss",
1329
1329
  noPadStart = {
1330
1330
  M: "0",
1331
1331
  d: "0",
1332
1332
  H: "0",
1333
1333
  m: "0",
1334
1334
  s: "0",
1335
1335
  }
1336
1336
  let dateResult = "";
1337
1337
  const padStarts = Object.assign(
1338
1338
  {
1339
1339
  M: "0",
1340
1340
  d: "0",
1341
1341
  H: "0",
1342
1342
  m: "0",
1343
1343
  s: "0",
1344
1344
  },
1345
1345
  noPadStart
1346
1346
  );
1347
1347
  if (dateTimeOrdate) {
1348
1348
  let changeDateTimeOrdate = dateTimeOrdate;
1349
1349
  const getChangeDateTimeToNumber = Number(changeDateTimeOrdate);
1350
1350
  if (getChangeDateTimeToNumber) {
1351
1351
  changeDateTimeOrdate = getChangeDateTimeToNumber;
1352
1352
  } else {
1353
1353
  changeDateTimeOrdate = `${changeDateTimeOrdate}`
1354
1354
  .replace(/-/g, "/")
1355
1355
  .replace(/\./g, "/");
1356
1356
  }
1357
1357
  const nowDate =
1358
1358
  dateTimeOrdate instanceof Date
1359
1359
  ? dateTimeOrdate
1360
1360
  : new Date(changeDateTimeOrdate);
1361
1361
  const dateMap = {
1362
1362
  y: `${nowDate.getFullYear()}`,
1363
1363
  M: `${nowDate.getMonth() + 1}`.padStart(2, padStarts["M"]),
1364
1364
  d: `${nowDate.getDate()}`.padStart(2, padStarts["d"]),
1365
1365
  H: `${nowDate.getHours()}`.padStart(2, padStarts["H"]),
1366
1366
  m: `${nowDate.getMinutes()}`.padStart(2, padStarts["m"]),
1367
1367
  s: `${nowDate.getSeconds()}`.padStart(2, padStarts["s"]),
1368
1368
  };
1369
1369
  const regDate = new RegExp("y+|M+|d+|H+|m+|s+", "g");
1370
1370
  const regYear = new RegExp("y");
1371
1371
  dateResult = format.replace(regDate, (v) => {
1372
1372
  let changeValue = v;
1373
1373
  if (regYear.test(changeValue)) {
1374
1374
  const thisYear = dateMap.y;
1375
1375
  const subValueLen = 4 - changeValue.length;
1376
1376
  changeValue = thisYear.substr(subValueLen);
1377
1377
  } else {
1378
1378
  const dateKey = v.substr(0, 1);
1379
1379
  changeValue = dateMap[dateKey];
1380
1380
  }
1381
1381
  return changeValue;
1382
1382
  });
1383
1383
  }
1384
1384
  return dateResult;
1385
1385
  let timer: any = null;
1386
1386
  let startTime = Date.now();
1387
1387
  return function () {
1388
1388
  const curTime = Date.now();
1389
1389
  const remaining = delay - (curTime - startTime);
1390
1390
  const context = this;
1391
1391
  const args = arguments;
1392
1392
  clearTimeout(timer);
1393
1393
  if (remaining <= 0) {
1394
1394
  func.apply(context, args);
1395
1395
  startTime = Date.now();
1396
1396
  } else {
1397
1397
  timer = setTimeout(func, remaining);
1398
1398
  }
1399
1399
  };
1400
1400
  let context, args, result;
1401
1401
  let timeout = null;
1402
1402
  let previous = 0;
1403
1403
  if (!options) options = {};
1404
1404
  const later = function () {
1405
1405
  previous = options.leading === false ? 0 : Date.now();
1406
1406
  timeout = null;
1407
1407
  result = func.apply(context, args);
1408
1408
  if (!timeout) context = args = null;
1409
1409
  };
1410
1410
  return function () {
1411
1411
  const now = Date.now();
1412
1412
  if (!previous && options.leading === false) previous = now;
1413
1413
  const remaining = wait - (now - previous);
1414
1414
  context = this;
1415
1415
  args = arguments;
1416
1416
  if (remaining <= 0 || remaining > wait) {
1417
1417
  if (timeout) {
1418
1418
  clearTimeout(timeout);
1419
1419
  timeout = null;
1420
1420
  }
1421
1421
  previous = now;
1422
1422
  result = func.apply(context, args);
1423
1423
  if (!timeout) context = args = null;
1424
1424
  } else if (!timeout && options.trailing !== false) {
1425
1425
  timeout = setTimeout(later, remaining);
1426
1426
  }
1427
1427
  return result;
1428
1428
  };
1429
1429
  let timer: any = null;
1430
1430
  return function () {
1431
1431
  const context: any = this;
1432
1432
  const args = arguments;
1433
1433
  timer && clearTimeout(timer);
1434
1434
  timer = setTimeout(function () {
1435
1435
  fn.apply(context, args);
1436
1436
  }, delay);
1437
1437
  };
1438
1438
  if (txt) {
1439
1439
  txt = txt.trim();
1440
1440
  const reg = new RegExp(/[\d-]+/);
1441
1441
  const res = reg.exec(txt);
1442
1442
  if (res && res.length > 0) {
1443
1443
  let tel = res[0];
1444
1444
  if (tel && delSeparator) {
1445
1445
  tel = tel.replace(/-/g, "");
1446
1446
  }
1447
1447
  return tel;
1448
1448
  }
1449
1449
  }
1450
1450
  return "";
1451
1451
  if (rgb) {
1452
1452
  const reg = /^(rgb|RGB)/;
1453
1453
  const color = rgb;
1454
1454
  if (reg.test(color)) {
1455
1455
  let strHex = "#";
1456
1456
  const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
1457
1457
  for (let i = 0; i < colorArr.length; i++) {
1458
1458
  let hex = Number(colorArr[i]).toString(16);
1459
1459
  if (hex === "0") {
1460
1460
  hex += hex;
1461
1461
  }
1462
1462
  strHex += hex;
1463
1463
  }
1464
1464
  return strHex;
1465
1465
  } else {
1466
1466
  return String(color);
1467
1467
  }
1468
1468
  } else {
1469
1469
  return "";
1470
1470
  }
1471
1471
  if (hex) {
1472
1472
  const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
1473
1473
  let color = hex.toLowerCase();
1474
1474
  if (reg.test(color)) {
1475
1475
  if (color.length === 4) {
1476
1476
  let colorNew = "#";
1477
1477
  for (let i = 1; i < 4; i += 1) {
1478
1478
  colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
1479
1479
  }
1480
1480
  color = colorNew;
1481
1481
  }
1482
1482
  const colorChange: number[] = [];
1483
1483
  for (let i = 1; i < 7; i += 2) {
1484
1484
  colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
1485
1485
  }
1486
1486
  if (returnList) {
1487
1487
  return colorChange;
1488
1488
  } else {
1489
1489
  return "RGB(" + colorChange.join(",") + ")";
1490
1490
  }
1491
1491
  } else {
1492
1492
  return color;
1493
1493
  }
1494
1494
  } else {
1495
1495
  return "";
1496
1496
  }
1497
1497
  n: number,
1498
1498
  m: number,
1499
1499
  filterNum: number | undefined = undefined
1500
1500
  const c = m - n + 1;
1501
1501
  const res = Math.floor(Math.random() * c + n);
1502
1502
  if (filterNum && filterNum == res) {
1503
1503
  console.log("随机数二次开始", res, filterNum);
1504
1504
  return getRandom(n, m, filterNum);
1505
1505
  } else {
1506
1506
  return res;
1507
1507
  }
1508
1508
  wqCookieStr: string;
1509
1509
  wqCookie: {
1510
1510
  pin?: string;
1511
1511
  visitkey?: string;
1512
1512
  [key: string]: any;
1513
1513
  };
1514
1514
  const {
1515
1515
  jdpin,
1516
1516
  pinStatus,
1517
1517
  visitkey,
1518
1518
  unionid,
1519
1519
  skey,
1520
1520
  __jda,
1521
1521
  __jdv,
1522
1522
  __wga,
1523
1523
  wid,
1524
1524
  wq_skey,
1525
1525
  wq_uin,
1526
1526
  wq_auth_token,
1527
1527
  wxapp_scene,
1528
1528
  wq_unionid,
1529
1529
  wxapp_openid,
1530
1530
  wxapp_version,
1531
1531
  wxapp_type,
1532
1532
  appType,
1533
1533
  } = cookie;
1534
1534
  const ret: string[] = [];
1535
1535
  const getUserCookieObj = {};
1536
1536
  const createUseCookieArr = [
1537
1537
  jdpin,
1538
1538
  pinStatus,
1539
1539
  visitkey,
1540
1540
  unionid,
1541
1541
  skey,
1542
1542
  __jda,
1543
1543
  __jdv,
1544
1544
  __wga,
1545
1545
  wid,
1546
1546
  wq_skey,
1547
1547
  wq_uin,
1548
1548
  wq_auth_token,
1549
1549
  wxapp_scene,
1550
1550
  wq_unionid,
1551
1551
  wxapp_openid,
1552
1552
  wxapp_version,
1553
1553
  wxapp_type,
1554
1554
  appType,
1555
1555
  ];
1556
1556
  createUseCookieArr.forEach((keyItem) => {
1557
1557
  if (keyItem && keyItem["name"]) {
1558
1558
  let { name, value } = keyItem;
1559
1559
  name = name === "jdpin" ? "pin" : name;
1560
1560
  name === "pin" && ret.push(`pt_pin=${encodeURIComponent(value)}`);
1561
1561
  ret.push(`${name}=${encodeURIComponent(value)}`);
1562
1562
  getUserCookieObj[name] = value;
1563
1563
  }
1564
1564
  });
1565
1565
  return {
1566
1566
  wqCookieStr: ret.join(";"),
1567
1567
  wqCookie: getUserCookieObj,
1568
1568
  };
1569
1569
  num,
1570
1570
  widthSize = 375,
1571
1571
  layoutWidth = windowWidth
1572
1572
  const getNum = Number(num);
1573
1573
  return Math.round((getNum / widthSize) * layoutWidth);
1574
1574
  let checkState = false;
1575
1575
  const couponFloorModuleType = floorData?.floorExtInfo?.moduleFlag;
1576
1576
  if (couponFloorModuleType === FloorModuleType.COUPON) {
1577
1577
  try {
1578
1578
  const dataDefines = getFloorDataToDataDefines(floorData);
1579
1579
  const couponDataDefine = dataDefines
1580
1580
  ? dataDefines.filter((item) => {
1581
1581
  return item.type === "coupon";
1582
1582
  })
1583
1583
  : [],
1584
1584
  couponList = couponDataDefine[0]?.nodeText?.data
1585
1585
  ? couponDataDefine[0]?.nodeText?.data
1586
1586
  : [],
1587
1587
  couponLength = couponList.length,
1588
1588
  numShowPerLine = couponDataDefine[0]?.nodeText?.numShowPerLine
1589
1589
  ? couponDataDefine[0]?.nodeText?.numShowPerLine
1590
1590
  : 0;
1591
1591
  if (numShowPerLine === 0 && couponLength > 3) {
1592
1592
  checkState = true;
1593
1593
  }
1594
1594
  } catch (e) {
1595
1595
  checkState = false;
1596
1596
  }
1597
1597
  return checkState;
1598
1598
  }
1599
1599
  const {
1600
1600
  containers = [],
1601
1601
  floors = [],
1602
1602
  clearFirstContaierMarginTop = false,
1603
1603
  isLuxuryShop = false,
1604
1604
  isShowNativeImmersivePlayer = false,
1605
1605
  screenHeight = null,
1606
1606
  screenWidth = null,
1607
1607
  bottomBarHeight = null,
1608
1608
  } = pageData;
1609
1609
  console.log("dealShopContentData:", pageData, "isvdev:", isvdev);
1610
1610
  const getThisTimeKey = Date.now();
1611
1611
  let shopContentContainerListData = containers?.filter(
1612
1612
  (item) => (!isvdev && item.typeCode !== "mShopHeader") || isvdev
1613
1613
  );
1614
1614
  const shopContentFloorListData = floors?.filter(
1615
1615
  ({ floorPosition }) =>
1616
1616
  (!isvdev && floorPosition !== "header" && floorPosition !== "footer") ||
1617
1617
  isvdev
1618
1618
  );
1619
1619
  const unableIsvContainerListData = getUnableIsvContainerListData(
1620
1620
  shopContentFloorListData,
1621
1621
  shopContentContainerListData,
1622
1622
  exceptionReportFn
1623
1623
  );
1624
1624
  shopContentContainerListData.forEach((item, index) => {
1625
1625
  item.key = `${getThisTimeKey + index}`;
1626
1626
  item.floors = [];
1627
1627
  item.includeUids &&
1628
1628
  item.includeUids.forEach((floorUid) => {
1629
1629
  const getFloorData = shopContentFloorListData.find(
1630
1630
  (floorItem) => floorItem.uid === floorUid
1631
1631
  );
1632
1632
  if (getFloorData) {
1633
1633
  const changeFloorData = {
1634
1634
  containerId: item.containerId,
1635
1635
  containerIndex: index,
1636
1636
  ...getFloorData,
1637
1637
  };
1638
1638
  const getCheckMoreCouponState =
1639
1639
  checkCouponAndChangeContainerSetData(getFloorData);
1640
1640
  if (getCheckMoreCouponState) {
1641
1641
  item.marginLeft && (item.marginLeft = 0);
1642
1642
  item.marginRight && (item.marginRight = 0);
1643
1643
  item.borderRadius && (item.borderRadius = 0);
1644
1644
  }
1645
1645
  if (getFloorData?.floorExtInfo?.floorLoadWay === 2) {
1646
1646
  const getSysFloorToLoadTypeRes = isIsvFloorUseable(
1647
1647
  getFloorData,
1648
1648
  exceptionReportFn
1649
1649
  );
1650
1650
  !getSysFloorToLoadTypeRes &&
1651
1651
  (getFloorData.floorExtInfo.floorLoadWay = 1);
1652
1652
  }
1653
1653
  item.floors.push(changeFloorData);
1654
1654
  }
1655
1655
  });
1656
1656
  if (
1657
1657
  ((!isvdev && index === 0) || (isvdev && index === 1)) &&
1658
1658
  item?.containerPosition == "content" &&
1659
1659
  item?.marginBottom > 0 &&
1660
1660
  !clearFirstContaierMarginTop
1661
1661
  ) {
1662
1662
  item.marginTop = item.marginBottom;
1663
1663
  }
1664
1664
  });
1665
1665
  shopContentContainerListData = shopContentContainerListData.filter(
1666
1666
  (item) =>
1667
1667
  item.floors.length > 0 &&
1668
1668
  unableIsvContainerListData.every(
1669
1669
  (containerItem) => containerItem.containerId != item.containerId
1670
1670
  )
1671
1671
  );
1672
1672
  console.log(
1673
1673
  "dealShopContentData isWxMinAndWxapp:",
1674
1674
  isWxMinAndWxapp,
1675
1675
  "weappJumpToH5:",
1676
1676
  pageData?.homeExtInfo?.weappJumpToH5
1677
1677
  );
1678
1678
  if (isProd && isWxMinAndWxapp) {
1679
1679
  shopContentContainerListData = shopContentContainerListData.filter(
1680
1680
  (item) =>
1681
1681
  item.floors.length > 0 &&
1682
1682
  !isIsvContainer(
1683
1683
  item.containerId,
1684
1684
  shopContentFloorListData,
1685
1685
  shopContentContainerListData
1686
1686
  )
1687
1687
  );
1688
1688
  }
1689
1689
  shopContentContainerListData = [].concat(shopContentContainerListData);
1690
1690
  return {
1691
1691
  shopContentContainerListData,
1692
1692
  shopContentFloorListData,
1693
1693
  };
1694
1694
  const changeOpts = {
1695
1695
  title: "",
1696
1696
  icon: "success",
1697
1697
  duration: 1500,
1698
1698
  mask: true,
1699
1699
  ...options,
1700
1700
  };
1701
1701
  if (changeOpts.title.length > 7) {
1702
1702
  showNormalToast(options);
1703
1703
  } else {
1704
1704
  Taro.showToast(changeOpts as any);
1705
1705
  }
1706
1706
  const changeOpts = {
1707
1707
  title: "",
1708
1708
  icon: "error",
1709
1709
  duration: 1500,
1710
1710
  mask: true,
1711
1711
  ...options,
1712
1712
  };
1713
1713
  if (changeOpts.title.length > 7) {
1714
1714
  showNormalToast(options);
1715
1715
  } else {
1716
1716
  Taro.showToast(changeOpts as any);
1717
1717
  }
1718
1718
  Taro.showToast({
1719
1719
  title: "",
1720
1720
  icon: "none",
1721
1721
  duration: 1500,
1722
1722
  mask: true,
1723
1723
  ...options,
1724
1724
  });
1725
1725
  return Taro.showLoading({
1726
1726
  title: text,
1727
1727
  });
1728
1728
  return new Promise(() => {
1729
1729
  Taro.nextTick(() => {
1730
1730
  setTimeout(() => {
1731
1731
  Taro.hideLoading(options);
1732
1732
  }, 300);
1733
1733
  });
1734
1734
  });
1735
1735
  return CHANNEL_TYPE[JDShopViewBusinessPathType.HOME];
1736
1736
  const {
1737
1737
  tabActive = SECTION_HOME_TAB_NAME_TYPE[
1738
1738
  SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
1739
1739
  ],
1740
1740
  sceneId,
1741
1741
  } = query;
1742
1742
  let changeTabActive = tabActive;
1743
1743
  if (sceneId) {
1744
1744
  if (isH5) {
1745
1745
  if (sceneId == "1002") {
1746
1746
  changeTabActive =
1747
1747
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT];
1748
1748
  }
1749
1749
  else if (sceneId == "1003") {
1750
1750
  changeTabActive =
1751
1751
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_ACTIVITY];
1752
1752
  }
1753
1753
  } else if (isWxMinAndWxapp) {
1754
1754
  if (sceneId == "1001" || sceneId == "1002") {
1755
1755
  changeTabActive =
1756
1756
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT];
1757
1757
  }
1758
1758
  else if (sceneId == "1003") {
1759
1759
  changeTabActive =
1760
1760
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION];
1761
1761
  }
1762
1762
  }
1763
1763
  }
1764
1764
  if (SECTION_HOME_TAB_QUERY_TYPE[changeTabActive]) {
1765
1765
  return {
1766
1766
  menuType: SHOP_MENU_ID_TYPE.HOME,
1767
1767
  tabActiveType: SECTION_HOME_TAB_QUERY_TYPE[changeTabActive],
1768
1768
  queryMenuTabActiveStr: `${SHOP_MENU_ID_TYPE.HOME}@${SECTION_HOME_TAB_QUERY_TYPE[changeTabActive]}`,
1769
1769
  };
1770
1770
  } else if (SHOP_MENU_ID_QUERY_NAME[changeTabActive]) {
1771
1771
  return {
1772
1772
  menuType: SHOP_MENU_ID_QUERY_NAME[changeTabActive],
1773
1773
  tabActiveType: 0,
1774
1774
  queryMenuTabActiveStr: `${SHOP_MENU_ID_QUERY_NAME[changeTabActive]}@0`,
1775
1775
  };
1776
1776
  } else {
1777
1777
  return {
1778
1778
  menuType: SHOP_MENU_ID_TYPE.HOME,
1779
1779
  tabActiveType: SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN,
1780
1780
  queryMenuTabActiveStr: `${SHOP_MENU_ID_TYPE.HOME}@${SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN}`,
1781
1781
  };
1782
1782
  }
1783
1783
  const deleteKeyList = [
1784
1784
  "$taroTimestamp",
1785
1785
  "cookie",
1786
1786
  "wdref",
1787
1787
  "navStart",
1788
1788
  "originOpts",
1789
1789
  "originParams",
1790
1790
  "originUrl",
1791
1791
  "referer",
1792
1792
  "stamp",
1793
1793
  "hybrid",
1794
1794
  "sr",
1795
1795
  "navh",
1796
1796
  "stath",
1797
1797
  ];
1798
1798
  let changeQueryData: any = { ...queryData };
1799
1799
  const qrCodeScene = changeQueryData?.scene ? changeQueryData?.scene : false;
1800
1800
  const sceneQuery =
1801
1801
  qrCodeScene && typeof qrCodeScene == "string"
1802
1802
  ? parseQueryUrlString(decodeURIComponent(qrCodeScene))
1803
1803
  : {};
1804
1804
  changeQueryData = { ...changeQueryData, ...sceneQuery };
1805
1805
  deleteKeyList.forEach((key) => {
1806
1806
  changeQueryData[key] && delete changeQueryData[key];
1807
1807
  });
1808
1808
  changeQueryData["shopid"] &&
1809
1809
  (changeQueryData["shopId"] = changeQueryData["shopid"]) &&
1810
1810
  delete changeQueryData["shopid"];
1811
1811
  changeQueryData["venderid"] &&
1812
1812
  (changeQueryData["venderId"] = changeQueryData["venderid"]) &&
1813
1813
  delete changeQueryData["venderid"];
1814
1814
  changeQueryData["vendorId"] &&
1815
1815
  (changeQueryData["venderId"] = changeQueryData["vendorId"]) &&
1816
1816
  delete changeQueryData["vendorId"];
1817
1817
  return changeQueryData;
1818
1818
  let isUsable = false;
1819
1819
  const modularPackResult = floorData?.floorExtInfo?.modularPackResult;
1820
1820
  const modularPackResultObj = formatPackResult(modularPackResult);
1821
1821
  const bundleUrl = getBundleUrl(modularPackResultObj);
1822
1822
  const bundleFileName = getBundleFileName(modularPackResultObj);
1823
1823
  const taroVersion = getTaroVersion(modularPackResultObj);
1824
1824
  if (bundleUrl && bundleFileName) {
1825
1825
  isUsable = true;
1826
1826
  }
1827
1827
  if (!isUsable && typeof exceptionReportFn === "function") {
1828
1828
  exceptionReportFn({
1829
1829
  code: `${NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG}${
1830
1830
  floorData?.floorExtInfo?.floorKind === FLOOR_KIND.PDC_SYSTEM_MODULE
1831
1831
  ? SgmCustomCode.SYSTEMPDCMODULE_DATA
1832
1832
  : SgmCustomCode.REMOTEMODULE_DATA
1833
1833
  }`,
1834
1834
  msg: {
1835
1835
  msg: `店铺h5楼层隐藏不显示。原因:模块数据不完备,楼层过滤。`,
1836
1836
  floorIdx: floorData?.floorIdx,
1837
1837
  uid: floorData?.uid,
1838
1838
  shopId: floorData?.floorExtInfo?.shopId,
1839
1839
  moduleId: floorData?.moduleId,
1840
1840
  moduleDesignerType: floorData?.floorExtInfo?.moduleDesignerType,
1841
1841
  floorLoadWay: floorData?.floorExtInfo?.floorLoadWay,
1842
1842
  floorKind: floorData?.floorExtInfo?.floorKind,
1843
1843
  middleTemplateId: floorData?.middleTemplateId,
1844
1844
  modularPackResult: {
1845
1845
  bundleUrl,
1846
1846
  taroVersion,
1847
1847
  },
1848
1848
  },
1849
1849
  });
1850
1850
  }
1851
1851
  return isUsable;
1852
1852
  const objContainer = containerListData.find(
1853
1853
  (item) => item.containerId === containerId
1854
1854
  );
1855
1855
  return (
1856
1856
  objContainer?.includeUids?.some((itemUid) => {
1857
1857
  const objectFloor = floorListData.find(
1858
1858
  (floorItem) => itemUid === floorItem.uid
1859
1859
  );
1860
1860
  return RemoteLoadFloorList.includes(
1861
1861
  objectFloor?.floorExtInfo?.moduleFlag
1862
1862
  );
1863
1863
  }) ?? false
1864
1864
  );
1865
1865
  floorListData,
1866
1866
  containerListData,
1867
1867
  exceptionReportFn?
1868
1868
  const unableIsvFloorListData = floorListData.filter(
1869
1869
  (floorItem) =>
1870
1870
  RemoteLoadFloorList.includes(floorItem?.floorExtInfo?.moduleFlag) &&
1871
1871
  !isIsvFloorUseable(floorItem, exceptionReportFn)
1872
1872
  );
1873
1873
  const unableIsvFloorUidList = unableIsvFloorListData.map(
1874
1874
  (floorItem) => floorItem.uid
1875
1875
  );
1876
1876
  const unableIsvContainerListData = containerListData.filter(
1877
1877
  (item) =>
1878
1878
  item.includeUids &&
1879
1879
  item.includeUids.every(
1880
1880
  (itemUid) => unableIsvFloorUidList.indexOf(itemUid) != -1
1881
1881
  )
1882
1882
  );
1883
1883
  return unableIsvContainerListData;
1884
1884
  return -2;
1885
1885
  return customObj;
1886
1886
  return /openApp\.jdMobile:\/\/virtual\?params=/i.test(openAppUrl);
1887
1887
  let getParams = false;
1888
1888
  if (isOpenJdAppUrl(openAppUrl)) {
1889
1889
  try {
1890
1890
  getParams = openAppUrl.replace(
1891
1891
  /openApp\.jdMobile:\/\/virtual\?params=/i,
1892
1892
  ""
1893
1893
  );
1894
1894
  getParams = JSON.parse(String(getParams));
1895
1895
  } catch (e) {
1896
1896
  console.log(e);
1897
1897
  }
1898
1898
  }
1899
1899
  return getParams;
1900
1900
  const getLastParams = Object.assign({}, openParams);
1901
1901
  return `openapp.jdmobile://virtual?params=${JSON.stringify(getLastParams)}`;
1902
1902
  if (val === null || val === "" || typeof val === "undefined") {
1903
1903
  return true;
1904
1904
  }
1905
1905
  return false;
1906
1906
  const {
1907
1907
  moduleId = "none",
1908
1908
  entrance = "none",
1909
1909
  sourceType = "none",
1910
1910
  sourceValue = "none",
1911
1911
  } = params;
1912
1912
  if (isIosDevice) {
1913
1913
  return `${moduleId}#${entrance}`;
1914
1914
  } else if (isAndroidDevice) {
1915
1915
  return `${sourceType}#${sourceValue}`;
1916
1916
  }
1917
1917
  return "none#none";
1918
1918
  if (data && typeof data === "object") {
1919
1919
  let getOpenAppData = { ...data };
1920
1920
  try {
1921
1921
  const { sourceInfo, designerId, templateId, source } = getOpenAppData;
1922
1922
  if (designerId && templateId) {
1923
1923
  getOpenAppData = Object.assign({}, getOpenAppData, {
1924
1924
  sourceInfo: {
1925
1925
  entrance: "设计师预览",
1926
1926
  },
1927
1927
  });
1928
1928
  } else if (sourceInfo) {
1929
1929
  const { entrance } = sourceInfo;
1930
1930
  getOpenAppData.sourceInfo.entrance =
1931
1931
  entrance && entrance.length > 0 ? entrance : "其他";
1932
1932
  } else if (source && !sourceInfo) {
1933
1933
  if (typeof source === "object") {
1934
1934
  const { sourceType, entrance, sourceValue, moduleId } = source;
1935
1935
  getOpenAppData = Object.assign({}, getOpenAppData, {
1936
1936
  sourceInfo: {
1937
1937
  entrance: sourceType || entrance || "其他",
1938
1938
  moduleId: sourceValue || moduleId || "-100",
1939
1939
  },
1940
1940
  });
1941
1941
  } else {
1942
1942
  getOpenAppData = Object.assign({}, getOpenAppData, {
1943
1943
  sourceInfo: {
1944
1944
  entrance: source,
1945
1945
  },
1946
1946
  });
1947
1947
  }
1948
1948
  } else {
1949
1949
  getOpenAppData = Object.assign({}, getOpenAppData, {
1950
1950
  sourceInfo: {
1951
1951
  entrance: "其他",
1952
1952
  },
1953
1953
  });
1954
1954
  }
1955
1955
  } catch (e) {
1956
1956
  console.log(e);
1957
1957
  }
1958
1958
  return getOpenAppData;
1959
1959
  }
1960
1960
  return data;
1961
1961
  return displayObj;
1962
1962
  if (typeof input === "string") {
1963
1963
  try {
1964
1964
  return JSON.parse(input);
1965
1965
  } catch (e) {
1966
1966
  console.error("JSON解析失败", e);
1967
1967
  return {};
1968
1968
  }
1969
1969
  }
1970
1970
  return input || {};
1971
1971
  return false;
1972
1972
  isJdApp,
1973
1973
  isWxApp,
1974
1974
  isIosDevice,
1975
1975
  isAndroidDevice,
1976
1976
  isJdAndIosDevice,
1977
1977
  isJdAndAndroidDevice,
1978
1978
  isWxMin,
1979
1979
  isWxMinAndWxapp,
1980
1980
  isJdMin,
1981
1981
  isMin,
1982
1982
  isJdMinAndHarmony,
1983
1983
  isH5,
1984
1984
  isH5AndJdShopView,
1985
1985
  isImageOptimizeEnable,
1986
1986
  isChartH5,
1987
1987
  isH5AndJdShopViewNativeScroll,
1988
1988
  isH5AndJdShopViewH5Scroll,
1989
1989
  isH5AndJdShopH5CustomScrollView,
1990
1990
  isWxMiniH5View,
1991
1991
  sliceArrToChunkList,
1992
1992
  dealAddress,
1993
1993
  objectToUrlEncode,
1994
1994
  parseQueryUrlString,
1995
1995
  setLowSmallPicUrl,
1996
1996
  getJfsImage,
1997
1997
  getQualityImage,
1998
1998
  countStringify,
1999
1999
  setTaroStorage,
2000
2000
  getTaroStorageKeyValue,
2001
2001
  removeTaroStorageKey,
2002
2002
  clearTaroStorageKey,
2003
2003
  getSystemInfos,
2004
2004
  addHttps,
2005
2005
  dateFormat,
2006
2006
  throttle,
2007
2007
  lodashThrottle,
2008
2008
  debounce,
2009
2009
  getTelephone,
2010
2010
  rgbToHex,
2011
2011
  hexToRgb,
2012
2012
  getRandom,
2013
2013
  getWxAppCookieStr,
2014
2014
  pxTransformFromData,
2015
2015
  dealShopContentData,
2016
2016
  showSuccessToast,
2017
2017
  showFailToast,
2018
2018
  showNormalToast,
2019
2019
  showShopLoading,
2020
2020
  hideShopLoading,
2021
2021
  getAppChannelType,
2022
2022
  formatTabActiveMenuType,
2023
2023
  filterUrlQueryData,
2024
2024
  getAvifSupport,
2025
2025
  getWebpSupport,
2026
2026
  isMemberPage,
2027
2027
  sgmCustomReport,
2028
2028
  isOpenJdAppUrl,
2029
2029
  jdOpenAppParams,
2030
2030
  createJdOpenAppUrl,
2031
2031
  dealJdOpenAppData,
2032
2032
  isEmpty,
2033
2033
  getJdAppReportPageSource,
2034
2034
  isAppClassifyPage,
2035
2035
  getQualityImageNew,
2036
2036
  getQualityImageOld,
2037
2037
  isPc,
2038
2038
  ipLoc_djd,
2039
2039
  jdAppVersionCompare,
2040
2040
  dealNativePixelToCssPixel,
2041
2041
  isAppStowShop,