@conecli/cone-render 0.9.1-shop2.15 → 0.9.1-shop2.16

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