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