@conecli/cone-render 0.9.1-shop2.9 → 0.10.1-beta.1

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