@conecli/cone-render 0.8.20-shop.141 → 0.8.20-shop.142
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.
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
package/dist/utils/utils.ts
CHANGED
|
@@ -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(objectFloor?.floorExtInfo?.moduleFlag)
|
|
857
856
|
}) ?? false
|
|
858
857
|
)
|
|
859
858
|
floorListData,
|
|
860
859
|
containerListData,
|
|
861
860
|
exceptionReportFn?,
|
|
862
861
|
const unableIsvFloorListData = floorListData.filter(
|
|
863
862
|
(floorItem) =>
|
|
864
863
|
RemoteLoadFloorList.includes(floorItem?.floorExtInfo?.moduleFlag) &&
|
|
865
864
|
!isIsvFloorUseable(floorItem, exceptionReportFn),
|
|
866
865
|
)
|
|
867
866
|
const unableIsvFloorUidList = unableIsvFloorListData.map(
|
|
868
867
|
(floorItem) => floorItem.uid,
|
|
869
868
|
)
|
|
870
869
|
const unableIsvContainerListData = containerListData.filter(
|
|
871
870
|
(item) =>
|
|
872
871
|
item.includeUids &&
|
|
873
872
|
item.includeUids.every(
|
|
874
873
|
(itemUid) => unableIsvFloorUidList.indexOf(itemUid) != -1,
|
|
875
874
|
),
|
|
876
875
|
)
|
|
877
876
|
return unableIsvContainerListData
|
|
878
877
|
return -2
|
|
879
878
|
return customObj
|
|
880
879
|
return customObj
|
|
881
880
|
return customObj
|
|
882
881
|
return /openApp\.jdMobile:\/\/virtual\?params=/i.test(openAppUrl)
|
|
883
882
|
let getParams = false
|
|
884
883
|
if (isOpenJdAppUrl(openAppUrl)) {
|
|
885
884
|
try {
|
|
886
885
|
getParams = openAppUrl.replace(
|
|
887
886
|
/openApp\.jdMobile:\/\/virtual\?params=/i,
|
|
888
887
|
'',
|
|
889
888
|
)
|
|
890
889
|
getParams = JSON.parse(String(getParams))
|
|
891
890
|
} catch (e) {
|
|
892
891
|
console.log(e)
|
|
893
892
|
}
|
|
894
893
|
}
|
|
895
894
|
return getParams
|
|
896
895
|
const getLastParams = Object.assign({}, openParams)
|
|
897
896
|
return `openapp.jdmobile://virtual?params=${JSON.stringify(getLastParams)}`
|
|
898
897
|
if (val === null || val === '' || typeof val === 'undefined') {
|
|
899
898
|
return true
|
|
900
899
|
}
|
|
901
900
|
return false
|
|
902
901
|
const {
|
|
903
902
|
moduleId = 'none',
|
|
904
903
|
entrance = 'none',
|
|
905
904
|
sourceType = 'none',
|
|
906
905
|
sourceValue = 'none',
|
|
907
906
|
} = params
|
|
908
907
|
if (isIosDevice) {
|
|
909
908
|
return `${moduleId}#${entrance}`
|
|
910
909
|
} else if (isAndroidDevice) {
|
|
911
910
|
return `${sourceType}#${sourceValue}`
|
|
912
911
|
}
|
|
913
912
|
return 'none#none'
|
|
914
913
|
if (data && typeof data === 'object') {
|
|
915
914
|
let getOpenAppData = { ...data }
|
|
916
915
|
try {
|
|
917
916
|
const { sourceInfo, designerId, templateId, source } = getOpenAppData
|
|
918
917
|
if (designerId && templateId) {
|
|
919
918
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
920
919
|
sourceInfo: {
|
|
921
920
|
entrance: '设计师预览',
|
|
922
921
|
},
|
|
923
922
|
})
|
|
924
923
|
} else if (sourceInfo) {
|
|
925
924
|
const { entrance } = sourceInfo
|
|
926
925
|
getOpenAppData.sourceInfo.entrance =
|
|
927
926
|
entrance && entrance.length > 0 ? entrance : '其他'
|
|
928
927
|
} else if (source && !sourceInfo) {
|
|
929
928
|
if (typeof source === 'object') {
|
|
930
929
|
const { sourceType, entrance, sourceValue, moduleId } = source
|
|
931
930
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
932
931
|
sourceInfo: {
|
|
933
932
|
entrance: sourceType || entrance || '其他',
|
|
934
933
|
moduleId: sourceValue || moduleId || '-100',
|
|
935
934
|
},
|
|
936
935
|
})
|
|
937
936
|
} else {
|
|
938
937
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
939
938
|
sourceInfo: {
|
|
940
939
|
entrance: source,
|
|
941
940
|
},
|
|
942
941
|
})
|
|
943
942
|
}
|
|
944
943
|
} else {
|
|
945
944
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
946
945
|
sourceInfo: {
|
|
947
946
|
entrance: '其他',
|
|
948
947
|
},
|
|
949
948
|
})
|
|
950
949
|
}
|
|
951
950
|
} catch (e) {
|
|
952
951
|
console.log(e)
|
|
953
952
|
}
|
|
954
953
|
return getOpenAppData
|
|
955
954
|
}
|
|
956
955
|
return data
|
|
957
956
|
return displayObj
|
|
958
957
|
if (typeof input === 'string') {
|
|
959
958
|
try {
|
|
960
959
|
return JSON.parse(input)
|
|
961
960
|
} catch (e) {
|
|
962
961
|
console.error('JSON解析失败', e)
|
|
963
962
|
return {}
|
|
964
963
|
}
|
|
965
964
|
}
|
|
966
965
|
return input || {}
|
|
967
966
|
return false
|
|
968
967
|
isJdApp,
|
|
969
968
|
isWxApp,
|
|
970
969
|
isIosDevice,
|
|
971
970
|
isAndroidDevice,
|
|
972
971
|
isJdAndIosDevice,
|
|
973
972
|
isJdAndAndroidDevice,
|
|
974
973
|
isWxMin,
|
|
975
974
|
isWxMinAndWxapp,
|
|
976
975
|
isJdMin,
|
|
977
976
|
isMin,
|
|
978
977
|
isJdMinAndHarmony,
|
|
979
978
|
isH5,
|
|
980
979
|
isH5AndJdShopView,
|
|
981
980
|
isImageOptimizeEnable,
|
|
982
981
|
isChartH5,
|
|
983
982
|
isH5AndJdShopViewNativeScroll,
|
|
984
983
|
isH5AndJdShopViewH5Scroll,
|
|
985
984
|
isH5AndJdShopH5CustomScrollView,
|
|
986
985
|
isWxMiniH5View,
|
|
987
986
|
sliceArrToChunkList,
|
|
988
987
|
dealAddress,
|
|
989
988
|
objectToUrlEncode,
|
|
990
989
|
parseQueryUrlString,
|
|
991
990
|
setLowSmallPicUrl,
|
|
992
991
|
getJfsImage,
|
|
993
992
|
getQualityImage,
|
|
994
993
|
countStringify,
|
|
995
994
|
setTaroStorage,
|
|
996
995
|
getTaroStorageKeyValue,
|
|
997
996
|
removeTaroStorageKey,
|
|
998
997
|
clearTaroStorageKey,
|
|
999
998
|
getSystemInfos,
|
|
1000
999
|
addHttps,
|
|
1001
1000
|
dateFormat,
|
|
1002
1001
|
throttle,
|
|
1003
1002
|
lodashThrottle,
|
|
1004
1003
|
debounce,
|
|
1005
1004
|
getTelephone,
|
|
1006
1005
|
rgbToHex,
|
|
1007
1006
|
hexToRgb,
|
|
1008
1007
|
getRandom,
|
|
1009
1008
|
getWxAppCookieStr,
|
|
1010
1009
|
pxTransformFromData,
|
|
1011
1010
|
dealShopContentData,
|
|
1012
1011
|
showSuccessToast,
|
|
1013
1012
|
showFailToast,
|
|
1014
1013
|
showNormalToast,
|
|
1015
1014
|
showShopLoading,
|
|
1016
1015
|
hideShopLoading,
|
|
1017
1016
|
getAppChannelType,
|
|
1018
1017
|
formatTabActiveMenuType,
|
|
1019
1018
|
filterUrlQueryData,
|
|
1020
1019
|
getAvifSupport,
|
|
1021
1020
|
getWebpSupport,
|
|
1022
1021
|
isMemberPage,
|
|
1023
1022
|
sgmCustomReport,
|
|
1024
1023
|
draCustomReport,
|
|
1025
1024
|
remoteCustomReport,
|
|
1026
1025
|
isOpenJdAppUrl,
|
|
1027
1026
|
jdOpenAppParams,
|
|
1028
1027
|
createJdOpenAppUrl,
|
|
1029
1028
|
dealJdOpenAppData,
|
|
1030
1029
|
isEmpty,
|
|
1031
1030
|
getJdAppReportPageSource,
|
|
1032
1031
|
isAppClassifyPage,
|
|
1033
1032
|
getQualityImageNew,
|
|
1034
1033
|
getQualityImageOld,
|
|
1035
1034
|
isPc,
|
|
1036
1035
|
ipLoc_djd,
|
|
1037
1036
|
jdAppVersionCompare,
|
|
1038
1037
|
dealNativePixelToCssPixel,
|
|
1039
1038
|
isAppStowShop,
|
|
1040
1039
|
isIpadDevice,
|
|
1040
|
+
import Taro from '@tarojs/taro'
|
|
1041
1041
|
SHOP_MENU_ID_TYPE,
|
|
1042
1042
|
SHOP_MENU_ID_QUERY_NAME,
|
|
1043
1043
|
SECTION_HOME_TAB_TYPE,
|
|
1044
1044
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
1045
1045
|
SECTION_HOME_TAB_QUERY_TYPE,
|
|
1046
1046
|
CHANNEL_TYPE,
|
|
1047
1047
|
JDShopViewBusinessPathType,
|
|
1048
1048
|
FloorModuleType,
|
|
1049
1049
|
RemoteLoadFloorList,
|
|
1050
1050
|
FLOOR_KIND,
|
|
1051
1051
|
getBundleUrl,
|
|
1052
1052
|
getBundleFileName,
|
|
1053
1053
|
formatPackResult,
|
|
1054
1054
|
getTaroVersion,
|
|
1055
1055
|
SgmCustomCode,
|
|
1056
1056
|
NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG,
|
|
1057
1057
|
return Taro.setStorage({
|
|
1058
1058
|
key: key,
|
|
1059
1059
|
data: value,
|
|
1060
1060
|
success: successBack,
|
|
1061
1061
|
fail: failBack,
|
|
1062
1062
|
}).catch((e)=>{
|
|
1063
1063
|
console.log(`setTaroStorage key:${key} 报错:`, e)
|
|
1064
1064
|
return null
|
|
1065
1065
|
})
|
|
1066
1066
|
try {
|
|
1067
1067
|
return Taro.getStorageSync(key)
|
|
1068
1068
|
} catch (e) {
|
|
1069
1069
|
console.log(`getTaroStorageKeyValue key:${key} 报错:`, e)
|
|
1070
1070
|
return null
|
|
1071
1071
|
}
|
|
1072
1072
|
return Taro.removeStorage({
|
|
1073
1073
|
key: key,
|
|
1074
1074
|
}).catch((e) => {
|
|
1075
1075
|
console.log(`removeTaroStorageKey key:${key} 报错:`, e)
|
|
1076
1076
|
})
|
|
1077
1077
|
return Taro.clearStorage().catch((e) => {
|
|
1078
1078
|
console.log('clearTaroStorageKey报错:', e)
|
|
1079
1079
|
})
|
|
1080
1080
|
let hasChecked = false
|
|
1081
1081
|
if (isH5) {
|
|
1082
1082
|
const avifCache = getTaroStorageKeyValue(KEY_AVIF)
|
|
1083
1083
|
if (avifCache === null || avifCache === '' || forceUpdate) {
|
|
1084
1084
|
hasChecked = true
|
|
1085
1085
|
const img = new Image()
|
|
1086
1086
|
img.onload = function () {
|
|
1087
1087
|
if (img.height > 0 && img.width > 0) {
|
|
1088
1088
|
setTaroStorage(KEY_AVIF, '1')
|
|
1089
1089
|
} else {
|
|
1090
1090
|
setTaroStorage(KEY_AVIF, '0')
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
1093
|
img.onerror = () => {
|
|
1094
1094
|
setTaroStorage(KEY_AVIF, '0')
|
|
1095
1095
|
}
|
|
1096
1096
|
img.src =
|
|
1097
1097
|
'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A='
|
|
1098
1098
|
}
|
|
1099
1099
|
const webpCache = getTaroStorageKeyValue(KEY_WEBP)
|
|
1100
1100
|
if (webpCache === null || webpCache === '' || forceUpdate) {
|
|
1101
1101
|
hasChecked = true
|
|
1102
1102
|
const img = new Image()
|
|
1103
1103
|
img.onload = function () {
|
|
1104
1104
|
if (img.height > 0 && img.width > 0) {
|
|
1105
1105
|
setTaroStorage(KEY_WEBP, '1')
|
|
1106
1106
|
} else {
|
|
1107
1107
|
setTaroStorage(KEY_WEBP, '0')
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
1110
|
img.onerror = () => {
|
|
1111
1111
|
setTaroStorage(KEY_WEBP, '0')
|
|
1112
1112
|
}
|
|
1113
1113
|
img.src =
|
|
1114
1114
|
'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAUAmJaQAA3AA/vz0AAA='
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
1117
|
return hasChecked
|
|
1118
1118
|
const hasChecked = imageFormatSupport(false)
|
|
1119
1119
|
if (!hasChecked) {
|
|
1120
1120
|
setTimeout(imageFormatSupport, 5000)
|
|
1121
1121
|
}
|
|
1122
1122
|
const resultList: Array<any> = [],
|
|
1123
1123
|
arrLen = arr.length
|
|
1124
1124
|
if (arrLen) {
|
|
1125
1125
|
if (arrLen > size) {
|
|
1126
1126
|
for (let i = 0; i < arrLen; i = i + size) {
|
|
1127
1127
|
resultList.push(arr.slice(i, i + size))
|
|
1128
1128
|
}
|
|
1129
1129
|
} else {
|
|
1130
1130
|
resultList.push(arr)
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
1133
1133
|
return resultList
|
|
1134
1134
|
let _address = ids
|
|
1135
1135
|
const _areaAreaSplit = ids.split('.')
|
|
1136
1136
|
const _areaAreaSplit2 = ids.split('_')
|
|
1137
1137
|
_address = _areaAreaSplit.length === 2 ? _areaAreaSplit[0] : _address
|
|
1138
1138
|
_address = _areaAreaSplit2.length === 3 ? `${_areaAreaSplit2}_0` : _address
|
|
1139
1139
|
return _address
|
|
1140
1140
|
let paramStr = ''
|
|
1141
1141
|
obj &&
|
|
1142
1142
|
Object.keys(obj).forEach((key, index) => {
|
|
1143
1143
|
const getValue = `${obj[key]}`
|
|
1144
1144
|
.replace(/undefined/, '')
|
|
1145
1145
|
.replace(/null/, '')
|
|
1146
1146
|
paramStr += `${index === 0 ? '' : '&'}${key}=${encodeURIComponent(
|
|
1147
1147
|
getValue,
|
|
1148
1148
|
)}`
|
|
1149
1149
|
})
|
|
1150
1150
|
return paramStr
|
|
1151
1151
|
const result = {}
|
|
1152
1152
|
if (
|
|
1153
1153
|
!urlOrQueryStr ||
|
|
1154
1154
|
('string' !== typeof urlOrQueryStr && String !== urlOrQueryStr.constructor)
|
|
1155
1155
|
) {
|
|
1156
1156
|
return result
|
|
1157
1157
|
}
|
|
1158
1158
|
if (urlOrQueryStr.indexOf('?') > -1) {
|
|
1159
1159
|
const queryStr = urlOrQueryStr.split('?')
|
|
1160
1160
|
const queryItemList =
|
|
1161
1161
|
queryStr && queryStr.length > 1 ? queryStr[1].split('&') : []
|
|
1162
1162
|
const queryItemListLen = queryItemList.length
|
|
1163
1163
|
queryItemListLen > 0 &&
|
|
1164
1164
|
queryItemList.forEach((item) => {
|
|
1165
1165
|
const thisItemList = item.split('=')
|
|
1166
1166
|
result[thisItemList[0]] = thisItemList[1]
|
|
1167
1167
|
})
|
|
1168
1168
|
} else {
|
|
1169
1169
|
const queryItemList =
|
|
1170
1170
|
urlOrQueryStr.indexOf('&') > -1
|
|
1171
1171
|
? urlOrQueryStr.split('&')
|
|
1172
1172
|
: [urlOrQueryStr]
|
|
1173
1173
|
const queryItemListLen = queryItemList.length
|
|
1174
1174
|
queryItemListLen > 0 &&
|
|
1175
1175
|
queryItemList.forEach((item) => {
|
|
1176
1176
|
const thisItemList = item.split('=')
|
|
1177
1177
|
result[thisItemList[0]] = thisItemList[1]
|
|
1178
1178
|
})
|
|
1179
1179
|
}
|
|
1180
1180
|
return result
|
|
1181
1181
|
url: string,
|
|
1182
1182
|
size?: {
|
|
1183
1183
|
w: number
|
|
1184
1184
|
h: number
|
|
1185
1185
|
},
|
|
1186
1186
|
quality?: number,
|
|
1187
1187
|
if (url && size) {
|
|
1188
1188
|
const _w = Math.floor(size.w)
|
|
1189
1189
|
const _h = Math.floor(size.h)
|
|
1190
1190
|
if (url.match(/gif$/i)) {
|
|
1191
1191
|
return url
|
|
1192
1192
|
} else {
|
|
1193
1193
|
if (_w > 0 && _h > 0) {
|
|
1194
1194
|
url = url.replace('jfs/', `s${_w}x${_h}_jfs/`)
|
|
1195
1195
|
}
|
|
1196
1196
|
url += quality != null ? `!q${quality}.dpg` : '.dpg'
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
1199
|
return url
|
|
1200
1200
|
url: string,
|
|
1201
1201
|
jfsImgInfo: UtilsInterFace.getJfsImageInfo = {},
|
|
1202
1202
|
if (url.match(/\.(jpg|png|dpg)$/i)) {
|
|
1203
1203
|
const { width, height, quality } = jfsImgInfo
|
|
1204
1204
|
if (typeof width === 'number' || typeof height === 'number') {
|
|
1205
1205
|
url = url.replace(
|
|
1206
1206
|
'/jfs/',
|
|
1207
1207
|
`/s${Math.floor(width || 0)}x${Math.floor(height || 0)}_jfs/`,
|
|
1208
1208
|
)
|
|
1209
1209
|
}
|
|
1210
1210
|
if (
|
|
1211
1211
|
typeof quality === 'number' &&
|
|
1212
1212
|
quality > 0 &&
|
|
1213
1213
|
quality < 100 &&
|
|
1214
1214
|
url.match(/\.jpg$/i)
|
|
1215
1215
|
) {
|
|
1216
1216
|
url += `!q${quality}.dpg`
|
|
1217
1217
|
}
|
|
1218
1218
|
}
|
|
1219
1219
|
return addHttps(url)
|
|
1220
1220
|
if (imgUrl) {
|
|
1221
1221
|
if (
|
|
1222
1222
|
!imgUrl.match(
|
|
1223
1223
|
/(storage\.360buyimg\.com)|(jdcloud-oss\.com)|(imgcps\.jd\.com)|((\w+)\.300hu\.com)|(thirdwx\.qlogo\.cn)|(!q)|gif|dpg$/i,
|
|
1224
1224
|
)
|
|
1225
1225
|
) {
|
|
1226
1226
|
if (!imgUrl.includes('360buyimg.com')) {
|
|
1227
1227
|
imgUrl = '//m.360buyimg.com/cms/' + imgUrl
|
|
1228
1228
|
}
|
|
1229
1229
|
if (quality != 100)
|
|
1230
1230
|
imgUrl += /\.png/.test(imgUrl) ? '.dpg' : `!q${quality}`
|
|
1231
1231
|
}
|
|
1232
1232
|
imgUrl = imgUrl.match(/^\/\//) ? `https:${imgUrl}` : imgUrl
|
|
1233
1233
|
}
|
|
1234
1234
|
return imgUrl
|
|
1235
1235
|
const result = value % step
|
|
1236
1236
|
return result === 0 ? value : Math.ceil(value / step) * step
|
|
1237
1237
|
const MAX = 3.5
|
|
1238
1238
|
return Math.min(window?.devicePixelRatio ?? 2, MAX)
|
|
1239
1239
|
isSkuImage: boolean
|
|
1240
1240
|
size: number
|
|
1241
1241
|
imgUrl: string,
|
|
1242
1242
|
options: QualityOptions,
|
|
1243
1243
|
isIgnoreOptimizeFromServer: boolean = false,
|
|
1244
1244
|
if (!imgUrl) {
|
|
1245
1245
|
console.error(
|
|
1246
1246
|
'The input parameter imageUrl for the getQualityImage() cannot be empty!',
|
|
1247
1247
|
)
|
|
1248
1248
|
return imgUrl
|
|
1249
1249
|
}
|
|
1250
1250
|
if (isIgnoreOptimizeFromServer) {
|
|
1251
1251
|
imgUrl = imgUrl.replace(/\.(jpe?g|png).*/, '.$1')
|
|
1252
1252
|
}
|
|
1253
1253
|
if (!/^((https?):)?\/\//.test(imgUrl)) {
|
|
1254
1254
|
imgUrl = '//m.360buyimg.com/cms/' + imgUrl
|
|
1255
1255
|
}
|
|
1256
1256
|
const imgServerRegExp = /(img|m)\d{0,2}\.360buyimg\.com\/.*\.(jpe?g|png)/i
|
|
1257
1257
|
if (!imgServerRegExp.test(imgUrl)) {
|
|
1258
1258
|
return imgUrl
|
|
1259
1259
|
}
|
|
1260
1260
|
imgUrl = /^\/\//.test(imgUrl) ? `https:${imgUrl}` : imgUrl
|
|
1261
1261
|
const { isSkuImage, size } = options || {}
|
|
1262
1262
|
const needReduceSize = isSkuImage && size
|
|
1263
1263
|
if (needReduceSize) {
|
|
1264
1264
|
const devicePixelRatio = getDevicePixelRatio()
|
|
1265
1265
|
const useWidth = getValueByStep(size * devicePixelRatio, 40)
|
|
1266
1266
|
imgUrl = imgUrl.replace(/\/[^\/]*jfs\//, `/s${useWidth}x${useWidth}_jfs/`)
|
|
1267
1267
|
}
|
|
1268
1268
|
const needCompress = !global?.info?.pageInfo?.isVipShop
|
|
1269
1269
|
const result = imgUrl.match(/\/\w+\.(jpe?g|png)$/)
|
|
1270
1270
|
if (needCompress && result) {
|
|
1271
1271
|
if (getAvifSupport() === '1') {
|
|
1272
1272
|
imgUrl += '.avif'
|
|
1273
1273
|
} else if (getWebpSupport() === '1') {
|
|
1274
1274
|
imgUrl += '.webp'
|
|
1275
1275
|
} else if (/jpe?g/.test(result[1])) {
|
|
1276
1276
|
imgUrl += '!q80'
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
1279
|
if (needReduceSize) {
|
|
1280
1280
|
imgUrl += '!z2'
|
|
1281
1281
|
}
|
|
1282
1282
|
return imgUrl
|
|
1283
1283
|
if (imgUrl) {
|
|
1284
1284
|
if (
|
|
1285
1285
|
!imgUrl.match(
|
|
1286
1286
|
/(storage\.360buyimg\.com)|(jdcloud-oss\.com)|((\w+)\.300hu\.com)|(thirdwx\.qlogo\.cn)|(!q)|gif|dpg$/i,
|
|
1287
1287
|
)
|
|
1288
1288
|
) {
|
|
1289
1289
|
if (!imgUrl.includes('360buyimg.com')) {
|
|
1290
1290
|
imgUrl = '//m.360buyimg.com/cms/' + imgUrl
|
|
1291
1291
|
}
|
|
1292
1292
|
if (quality != 100)
|
|
1293
1293
|
imgUrl += /\.png/.test(imgUrl) ? '.dpg' : `!q${quality}`
|
|
1294
1294
|
}
|
|
1295
1295
|
imgUrl = imgUrl.match(/^\/\//) ? `https:${imgUrl}` : imgUrl
|
|
1296
1296
|
}
|
|
1297
1297
|
return imgUrl
|
|
1298
1298
|
return getTaroStorageKeyValue(KEY_AVIF) || '0'
|
|
1299
1299
|
return getTaroStorageKeyValue(KEY_WEBP) || '0'
|
|
1300
1300
|
count: number,
|
|
1301
1301
|
fixedNum = 1,
|
|
1302
1302
|
unit = '万',
|
|
1303
1303
|
maxNum = 10000,
|
|
1304
1304
|
count = Number(count)
|
|
1305
1305
|
const getMaxNum = count > 100000000 ? 100000000 : maxNum
|
|
1306
1306
|
const getUnit = count > 100000000 ? '亿' : unit
|
|
1307
1307
|
if (count >= getMaxNum) {
|
|
1308
1308
|
return (count / getMaxNum).toFixed(fixedNum) + getUnit
|
|
1309
1309
|
}
|
|
1310
1310
|
return count
|
|
1311
1311
|
const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfo || {
|
|
1312
1312
|
platform: '',
|
|
1313
1313
|
model: '',
|
|
1314
1314
|
system: '',
|
|
1315
1315
|
}
|
|
1316
1316
|
const isIOS = !!systemInfo.system.match(/ios/i)
|
|
1317
1317
|
const isAndroid = !!systemInfo.system.match(/android/i)
|
|
1318
1318
|
if (!systemInfo.statusBarHeight) {
|
|
1319
1319
|
systemInfo.statusBarHeight = screenHeight - windowHeight - 20
|
|
1320
1320
|
systemInfo.navBarExtendHeight = 0
|
|
1321
1321
|
} else {
|
|
1322
1322
|
if (isIOS) {
|
|
1323
1323
|
systemInfo.navBarExtendHeight = 4
|
|
1324
1324
|
} else {
|
|
1325
1325
|
systemInfo.navBarExtendHeight = 0
|
|
1326
1326
|
}
|
|
1327
1327
|
}
|
|
1328
1328
|
let rect = Taro.getMenuButtonBoundingClientRect
|
|
1329
1329
|
? Taro.getMenuButtonBoundingClientRect()
|
|
1330
1330
|
: null
|
|
1331
1331
|
if (!rect || !rect.width || !rect.top || !rect.left || !rect.height) {
|
|
1332
1332
|
let gap = 0
|
|
1333
1333
|
let width = 96
|
|
1334
1334
|
if (systemInfo.platform === 'android') {
|
|
1335
1335
|
gap = 8
|
|
1336
1336
|
width = 96
|
|
1337
1337
|
} else if (systemInfo.platform === 'devtools') {
|
|
1338
1338
|
if (isIOS) {
|
|
1339
1339
|
gap = 5.5
|
|
1340
1340
|
} else {
|
|
1341
1341
|
gap = 7.5
|
|
1342
1342
|
}
|
|
1343
1343
|
} else {
|
|
1344
1344
|
gap = 4
|
|
1345
1345
|
width = 88
|
|
1346
1346
|
}
|
|
1347
1347
|
rect = {
|
|
1348
1348
|
bottom: systemInfo.statusBarHeight + gap + 32,
|
|
1349
1349
|
height: 32,
|
|
1350
1350
|
left: systemInfo.windowWidth - width - 10,
|
|
1351
1351
|
right: systemInfo.windowWidth - 10,
|
|
1352
1352
|
top: systemInfo.statusBarHeight + gap,
|
|
1353
1353
|
width,
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
1356
1356
|
const gap = rect.top - systemInfo.statusBarHeight
|
|
1357
1357
|
systemInfo.navBarTopToStatusBar = gap
|
|
1358
1358
|
systemInfo.navBarHeight = 2 * gap + rect.height
|
|
1359
1359
|
systemInfo.capsulePosition = rect
|
|
1360
1360
|
systemInfo.isIOS = isIOS
|
|
1361
1361
|
systemInfo.isAndroid = isAndroid
|
|
1362
1362
|
return systemInfo
|
|
1363
1363
|
if (str.match(/^\/\//)) {
|
|
1364
1364
|
str = 'https:' + str
|
|
1365
1365
|
}
|
|
1366
1366
|
return str
|
|
1367
1367
|
dateTimeOrdate: Date | string | number | null,
|
|
1368
1368
|
format = 'yyyy-MM-dd HH:mm:ss',
|
|
1369
1369
|
noPadStart = {
|
|
1370
1370
|
M: '0',
|
|
1371
1371
|
d: '0',
|
|
1372
1372
|
H: '0',
|
|
1373
1373
|
m: '0',
|
|
1374
1374
|
s: '0',
|
|
1375
1375
|
},
|
|
1376
1376
|
let dateResult = ''
|
|
1377
1377
|
const padStarts = Object.assign(
|
|
1378
1378
|
{
|
|
1379
1379
|
M: '0',
|
|
1380
1380
|
d: '0',
|
|
1381
1381
|
H: '0',
|
|
1382
1382
|
m: '0',
|
|
1383
1383
|
s: '0',
|
|
1384
1384
|
},
|
|
1385
1385
|
noPadStart,
|
|
1386
1386
|
)
|
|
1387
1387
|
if (dateTimeOrdate) {
|
|
1388
1388
|
let changeDateTimeOrdate = dateTimeOrdate
|
|
1389
1389
|
const getChangeDateTimeToNumber = Number(changeDateTimeOrdate)
|
|
1390
1390
|
if (getChangeDateTimeToNumber) {
|
|
1391
1391
|
changeDateTimeOrdate = getChangeDateTimeToNumber
|
|
1392
1392
|
} else {
|
|
1393
1393
|
changeDateTimeOrdate = `${changeDateTimeOrdate}`
|
|
1394
1394
|
.replace(/-/g, '/')
|
|
1395
1395
|
.replace(/\./g, '/')
|
|
1396
1396
|
}
|
|
1397
1397
|
const nowDate =
|
|
1398
1398
|
dateTimeOrdate instanceof Date
|
|
1399
1399
|
? dateTimeOrdate
|
|
1400
1400
|
: new Date(changeDateTimeOrdate)
|
|
1401
1401
|
const dateMap = {
|
|
1402
1402
|
y: `${nowDate.getFullYear()}`,
|
|
1403
1403
|
M: `${nowDate.getMonth() + 1}`.padStart(2, padStarts['M']),
|
|
1404
1404
|
d: `${nowDate.getDate()}`.padStart(2, padStarts['d']),
|
|
1405
1405
|
H: `${nowDate.getHours()}`.padStart(2, padStarts['H']),
|
|
1406
1406
|
m: `${nowDate.getMinutes()}`.padStart(2, padStarts['m']),
|
|
1407
1407
|
s: `${nowDate.getSeconds()}`.padStart(2, padStarts['s']),
|
|
1408
1408
|
}
|
|
1409
1409
|
const regDate = new RegExp('y+|M+|d+|H+|m+|s+', 'g')
|
|
1410
1410
|
const regYear = new RegExp('y')
|
|
1411
1411
|
dateResult = format.replace(regDate, (v) => {
|
|
1412
1412
|
let changeValue = v
|
|
1413
1413
|
if (regYear.test(changeValue)) {
|
|
1414
1414
|
const thisYear = dateMap.y
|
|
1415
1415
|
const subValueLen = 4 - changeValue.length
|
|
1416
1416
|
changeValue = thisYear.substr(subValueLen)
|
|
1417
1417
|
} else {
|
|
1418
1418
|
const dateKey = v.substr(0, 1)
|
|
1419
1419
|
changeValue = dateMap[dateKey]
|
|
1420
1420
|
}
|
|
1421
1421
|
return changeValue
|
|
1422
1422
|
})
|
|
1423
1423
|
}
|
|
1424
1424
|
return dateResult
|
|
1425
1425
|
let timer: any = null
|
|
1426
1426
|
let startTime = Date.now()
|
|
1427
1427
|
return function () {
|
|
1428
1428
|
const curTime = Date.now()
|
|
1429
1429
|
const remaining = delay - (curTime - startTime)
|
|
1430
1430
|
const context = this
|
|
1431
1431
|
const args = arguments
|
|
1432
1432
|
clearTimeout(timer)
|
|
1433
1433
|
if (remaining <= 0) {
|
|
1434
1434
|
func.apply(context, args)
|
|
1435
1435
|
startTime = Date.now()
|
|
1436
1436
|
} else {
|
|
1437
1437
|
timer = setTimeout(func, remaining)
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
1440
1440
|
let context, args, result
|
|
1441
1441
|
let timeout = null
|
|
1442
1442
|
let previous = 0
|
|
1443
1443
|
if (!options) options = {}
|
|
1444
1444
|
const later = function () {
|
|
1445
1445
|
previous = options.leading === false ? 0 : Date.now()
|
|
1446
1446
|
timeout = null
|
|
1447
1447
|
result = func.apply(context, args)
|
|
1448
1448
|
if (!timeout) context = args = null
|
|
1449
1449
|
}
|
|
1450
1450
|
return function () {
|
|
1451
1451
|
const now = Date.now()
|
|
1452
1452
|
if (!previous && options.leading === false) previous = now
|
|
1453
1453
|
const remaining = wait - (now - previous)
|
|
1454
1454
|
context = this
|
|
1455
1455
|
args = arguments
|
|
1456
1456
|
if (remaining <= 0 || remaining > wait) {
|
|
1457
1457
|
if (timeout) {
|
|
1458
1458
|
clearTimeout(timeout)
|
|
1459
1459
|
timeout = null
|
|
1460
1460
|
}
|
|
1461
1461
|
previous = now
|
|
1462
1462
|
result = func.apply(context, args)
|
|
1463
1463
|
if (!timeout) context = args = null
|
|
1464
1464
|
} else if (!timeout && options.trailing !== false) {
|
|
1465
1465
|
timeout = setTimeout(later, remaining)
|
|
1466
1466
|
}
|
|
1467
1467
|
return result
|
|
1468
1468
|
}
|
|
1469
1469
|
let timer: any = null
|
|
1470
1470
|
return function () {
|
|
1471
1471
|
const context: any = this
|
|
1472
1472
|
const args = arguments
|
|
1473
1473
|
timer && clearTimeout(timer)
|
|
1474
1474
|
timer = setTimeout(function () {
|
|
1475
1475
|
fn.apply(context, args)
|
|
1476
1476
|
}, delay)
|
|
1477
1477
|
}
|
|
1478
1478
|
if (txt) {
|
|
1479
1479
|
txt = txt.trim()
|
|
1480
1480
|
const reg = new RegExp(/[\d-]+/)
|
|
1481
1481
|
const res = reg.exec(txt)
|
|
1482
1482
|
if (res && res.length > 0) {
|
|
1483
1483
|
let tel = res[0]
|
|
1484
1484
|
if (tel && delSeparator) {
|
|
1485
1485
|
tel = tel.replace(/-/g, '')
|
|
1486
1486
|
}
|
|
1487
1487
|
return tel
|
|
1488
1488
|
}
|
|
1489
1489
|
}
|
|
1490
1490
|
return ''
|
|
1491
1491
|
if (rgb) {
|
|
1492
1492
|
const reg = /^(rgb|RGB)/
|
|
1493
1493
|
const color = rgb
|
|
1494
1494
|
if (reg.test(color)) {
|
|
1495
1495
|
let strHex = '#'
|
|
1496
1496
|
const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',')
|
|
1497
1497
|
for (let i = 0; i < colorArr.length; i++) {
|
|
1498
1498
|
let hex = Number(colorArr[i]).toString(16)
|
|
1499
1499
|
if (hex === '0') {
|
|
1500
1500
|
hex += hex
|
|
1501
1501
|
}
|
|
1502
1502
|
strHex += hex
|
|
1503
1503
|
}
|
|
1504
1504
|
return strHex
|
|
1505
1505
|
} else {
|
|
1506
1506
|
return String(color)
|
|
1507
1507
|
}
|
|
1508
1508
|
} else {
|
|
1509
1509
|
return ''
|
|
1510
1510
|
}
|
|
1511
1511
|
if (hex) {
|
|
1512
1512
|
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
|
|
1513
1513
|
let color = hex.toLowerCase()
|
|
1514
1514
|
if (reg.test(color)) {
|
|
1515
1515
|
if (color.length === 4) {
|
|
1516
1516
|
let colorNew = '#'
|
|
1517
1517
|
for (let i = 1; i < 4; i += 1) {
|
|
1518
1518
|
colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1))
|
|
1519
1519
|
}
|
|
1520
1520
|
color = colorNew
|
|
1521
1521
|
}
|
|
1522
1522
|
const colorChange: number[] = []
|
|
1523
1523
|
for (let i = 1; i < 7; i += 2) {
|
|
1524
1524
|
colorChange.push(parseInt('0x' + color.slice(i, i + 2)))
|
|
1525
1525
|
}
|
|
1526
1526
|
if (returnList) {
|
|
1527
1527
|
return colorChange
|
|
1528
1528
|
} else {
|
|
1529
1529
|
return 'RGB(' + colorChange.join(',') + ')'
|
|
1530
1530
|
}
|
|
1531
1531
|
} else {
|
|
1532
1532
|
return color
|
|
1533
1533
|
}
|
|
1534
1534
|
} else {
|
|
1535
1535
|
return ''
|
|
1536
1536
|
}
|
|
1537
1537
|
n: number,
|
|
1538
1538
|
m: number,
|
|
1539
1539
|
filterNum: number | undefined = undefined,
|
|
1540
1540
|
const c = m - n + 1
|
|
1541
1541
|
const res = Math.floor(Math.random() * c + n)
|
|
1542
1542
|
if (filterNum && filterNum == res) {
|
|
1543
1543
|
console.log('随机数二次开始', res, filterNum)
|
|
1544
1544
|
return getRandom(n, m, filterNum)
|
|
1545
1545
|
} else {
|
|
1546
1546
|
return res
|
|
1547
1547
|
}
|
|
1548
1548
|
wqCookieStr: string
|
|
1549
1549
|
wqCookie: {
|
|
1550
1550
|
pin?: string
|
|
1551
1551
|
visitkey?: string
|
|
1552
1552
|
[key: string]: any
|
|
1553
1553
|
}
|
|
1554
1554
|
const {
|
|
1555
1555
|
jdpin,
|
|
1556
1556
|
pinStatus,
|
|
1557
1557
|
visitkey,
|
|
1558
1558
|
unionid,
|
|
1559
1559
|
skey,
|
|
1560
1560
|
__jda,
|
|
1561
1561
|
__jdv,
|
|
1562
1562
|
__wga,
|
|
1563
1563
|
wid,
|
|
1564
1564
|
wq_skey,
|
|
1565
1565
|
wq_uin,
|
|
1566
1566
|
wq_auth_token,
|
|
1567
1567
|
wxapp_scene,
|
|
1568
1568
|
wq_unionid,
|
|
1569
1569
|
wxapp_openid,
|
|
1570
1570
|
wxapp_version,
|
|
1571
1571
|
wxapp_type,
|
|
1572
1572
|
appType,
|
|
1573
1573
|
} = cookie
|
|
1574
1574
|
const ret: string[] = []
|
|
1575
1575
|
const getUserCookieObj = {}
|
|
1576
1576
|
const createUseCookieArr = [
|
|
1577
1577
|
jdpin,
|
|
1578
1578
|
pinStatus,
|
|
1579
1579
|
visitkey,
|
|
1580
1580
|
unionid,
|
|
1581
1581
|
skey,
|
|
1582
1582
|
__jda,
|
|
1583
1583
|
__jdv,
|
|
1584
1584
|
__wga,
|
|
1585
1585
|
wid,
|
|
1586
1586
|
wq_skey,
|
|
1587
1587
|
wq_uin,
|
|
1588
1588
|
wq_auth_token,
|
|
1589
1589
|
wxapp_scene,
|
|
1590
1590
|
wq_unionid,
|
|
1591
1591
|
wxapp_openid,
|
|
1592
1592
|
wxapp_version,
|
|
1593
1593
|
wxapp_type,
|
|
1594
1594
|
appType,
|
|
1595
1595
|
]
|
|
1596
1596
|
createUseCookieArr.forEach((keyItem) => {
|
|
1597
1597
|
if (keyItem && keyItem['name']) {
|
|
1598
1598
|
let { name, value } = keyItem
|
|
1599
1599
|
name = name === 'jdpin' ? 'pin' : name
|
|
1600
1600
|
name === 'pin' && ret.push(`pt_pin=${encodeURIComponent(value)}`)
|
|
1601
1601
|
ret.push(`${name}=${encodeURIComponent(value)}`)
|
|
1602
1602
|
getUserCookieObj[name] = value
|
|
1603
1603
|
}
|
|
1604
1604
|
})
|
|
1605
1605
|
return {
|
|
1606
1606
|
wqCookieStr: ret.join(';'),
|
|
1607
1607
|
wqCookie: getUserCookieObj,
|
|
1608
1608
|
}
|
|
1609
1609
|
num,
|
|
1610
1610
|
widthSize = 375,
|
|
1611
1611
|
layoutWidth = windowWidth,
|
|
1612
1612
|
const getNum = Number(num)
|
|
1613
1613
|
return Math.round((getNum / widthSize) * layoutWidth)
|
|
1614
1614
|
let checkState = false
|
|
1615
1615
|
const couponFloorModuleType = floorData?.floorExtInfo?.moduleFlag
|
|
1616
1616
|
if (couponFloorModuleType === FloorModuleType.COUPON) {
|
|
1617
1617
|
try {
|
|
1618
1618
|
const dataDefines = getFloorDataToDataDefines(floorData)
|
|
1619
1619
|
const couponDataDefine = dataDefines
|
|
1620
1620
|
? dataDefines.filter((item) => {
|
|
1621
1621
|
return item.type === 'coupon'
|
|
1622
1622
|
})
|
|
1623
1623
|
: [],
|
|
1624
1624
|
couponList = couponDataDefine[0]?.nodeText?.data
|
|
1625
1625
|
? couponDataDefine[0]?.nodeText?.data
|
|
1626
1626
|
: [],
|
|
1627
1627
|
couponLength = couponList.length,
|
|
1628
1628
|
numShowPerLine = couponDataDefine[0]?.nodeText?.numShowPerLine
|
|
1629
1629
|
? couponDataDefine[0]?.nodeText?.numShowPerLine
|
|
1630
1630
|
: 0
|
|
1631
1631
|
if (numShowPerLine === 0 && couponLength > 3) {
|
|
1632
1632
|
checkState = true
|
|
1633
1633
|
}
|
|
1634
1634
|
} catch (e) {
|
|
1635
1635
|
checkState = false
|
|
1636
1636
|
}
|
|
1637
1637
|
return checkState
|
|
1638
1638
|
}
|
|
1639
1639
|
const {
|
|
1640
1640
|
containers = [],
|
|
1641
1641
|
floors = [],
|
|
1642
1642
|
clearFirstContaierMarginTop = false,
|
|
1643
1643
|
} = pageData
|
|
1644
1644
|
console.log('dealShopContentData:', pageData, 'isvdev:', isvdev)
|
|
1645
1645
|
const getThisTimeKey = Date.now()
|
|
1646
1646
|
let shopContentContainerListData = containers?.filter(
|
|
1647
1647
|
(item) => (!isvdev && item.typeCode !== 'mShopHeader') || isvdev,
|
|
1648
1648
|
)
|
|
1649
1649
|
const shopContentFloorListData = floors?.filter(
|
|
1650
1650
|
({ floorPosition }) =>
|
|
1651
1651
|
(!isvdev && floorPosition !== 'header' && floorPosition !== 'footer') ||
|
|
1652
1652
|
isvdev,
|
|
1653
1653
|
)
|
|
1654
1654
|
const unableIsvContainerListData = getUnableIsvContainerListData(
|
|
1655
1655
|
shopContentFloorListData,
|
|
1656
1656
|
shopContentContainerListData,
|
|
1657
1657
|
exceptionReportFn,
|
|
1658
1658
|
)
|
|
1659
1659
|
shopContentContainerListData.forEach((item, index) => {
|
|
1660
1660
|
item.key = `${getThisTimeKey + index}`
|
|
1661
1661
|
item.floors = []
|
|
1662
1662
|
item.includeUids &&
|
|
1663
1663
|
item.includeUids.forEach((floorUid) => {
|
|
1664
1664
|
const getFloorData = shopContentFloorListData.find(
|
|
1665
1665
|
(floorItem) => floorItem.uid === floorUid,
|
|
1666
1666
|
)
|
|
1667
1667
|
if (getFloorData) {
|
|
1668
1668
|
const changeFloorData = {
|
|
1669
1669
|
containerId: item.containerId,
|
|
1670
1670
|
containerIndex: index,
|
|
1671
1671
|
...getFloorData,
|
|
1672
1672
|
}
|
|
1673
1673
|
const getCheckMoreCouponState =
|
|
1674
1674
|
checkCouponAndChangeContainerSetData(getFloorData)
|
|
1675
1675
|
if (getCheckMoreCouponState) {
|
|
1676
1676
|
item.marginLeft && (item.marginLeft = 0)
|
|
1677
1677
|
item.marginRight && (item.marginRight = 0)
|
|
1678
1678
|
item.borderRadius && (item.borderRadius = 0)
|
|
1679
1679
|
}
|
|
1680
1680
|
if (getFloorData?.floorExtInfo?.floorLoadWay === 2) {
|
|
1681
1681
|
const getSysFloorToLoadTypeRes = isIsvFloorUseable(
|
|
1682
1682
|
getFloorData,
|
|
1683
1683
|
exceptionReportFn,
|
|
1684
1684
|
)
|
|
1685
1685
|
!getSysFloorToLoadTypeRes &&
|
|
1686
1686
|
(getFloorData.floorExtInfo.floorLoadWay = 1)
|
|
1687
1687
|
}
|
|
1688
1688
|
item.floors.push(changeFloorData)
|
|
1689
1689
|
}
|
|
1690
1690
|
})
|
|
1691
1691
|
if (
|
|
1692
1692
|
((!isvdev && index === 0) || (isvdev && index === 1)) &&
|
|
1693
1693
|
item?.containerPosition == 'content' &&
|
|
1694
1694
|
item?.marginBottom > 0 &&
|
|
1695
1695
|
!clearFirstContaierMarginTop
|
|
1696
1696
|
) {
|
|
1697
1697
|
item.marginTop = item.marginBottom
|
|
1698
1698
|
}
|
|
1699
1699
|
})
|
|
1700
1700
|
shopContentContainerListData = shopContentContainerListData.filter(
|
|
1701
1701
|
(item) =>
|
|
1702
1702
|
item.floors.length > 0 &&
|
|
1703
1703
|
unableIsvContainerListData.every(
|
|
1704
1704
|
(containerItem) => containerItem.containerId != item.containerId,
|
|
1705
1705
|
),
|
|
1706
1706
|
)
|
|
1707
1707
|
console.log(
|
|
1708
1708
|
'dealShopContentData isWxMinAndWxapp:',
|
|
1709
1709
|
isWxMinAndWxapp,
|
|
1710
1710
|
'weappJumpToH5:',
|
|
1711
1711
|
pageData?.homeExtInfo?.weappJumpToH5,
|
|
1712
1712
|
)
|
|
1713
1713
|
if (isProd && isWxMinAndWxapp) {
|
|
1714
1714
|
shopContentContainerListData = shopContentContainerListData.filter(
|
|
1715
1715
|
(item) =>
|
|
1716
1716
|
item.floors.length > 0 &&
|
|
1717
1717
|
!isIsvContainer(
|
|
1718
1718
|
item.containerId,
|
|
1719
1719
|
shopContentFloorListData,
|
|
1720
1720
|
shopContentContainerListData,
|
|
1721
1721
|
),
|
|
1722
1722
|
)
|
|
1723
1723
|
}
|
|
1724
1724
|
shopContentContainerListData = [].concat(shopContentContainerListData)
|
|
1725
1725
|
return {
|
|
1726
1726
|
shopContentContainerListData,
|
|
1727
1727
|
shopContentFloorListData,
|
|
1728
1728
|
}
|
|
1729
1729
|
const changeOpts = {
|
|
1730
1730
|
title: '',
|
|
1731
1731
|
icon: 'success',
|
|
1732
1732
|
duration: 1500,
|
|
1733
1733
|
mask: true,
|
|
1734
1734
|
...options,
|
|
1735
1735
|
}
|
|
1736
1736
|
if (changeOpts.title.length > 7) {
|
|
1737
1737
|
showNormalToast(options)
|
|
1738
1738
|
} else {
|
|
1739
1739
|
Taro.showToast(changeOpts as any)
|
|
1740
1740
|
}
|
|
1741
1741
|
const changeOpts = {
|
|
1742
1742
|
title: '',
|
|
1743
1743
|
icon: 'error',
|
|
1744
1744
|
duration: 1500,
|
|
1745
1745
|
mask: true,
|
|
1746
1746
|
...options,
|
|
1747
1747
|
}
|
|
1748
1748
|
if (changeOpts.title.length > 7) {
|
|
1749
1749
|
showNormalToast(options)
|
|
1750
1750
|
} else {
|
|
1751
1751
|
Taro.showToast(changeOpts as any)
|
|
1752
1752
|
}
|
|
1753
1753
|
Taro.showToast({
|
|
1754
1754
|
title: '',
|
|
1755
1755
|
icon: 'none',
|
|
1756
1756
|
duration: 1500,
|
|
1757
1757
|
mask: true,
|
|
1758
1758
|
...options,
|
|
1759
1759
|
})
|
|
1760
1760
|
return Taro.showLoading({
|
|
1761
1761
|
title: text,
|
|
1762
1762
|
})
|
|
1763
1763
|
return new Promise(() => {
|
|
1764
1764
|
Taro.nextTick(() => {
|
|
1765
1765
|
setTimeout(() => {
|
|
1766
1766
|
Taro.hideLoading(options)
|
|
1767
1767
|
}, 300)
|
|
1768
1768
|
})
|
|
1769
1769
|
})
|
|
1770
1770
|
return CHANNEL_TYPE[JDShopViewBusinessPathType.HOME]
|
|
1771
1771
|
const {
|
|
1772
1772
|
tabActive = SECTION_HOME_TAB_NAME_TYPE[
|
|
1773
1773
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
1774
1774
|
],
|
|
1775
1775
|
sceneId,
|
|
1776
1776
|
} = query
|
|
1777
1777
|
let changeTabActive = tabActive
|
|
1778
1778
|
if (sceneId) {
|
|
1779
1779
|
if (isH5) {
|
|
1780
1780
|
if (sceneId == '1002') {
|
|
1781
1781
|
changeTabActive =
|
|
1782
1782
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT]
|
|
1783
1783
|
}
|
|
1784
1784
|
else if (sceneId == '1003') {
|
|
1785
1785
|
changeTabActive =
|
|
1786
1786
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_ACTIVITY]
|
|
1787
1787
|
}
|
|
1788
1788
|
} else if (isWxMinAndWxapp) {
|
|
1789
1789
|
if (sceneId == '1001' || sceneId == '1002') {
|
|
1790
1790
|
changeTabActive =
|
|
1791
1791
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT]
|
|
1792
1792
|
}
|
|
1793
1793
|
else if (sceneId == '1003') {
|
|
1794
1794
|
changeTabActive =
|
|
1795
1795
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]
|
|
1796
1796
|
}
|
|
1797
1797
|
}
|
|
1798
1798
|
}
|
|
1799
1799
|
if (SECTION_HOME_TAB_QUERY_TYPE[changeTabActive]) {
|
|
1800
1800
|
return {
|
|
1801
1801
|
menuType: SHOP_MENU_ID_TYPE.HOME,
|
|
1802
1802
|
tabActiveType: SECTION_HOME_TAB_QUERY_TYPE[changeTabActive],
|
|
1803
1803
|
queryMenuTabActiveStr: `${SHOP_MENU_ID_TYPE.HOME}@${SECTION_HOME_TAB_QUERY_TYPE[changeTabActive]}`,
|
|
1804
1804
|
}
|
|
1805
1805
|
} else if (SHOP_MENU_ID_QUERY_NAME[changeTabActive]) {
|
|
1806
1806
|
return {
|
|
1807
1807
|
menuType: SHOP_MENU_ID_QUERY_NAME[changeTabActive],
|
|
1808
1808
|
tabActiveType: 0,
|
|
1809
1809
|
queryMenuTabActiveStr: `${SHOP_MENU_ID_QUERY_NAME[changeTabActive]}@0`,
|
|
1810
1810
|
}
|
|
1811
1811
|
} else {
|
|
1812
1812
|
return {
|
|
1813
1813
|
menuType: SHOP_MENU_ID_TYPE.HOME,
|
|
1814
1814
|
tabActiveType: SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN,
|
|
1815
1815
|
queryMenuTabActiveStr: `${SHOP_MENU_ID_TYPE.HOME}@${SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN}`,
|
|
1816
1816
|
}
|
|
1817
1817
|
}
|
|
1818
1818
|
const deleteKeyList = [
|
|
1819
1819
|
'$taroTimestamp',
|
|
1820
1820
|
'cookie',
|
|
1821
1821
|
'wdref',
|
|
1822
1822
|
'navStart',
|
|
1823
1823
|
'originOpts',
|
|
1824
1824
|
'originParams',
|
|
1825
1825
|
'originUrl',
|
|
1826
1826
|
'referer',
|
|
1827
1827
|
'stamp',
|
|
1828
1828
|
'hybrid',
|
|
1829
1829
|
'sr',
|
|
1830
1830
|
'navh',
|
|
1831
1831
|
'stath',
|
|
1832
1832
|
]
|
|
1833
1833
|
let changeQueryData: any = { ...queryData }
|
|
1834
1834
|
const qrCodeScene = changeQueryData?.scene ? changeQueryData?.scene : false
|
|
1835
1835
|
const sceneQuery =
|
|
1836
1836
|
qrCodeScene && typeof qrCodeScene == 'string'
|
|
1837
1837
|
? parseQueryUrlString(decodeURIComponent(qrCodeScene))
|
|
1838
1838
|
: {}
|
|
1839
1839
|
changeQueryData = { ...changeQueryData, ...sceneQuery }
|
|
1840
1840
|
deleteKeyList.forEach((key) => {
|
|
1841
1841
|
changeQueryData[key] && delete changeQueryData[key]
|
|
1842
1842
|
})
|
|
1843
1843
|
changeQueryData['shopid'] &&
|
|
1844
1844
|
(changeQueryData['shopId'] = changeQueryData['shopid']) &&
|
|
1845
1845
|
delete changeQueryData['shopid']
|
|
1846
1846
|
changeQueryData['venderid'] &&
|
|
1847
1847
|
(changeQueryData['venderId'] = changeQueryData['venderid']) &&
|
|
1848
1848
|
delete changeQueryData['venderid']
|
|
1849
1849
|
changeQueryData['vendorId'] &&
|
|
1850
1850
|
(changeQueryData['venderId'] = changeQueryData['vendorId']) &&
|
|
1851
1851
|
delete changeQueryData['vendorId']
|
|
1852
1852
|
changeQueryData["shopId"] && changeQueryData["shopId"] === 'undefined' && delete changeQueryData["shopId"];
|
|
1853
1853
|
changeQueryData["venderId"] && changeQueryData["venderId"] === 'undefined' && delete changeQueryData["venderId"];
|
|
1854
1854
|
return changeQueryData
|
|
1855
1855
|
let isUsable = false
|
|
1856
1856
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
1857
1857
|
const modularPackResultObj = formatPackResult(modularPackResult)
|
|
1858
1858
|
const bundleUrl = getBundleUrl(modularPackResultObj)
|
|
1859
1859
|
const bundleFileName = getBundleFileName(modularPackResultObj)
|
|
1860
1860
|
const taroVersion = getTaroVersion(modularPackResultObj)
|
|
1861
1861
|
if (bundleUrl && bundleFileName) {
|
|
1862
1862
|
isUsable = true
|
|
1863
1863
|
}
|
|
1864
1864
|
if (!isUsable && typeof exceptionReportFn === 'function') {
|
|
1865
1865
|
exceptionReportFn({
|
|
1866
1866
|
code: `${NO_ENVIRONMENT_AND_PAGE_TYPE_FLAG}${
|
|
1867
1867
|
floorData?.floorExtInfo?.floorKind === FLOOR_KIND.PDC_SYSTEM_MODULE
|
|
1868
1868
|
? SgmCustomCode.SYSTEMPDCMODULE_DATA
|
|
1869
1869
|
: SgmCustomCode.REMOTEMODULE_DATA
|
|
1870
1870
|
}`,
|
|
1871
1871
|
msg: {
|
|
1872
1872
|
msg: `店铺h5楼层隐藏不显示。原因:模块数据不完备,楼层过滤。`,
|
|
1873
1873
|
floorIdx: floorData?.floorIdx,
|
|
1874
1874
|
uid: floorData?.uid,
|
|
1875
1875
|
shopId: floorData?.floorExtInfo?.shopId,
|
|
1876
1876
|
moduleId: floorData?.moduleId,
|
|
1877
1877
|
moduleDesignerType: floorData?.floorExtInfo?.moduleDesignerType,
|
|
1878
1878
|
floorLoadWay: floorData?.floorExtInfo?.floorLoadWay,
|
|
1879
1879
|
floorKind: floorData?.floorExtInfo?.floorKind,
|
|
1880
1880
|
middleTemplateId: floorData?.middleTemplateId,
|
|
1881
1881
|
modularPackResult: {
|
|
1882
1882
|
bundleUrl,
|
|
1883
1883
|
taroVersion,
|
|
1884
1884
|
},
|
|
1885
1885
|
},
|
|
1886
1886
|
})
|
|
1887
1887
|
}
|
|
1888
1888
|
return isUsable
|
|
1889
1889
|
const objContainer = containerListData.find(
|
|
1890
1890
|
(item) => item.containerId === containerId,
|
|
1891
1891
|
)
|
|
1892
1892
|
return (
|
|
1893
1893
|
objContainer?.includeUids?.some((itemUid) => {
|
|
1894
1894
|
const objectFloor = floorListData.find(
|
|
1895
1895
|
(floorItem) => itemUid === floorItem.uid,
|
|
1896
1896
|
)
|
|
1897
1897
|
return RemoteLoadFloorList.includes(objectFloor?.floorExtInfo?.moduleFlag)
|
|
1898
1898
|
}) ?? false
|
|
1899
1899
|
)
|
|
1900
1900
|
floorListData,
|
|
1901
1901
|
containerListData,
|
|
1902
1902
|
exceptionReportFn?,
|
|
1903
1903
|
const unableIsvFloorListData = floorListData.filter(
|
|
1904
1904
|
(floorItem) =>
|
|
1905
1905
|
RemoteLoadFloorList.includes(floorItem?.floorExtInfo?.moduleFlag) &&
|
|
1906
1906
|
!isIsvFloorUseable(floorItem, exceptionReportFn),
|
|
1907
1907
|
)
|
|
1908
1908
|
const unableIsvFloorUidList = unableIsvFloorListData.map(
|
|
1909
1909
|
(floorItem) => floorItem.uid,
|
|
1910
1910
|
)
|
|
1911
1911
|
const unableIsvContainerListData = containerListData.filter(
|
|
1912
1912
|
(item) =>
|
|
1913
1913
|
item.includeUids &&
|
|
1914
1914
|
item.includeUids.every(
|
|
1915
1915
|
(itemUid) => unableIsvFloorUidList.indexOf(itemUid) != -1,
|
|
1916
1916
|
),
|
|
1917
1917
|
)
|
|
1918
1918
|
return unableIsvContainerListData
|
|
1919
1919
|
return -2
|
|
1920
1920
|
return customObj
|
|
1921
1921
|
return customObj
|
|
1922
1922
|
return customObj
|
|
1923
1923
|
return /openApp\.jdMobile:\/\/virtual\?params=/i.test(openAppUrl)
|
|
1924
1924
|
let getParams = false
|
|
1925
1925
|
if (isOpenJdAppUrl(openAppUrl)) {
|
|
1926
1926
|
try {
|
|
1927
1927
|
getParams = openAppUrl.replace(
|
|
1928
1928
|
/openApp\.jdMobile:\/\/virtual\?params=/i,
|
|
1929
1929
|
'',
|
|
1930
1930
|
)
|
|
1931
1931
|
getParams = JSON.parse(String(getParams))
|
|
1932
1932
|
} catch (e) {
|
|
1933
1933
|
console.log(e)
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
1936
1936
|
return getParams
|
|
1937
1937
|
const getLastParams = Object.assign({}, openParams)
|
|
1938
1938
|
return `openapp.jdmobile://virtual?params=${JSON.stringify(getLastParams)}`
|
|
1939
1939
|
if (val === null || val === '' || typeof val === 'undefined') {
|
|
1940
1940
|
return true
|
|
1941
1941
|
}
|
|
1942
1942
|
return false
|
|
1943
1943
|
const {
|
|
1944
1944
|
moduleId = 'none',
|
|
1945
1945
|
entrance = 'none',
|
|
1946
1946
|
sourceType = 'none',
|
|
1947
1947
|
sourceValue = 'none',
|
|
1948
1948
|
} = params
|
|
1949
1949
|
if (isIosDevice) {
|
|
1950
1950
|
return `${moduleId}#${entrance}`
|
|
1951
1951
|
} else if (isAndroidDevice) {
|
|
1952
1952
|
return `${sourceType}#${sourceValue}`
|
|
1953
1953
|
}
|
|
1954
1954
|
return 'none#none'
|
|
1955
1955
|
if (data && typeof data === 'object') {
|
|
1956
1956
|
let getOpenAppData = { ...data }
|
|
1957
1957
|
try {
|
|
1958
1958
|
const { sourceInfo, designerId, templateId, source } = getOpenAppData
|
|
1959
1959
|
if (designerId && templateId) {
|
|
1960
1960
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
1961
1961
|
sourceInfo: {
|
|
1962
1962
|
entrance: '设计师预览',
|
|
1963
1963
|
},
|
|
1964
1964
|
})
|
|
1965
1965
|
} else if (sourceInfo) {
|
|
1966
1966
|
const { entrance } = sourceInfo
|
|
1967
1967
|
getOpenAppData.sourceInfo.entrance =
|
|
1968
1968
|
entrance && entrance.length > 0 ? entrance : '其他'
|
|
1969
1969
|
} else if (source && !sourceInfo) {
|
|
1970
1970
|
if (typeof source === 'object') {
|
|
1971
1971
|
const { sourceType, entrance, sourceValue, moduleId } = source
|
|
1972
1972
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
1973
1973
|
sourceInfo: {
|
|
1974
1974
|
entrance: sourceType || entrance || '其他',
|
|
1975
1975
|
moduleId: sourceValue || moduleId || '-100',
|
|
1976
1976
|
},
|
|
1977
1977
|
})
|
|
1978
1978
|
} else {
|
|
1979
1979
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
1980
1980
|
sourceInfo: {
|
|
1981
1981
|
entrance: source,
|
|
1982
1982
|
},
|
|
1983
1983
|
})
|
|
1984
1984
|
}
|
|
1985
1985
|
} else {
|
|
1986
1986
|
getOpenAppData = Object.assign({}, getOpenAppData, {
|
|
1987
1987
|
sourceInfo: {
|
|
1988
1988
|
entrance: '其他',
|
|
1989
1989
|
},
|
|
1990
1990
|
})
|
|
1991
1991
|
}
|
|
1992
1992
|
} catch (e) {
|
|
1993
1993
|
console.log(e)
|
|
1994
1994
|
}
|
|
1995
1995
|
return getOpenAppData
|
|
1996
1996
|
}
|
|
1997
1997
|
return data
|
|
1998
1998
|
return displayObj
|
|
1999
1999
|
if (typeof input === 'string') {
|
|
2000
2000
|
try {
|
|
2001
2001
|
return JSON.parse(input)
|
|
2002
2002
|
} catch (e) {
|
|
2003
2003
|
console.error('JSON解析失败', e)
|
|
2004
2004
|
return {}
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
2007
|
return input || {}
|
|
2008
2008
|
return false
|
|
2009
2009
|
isJdApp,
|
|
2010
2010
|
isWxApp,
|
|
2011
2011
|
isIosDevice,
|
|
2012
2012
|
isAndroidDevice,
|
|
2013
2013
|
isJdAndIosDevice,
|
|
2014
2014
|
isJdAndAndroidDevice,
|
|
2015
2015
|
isWxMin,
|
|
2016
2016
|
isWxMinAndWxapp,
|
|
2017
2017
|
isJdMin,
|
|
2018
2018
|
isMin,
|
|
2019
2019
|
isJdMinAndHarmony,
|
|
2020
2020
|
isH5,
|
|
2021
2021
|
isH5AndJdShopView,
|
|
2022
2022
|
isImageOptimizeEnable,
|
|
2023
2023
|
isChartH5,
|
|
2024
2024
|
isH5AndJdShopViewNativeScroll,
|
|
2025
2025
|
isH5AndJdShopViewH5Scroll,
|
|
2026
2026
|
isH5AndJdShopH5CustomScrollView,
|
|
2027
2027
|
isWxMiniH5View,
|
|
2028
2028
|
sliceArrToChunkList,
|
|
2029
2029
|
dealAddress,
|
|
2030
2030
|
objectToUrlEncode,
|
|
2031
2031
|
parseQueryUrlString,
|
|
2032
2032
|
setLowSmallPicUrl,
|
|
2033
2033
|
getJfsImage,
|
|
2034
2034
|
getQualityImage,
|
|
2035
2035
|
countStringify,
|
|
2036
2036
|
setTaroStorage,
|
|
2037
2037
|
getTaroStorageKeyValue,
|
|
2038
2038
|
removeTaroStorageKey,
|
|
2039
2039
|
clearTaroStorageKey,
|
|
2040
2040
|
getSystemInfos,
|
|
2041
2041
|
addHttps,
|
|
2042
2042
|
dateFormat,
|
|
2043
2043
|
throttle,
|
|
2044
2044
|
lodashThrottle,
|
|
2045
2045
|
debounce,
|
|
2046
2046
|
getTelephone,
|
|
2047
2047
|
rgbToHex,
|
|
2048
2048
|
hexToRgb,
|
|
2049
2049
|
getRandom,
|
|
2050
2050
|
getWxAppCookieStr,
|
|
2051
2051
|
pxTransformFromData,
|
|
2052
2052
|
dealShopContentData,
|
|
2053
2053
|
showSuccessToast,
|
|
2054
2054
|
showFailToast,
|
|
2055
2055
|
showNormalToast,
|
|
2056
2056
|
showShopLoading,
|
|
2057
2057
|
hideShopLoading,
|
|
2058
2058
|
getAppChannelType,
|
|
2059
2059
|
formatTabActiveMenuType,
|
|
2060
2060
|
filterUrlQueryData,
|
|
2061
2061
|
getAvifSupport,
|
|
2062
2062
|
getWebpSupport,
|
|
2063
2063
|
isMemberPage,
|
|
2064
2064
|
sgmCustomReport,
|
|
2065
2065
|
draCustomReport,
|
|
2066
2066
|
remoteCustomReport,
|
|
2067
2067
|
isOpenJdAppUrl,
|
|
2068
2068
|
jdOpenAppParams,
|
|
2069
2069
|
createJdOpenAppUrl,
|
|
2070
2070
|
dealJdOpenAppData,
|
|
2071
2071
|
isEmpty,
|
|
2072
2072
|
getJdAppReportPageSource,
|
|
2073
2073
|
isAppClassifyPage,
|
|
2074
2074
|
getQualityImageNew,
|
|
2075
2075
|
getQualityImageOld,
|
|
2076
2076
|
isPc,
|
|
2077
2077
|
ipLoc_djd,
|
|
2078
2078
|
jdAppVersionCompare,
|
|
2079
2079
|
dealNativePixelToCssPixel,
|
|
2080
2080
|
isAppStowShop,
|
|
2081
2081
|
isIpadDevice,
|