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

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