@conecli/cone-render 0.9.1-shop2.14 → 0.9.1-shop2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils/index.h5.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
UtilsInterFace
|
|
3
2
|
nativePageShowToast,
|
|
4
3
|
ToastAndroidType,
|
|
5
4
|
ToastIosType,
|
|
6
5
|
stopNativeScrollEvent,
|
|
7
6
|
getAppChannelType,
|
|
8
7
|
isAndroidDevice,
|
|
9
8
|
isH5AndJdShopView,
|
|
10
9
|
isChartH5,
|
|
11
10
|
isH5AndJdShopViewNativeScroll,
|
|
12
11
|
isIosDevice,
|
|
13
12
|
isJdAndAndroidDevice,
|
|
14
13
|
isJdAndIosDevice,
|
|
15
14
|
isJdApp,
|
|
16
15
|
isWxApp,
|
|
17
16
|
isWxMiniH5View,
|
|
18
17
|
isJdAndHarmonyDevice,
|
|
19
18
|
isH5AndJingGouMini,
|
|
20
19
|
urlCookie,
|
|
21
20
|
sgmCustomReport,
|
|
22
21
|
isMemberPage,
|
|
23
22
|
isH5AndJdShopViewH5Scroll,
|
|
24
23
|
isH5AndJdShopH5CustomScrollView,
|
|
25
24
|
isAppClassifyPage,
|
|
26
25
|
isAppHomeForMarketPage,
|
|
27
26
|
isPc,
|
|
28
27
|
ipLoc_djd,
|
|
29
28
|
jdAppVersionCompare,
|
|
30
29
|
isTjScence,
|
|
31
30
|
isH5AdnJxMini,
|
|
32
31
|
isTjM,
|
|
33
32
|
isTjJxM,
|
|
34
33
|
isTJApp,
|
|
35
34
|
isH5AdnHaoWuJie,
|
|
36
35
|
tjChannel,
|
|
37
36
|
dealNativePixelToCssPixel,
|
|
38
37
|
isAppStowShop,
|
|
39
38
|
isJdAndroidX5Core,
|
|
40
39
|
parseQueryUrlObj,
|
|
41
40
|
addHttps,
|
|
42
41
|
clearTaroStorageKey,
|
|
43
42
|
countStringify,
|
|
44
43
|
dateFormat,
|
|
45
44
|
dealAddress,
|
|
46
45
|
dealShopContentData as originDealShopContentData,
|
|
47
46
|
debounce,
|
|
48
47
|
filterUrlQueryData,
|
|
49
48
|
formatTabActiveMenuType,
|
|
50
49
|
getAvifSupport,
|
|
51
50
|
getWebpSupport,
|
|
52
51
|
getTaroStorageKeyValue,
|
|
53
52
|
getWxAppCookieStr,
|
|
54
53
|
isH5,
|
|
55
54
|
isMin,
|
|
56
55
|
isJdMin,
|
|
57
56
|
isWxMin,
|
|
58
57
|
isWxMinAndWxapp,
|
|
59
58
|
isJdMinAndHarmony,
|
|
60
59
|
lodashThrottle,
|
|
61
60
|
objectToUrlEncode,
|
|
62
61
|
parseQueryUrlString,
|
|
63
62
|
removeTaroStorageKey,
|
|
64
63
|
setLowSmallPicUrl,
|
|
65
64
|
setTaroStorage,
|
|
66
65
|
showFailToast,
|
|
67
66
|
showNormalToast,
|
|
68
67
|
showSuccessToast,
|
|
69
68
|
sliceArrToChunkList,
|
|
70
69
|
throttle,
|
|
71
70
|
getQualityImageNew,
|
|
72
71
|
getQualityImageOld,
|
|
73
72
|
isOpenJdAppUrl,
|
|
74
73
|
jdOpenAppParams,
|
|
75
74
|
createJdOpenAppUrl,
|
|
76
75
|
isEmpty,
|
|
77
76
|
getJdAppReportPageSource,
|
|
78
77
|
dealJdOpenAppData,
|
|
79
78
|
SgmCustomCode,
|
|
80
79
|
} from '../common/sgmCustomCode'
|
|
81
80
|
const getNum = Number(num)
|
|
82
81
|
let _changeLayoutWidth = layoutWidth
|
|
83
82
|
if (!_changeLayoutWidth) {
|
|
84
83
|
_changeLayoutWidth =
|
|
85
84
|
_ShopSystemInfo && _ShopSystemInfo?.windowWidth
|
|
86
85
|
? _ShopSystemInfo.windowWidth
|
|
87
86
|
: Taro.getSystemInfoSync()?.windowWidth
|
|
88
87
|
}
|
|
89
88
|
return Math.round((getNum / widthSize) * _changeLayoutWidth)
|
|
90
89
|
changeSize,
|
|
91
90
|
designWidth = 750,
|
|
92
91
|
systemInfo,
|
|
93
92
|
const getRootFontSize =
|
|
94
93
|
(40 * (systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth)) / 750
|
|
95
94
|
const getRealRootFontSize =
|
|
96
95
|
getRootFontSize > 40 ? 40 : getRootFontSize < 20 ? 20 : getRootFontSize
|
|
97
96
|
return Math.ceil(
|
|
98
97
|
(((parseInt(String(changeSize), 10) / 40) * 750) / designWidth) *
|
|
99
98
|
getRealRootFontSize,
|
|
100
99
|
)
|
|
101
100
|
console.log(
|
|
102
101
|
'获取系统宽度systemInfo?.windowWidth',
|
|
103
102
|
systemInfo?.windowWidth,
|
|
104
103
|
'taroToTransformRoutimePXNumber(changeWidth)',
|
|
105
104
|
taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
|
|
106
105
|
)
|
|
107
106
|
return buildType === BUILD_TYPE.CLASSIFY && systemInfo?.windowWidth
|
|
108
107
|
? systemInfo?.windowWidth -
|
|
109
108
|
taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
|
|
110
109
|
: systemInfo?.windowWidth ?? 0
|
|
111
110
|
const systemInfo = Taro.getSystemInfoSync()
|
|
112
111
|
if (params && params?.pageWidth && params?.pageHeight) {
|
|
113
112
|
systemInfo.windowWidth = params?.pageWidth
|
|
114
113
|
systemInfo.windowHeight = params?.pageHeight
|
|
115
114
|
}
|
|
116
115
|
systemInfo['containerWidth'] = getContainerWidth(buildType, systemInfo)
|
|
117
116
|
console.warn('====获取系统信息=====', systemInfo)
|
|
118
117
|
return systemInfo
|
|
119
118
|
let result: boolean | null = null
|
|
120
119
|
return function() {
|
|
121
120
|
if (result === null) {
|
|
122
121
|
const appVersionCheckPass = jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0
|
|
123
122
|
const supportBuildType = /app-view|app-member|app-classify|member-home/
|
|
124
123
|
const scopeCheckPass = supportBuildType.test(buildType || '')
|
|
125
124
|
const enableAvifOptimize = appVersionCheckPass && scopeCheckPass
|
|
126
125
|
if(enableAvifOptimize){
|
|
127
126
|
const configData = global.getDynamicConfig('avifSwitch')
|
|
128
127
|
console.warn("🚗 ~~ file: utils.ts:187 ~~ isImageOptimizeEnable ~~ enableAvifOptimize:", enableAvifOptimize, ' appVersionCheckPass:', appVersionCheckPass, ' scopeCheckPass:', scopeCheckPass)
|
|
129
128
|
console.warn("🚗 ~~ file: utils.ts:188 ~~ global.getDynamicConfig ~~ configData:", configData)
|
|
130
129
|
const { globalOn = true, ignoreOptimizeFromServer = false, page = {}, grayscale = {}, whiteList = [], blackList = [] } = configData || {}
|
|
131
130
|
const {shopId = '0', venderId = '0'} = parseQueryUrlObj
|
|
132
131
|
let imageEnableResult = true
|
|
133
132
|
isIgnoreOptimizeFromServer = ignoreOptimizeFromServer
|
|
134
133
|
if (blackList.find(item => item.sId === Number(shopId) || item.vId === Number(venderId))){
|
|
135
134
|
imageEnableResult = false
|
|
136
135
|
console.warn("🚗 ~~ file: utils.ts:198 命中黑名单~")
|
|
137
136
|
}else if(whiteList.find(item => item.sId === Number(shopId) || item.vId === Number(venderId))){
|
|
138
137
|
isIgnoreOptimizeFromServer = true
|
|
139
138
|
imageEnableResult = true
|
|
140
139
|
console.warn("🚗 ~~ file: utils.ts:205 命中白名单~")
|
|
141
140
|
}else if(grayscale[buildType] && isInGrayscale(grayscale[buildType], 'imageOptimizeSwitch')){
|
|
142
141
|
isIgnoreOptimizeFromServer = true
|
|
143
142
|
imageEnableResult = true
|
|
144
143
|
console.warn("🚗 ~~ file: utils.ts:214 命中灰度~")
|
|
145
144
|
}else{
|
|
146
145
|
imageEnableResult = globalOn === true || page[buildType] === true
|
|
147
146
|
if(globalOn === true){
|
|
148
147
|
isIgnoreOptimizeFromServer = true
|
|
149
148
|
console.warn("🚗 ~~ file: utils.ts:220 走全局开关控制逻辑,开关已打开~")
|
|
150
149
|
}else if(page[buildType] === true){
|
|
151
150
|
console.warn("🚗 ~~ file: utils.ts:220 走页面开关控制逻辑,开关已打开~")
|
|
152
151
|
}else{
|
|
153
152
|
console.warn("🚗 ~~ file: utils.ts:220 走全局或页面开关控制逻辑,开关未打开!")
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
155
|
result = imageEnableResult
|
|
157
156
|
return imageEnableResult
|
|
158
157
|
}else{
|
|
159
158
|
result = false
|
|
160
159
|
return false
|
|
161
160
|
}
|
|
162
161
|
} else {
|
|
163
162
|
return result
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
if(typeof options === 'object' && isImageOptimizeEnable()){
|
|
167
166
|
return getQualityImageNew(imgUrl, options, isIgnoreOptimizeFromServer)
|
|
168
167
|
}else{
|
|
169
168
|
return getQualityImageOld(imgUrl, options)
|
|
170
169
|
}
|
|
171
170
|
const getSystemInfo = getSystemAndContainerWidthInfo(params) || {
|
|
172
171
|
windowWidth: window.innerWidth,
|
|
173
172
|
containerWidth: getContainerWidth(buildType, {
|
|
174
173
|
windowWidth: window.innerWidth,
|
|
175
174
|
}),
|
|
176
175
|
screenWidth: window.innerWidth,
|
|
177
176
|
platform: '',
|
|
178
177
|
model: '',
|
|
179
178
|
system: '',
|
|
180
179
|
}
|
|
181
180
|
if (isJdApp && isAndroidDevice && getSystemInfo.windowWidth <= 0) {
|
|
182
181
|
getSystemInfo.windowWidth = getSystemInfo.screenWidth
|
|
183
182
|
getSystemInfo['containerWidth'] = getContainerWidth(
|
|
184
183
|
buildType,
|
|
185
184
|
getSystemInfo,
|
|
186
185
|
)
|
|
187
186
|
}
|
|
188
187
|
return getSystemInfo
|
|
189
188
|
console.log('进入commonshowToast, 传入参数options为: ', options)
|
|
190
189
|
const params = Object.assign(
|
|
191
190
|
{},
|
|
192
191
|
{
|
|
193
192
|
title: '',
|
|
194
193
|
duration: 1500,
|
|
195
194
|
},
|
|
196
195
|
options,
|
|
197
196
|
)
|
|
198
197
|
params.duration = params.duration / 1000
|
|
199
198
|
if (isJdApp) {
|
|
200
199
|
const showSuccessType = isIosDevice
|
|
201
200
|
? ToastIosType.SUCCESS
|
|
202
201
|
: ToastAndroidType.SUCCESS
|
|
203
202
|
const duration = isAndroidDevice ? 0 : params.duration
|
|
204
203
|
nativePageShowToast(options.title, showSuccessType, duration)
|
|
205
204
|
console.log('执行原生toast success')
|
|
206
205
|
} else {
|
|
207
206
|
showSuccessToast(options)
|
|
208
207
|
}
|
|
209
208
|
const params = Object.assign(
|
|
210
209
|
{},
|
|
211
210
|
{
|
|
212
211
|
title: '',
|
|
213
212
|
duration: 1500,
|
|
214
213
|
},
|
|
215
214
|
options,
|
|
216
215
|
)
|
|
217
216
|
params.duration = params.duration / 1000
|
|
218
217
|
if (isJdApp) {
|
|
219
218
|
const showSuccessType = isIosDevice
|
|
220
219
|
? ToastIosType.FAIL
|
|
221
220
|
: ToastAndroidType.FAIL
|
|
222
221
|
const duration = isAndroidDevice ? 0 : params.duration
|
|
223
222
|
nativePageShowToast(options.title, showSuccessType, duration)
|
|
224
223
|
console.log('执行原生toast fail')
|
|
225
224
|
} else {
|
|
226
225
|
console.log('执行H5 toast fail')
|
|
227
226
|
showFailToast(options)
|
|
228
227
|
}
|
|
229
228
|
const params = Object.assign(
|
|
230
229
|
{},
|
|
231
230
|
{
|
|
232
231
|
title: '',
|
|
233
232
|
duration: 1500,
|
|
234
233
|
},
|
|
235
234
|
options,
|
|
236
235
|
)
|
|
237
236
|
params.duration = params.duration / 1000
|
|
238
237
|
if (isJdApp) {
|
|
239
238
|
const showSuccessType = isIosDevice ?
|
|
240
239
|
ToastIosType.NORMAL :
|
|
241
240
|
ToastAndroidType.NORMAL
|
|
242
241
|
const duration = isAndroidDevice ? 0 : params.duration
|
|
243
242
|
nativePageShowToast(options.title, showSuccessType, duration)
|
|
244
243
|
} else {
|
|
245
244
|
showNormalToast(options)
|
|
246
245
|
}
|
|
247
246
|
const createLoadingEle = document.createElement('div')
|
|
248
247
|
createLoadingEle.id = 'J_shopLoading'
|
|
249
248
|
createLoadingEle.className = `d-shop-loading flexible-center-box ${customClassName}`
|
|
250
249
|
createLoadingEle.innerHTML =
|
|
251
250
|
`<div class='d-loading-content'>
|
|
252
251
|
<span class='d-shop-loading-icon'></span>
|
|
253
252
|
<p class='d-shop-text'>${text}</p>
|
|
254
253
|
</div>`
|
|
255
254
|
const getEle = document.body
|
|
256
255
|
? document.body
|
|
257
256
|
: document.getElementsByTagName('body')[0]
|
|
258
257
|
getEle.appendChild(createLoadingEle)
|
|
259
258
|
const getEle = document.getElementById('J_shopLoading')
|
|
260
259
|
getEle && getEle.remove()
|
|
261
260
|
const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getReviseSystemInfo(
|
|
262
261
|
params,
|
|
263
262
|
)
|
|
264
263
|
if (!systemInfo.system && window) {
|
|
265
264
|
systemInfo.system = window.navigator.userAgent
|
|
266
265
|
systemInfo.isChrome = !!systemInfo?.system.match(/chrome/i)
|
|
267
266
|
}
|
|
268
267
|
const isIOS = !!systemInfo?.system.match(/ios/i)
|
|
269
268
|
const isAndroid = !!systemInfo?.system.match(/android/i)
|
|
270
269
|
systemInfo.navBarHeight = 0
|
|
271
270
|
systemInfo.statusBarHeight = 0
|
|
272
271
|
systemInfo.capsulePosition = null
|
|
273
272
|
systemInfo.isIOS = isIOS
|
|
274
273
|
systemInfo.isAndroid = isAndroid
|
|
275
274
|
_ShopSystemInfo = systemInfo
|
|
276
275
|
return systemInfo
|
|
277
276
|
return originDealShopContentData(pageData, sgmCustomReport, isvdev)
|
|
278
277
|
if(isNaN(Number(scale))){
|
|
279
278
|
console.warn(`The 'scale' parameter of the 'isInGrayscale' function is invalid! Expected a number, but received ${scale}`)
|
|
280
279
|
return false
|
|
281
280
|
}
|
|
282
281
|
const { venderId } = global.info.queryInfo || {}
|
|
283
282
|
const id = venderId
|
|
284
283
|
if(!id){
|
|
285
284
|
return false
|
|
286
285
|
}
|
|
287
286
|
const useScale = Math.max(0, Math.min(1, Number(scale)))
|
|
288
287
|
const isMatch = Math.floor(Number(id) % (1 / useScale)) === 0
|
|
289
288
|
if(reportKey){
|
|
290
289
|
sgmCustomReport({
|
|
291
290
|
code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
|
|
292
291
|
msg: '灰度调用',
|
|
293
292
|
})
|
|
294
293
|
console.log(`基于KEY[${reportKey}]的灰度调用1次~`, getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`))
|
|
295
294
|
if(isMatch){
|
|
296
295
|
sgmCustomReport({
|
|
297
296
|
code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
|
|
298
297
|
msg: '灰度命中',
|
|
299
298
|
})
|
|
300
299
|
console.log(`基于KEY[${reportKey}]的命中1次灰度!`, getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`))
|
|
301
300
|
}
|
|
302
301
|
}
|
|
303
302
|
return isMatch
|
|
304
303
|
isJdApp,
|
|
305
304
|
isWxApp,
|
|
306
305
|
isIosDevice,
|
|
307
306
|
isAndroidDevice,
|
|
308
307
|
isJdAndIosDevice,
|
|
309
308
|
isJdAndAndroidDevice,
|
|
310
309
|
isJdAndHarmonyDevice,
|
|
311
310
|
isJdAndroidX5Core,
|
|
312
311
|
isMin,
|
|
313
312
|
isWxMin,
|
|
314
313
|
isWxMinAndWxapp,
|
|
315
314
|
isJdMinAndHarmony,
|
|
316
315
|
isJdMin,
|
|
317
316
|
isH5,
|
|
318
317
|
isH5AndJdShopView,
|
|
319
318
|
isChartH5,
|
|
320
319
|
isH5AndJdShopViewNativeScroll,
|
|
321
320
|
isH5AndJdShopViewH5Scroll,
|
|
322
321
|
isH5AndJdShopH5CustomScrollView,
|
|
323
322
|
isH5AndJingGouMini,
|
|
324
323
|
isWxMiniH5View,
|
|
325
324
|
urlCookie,
|
|
326
325
|
sliceArrToChunkList,
|
|
327
326
|
dealAddress,
|
|
328
327
|
objectToUrlEncode,
|
|
329
328
|
parseQueryUrlString,
|
|
330
329
|
setLowSmallPicUrl,
|
|
331
330
|
setTaroStorage,
|
|
332
331
|
getTaroStorageKeyValue,
|
|
333
332
|
removeTaroStorageKey,
|
|
334
333
|
clearTaroStorageKey,
|
|
335
334
|
getAvifSupport,
|
|
336
335
|
getWebpSupport,
|
|
337
336
|
getQualityImage,
|
|
338
337
|
countStringify,
|
|
339
338
|
getWxAppCookieStr,
|
|
340
339
|
getSystemInfos,
|
|
341
340
|
pxTransformFromData,
|
|
342
341
|
dealShopContentDataAndReport as dealShopContentData,
|
|
343
342
|
dateFormat,
|
|
344
343
|
throttle,
|
|
345
344
|
lodashThrottle,
|
|
346
345
|
debounce,
|
|
347
346
|
addHttps,
|
|
348
347
|
commonShowSuccessToast as showSuccessToast,
|
|
349
348
|
commonShowFailToast as showFailToast,
|
|
350
349
|
commonShowNormalToast as showNormalToast,
|
|
351
350
|
showShopLoading,
|
|
352
351
|
hideShopLoading,
|
|
353
352
|
stopNativeScrollEvent,
|
|
354
353
|
getAppChannelType,
|
|
355
354
|
formatTabActiveMenuType,
|
|
356
355
|
filterUrlQueryData,
|
|
357
356
|
sgmCustomReport,
|
|
358
357
|
isMemberPage,
|
|
359
358
|
getFloorDataToDataDefines,
|
|
360
359
|
isOpenJdAppUrl,
|
|
361
360
|
jdOpenAppParams,
|
|
362
361
|
createJdOpenAppUrl,
|
|
363
362
|
isEmpty,
|
|
364
363
|
getJdAppReportPageSource,
|
|
365
364
|
isAppClassifyPage,
|
|
366
365
|
isAppHomeForMarketPage,
|
|
367
366
|
isImageOptimizeEnable,
|
|
368
367
|
isPc,
|
|
369
368
|
ipLoc_djd,
|
|
370
369
|
isTjScence,
|
|
371
370
|
isH5AdnJxMini,
|
|
372
371
|
isTjM,
|
|
373
372
|
isTjJxM,
|
|
374
373
|
isTJApp,
|
|
375
374
|
isH5AdnHaoWuJie,
|
|
376
375
|
tjChannel,
|
|
377
376
|
dealJdOpenAppData,
|
|
378
377
|
jdAppVersionCompare,
|
|
379
378
|
dealNativePixelToCssPixel,
|
|
380
379
|
isAppStowShop,
|
|
381
380
|
getSgmCustomCode,
|
|
382
381
|
handleSgmCodeTaroVersion,
|
|
383
382
|
isInGrayscale,
|
|
383
|
+
import Taro from '@tarojs/taro'
|
|
384
384
|
UtilsInterFace
|
|
385
385
|
nativePageShowToast,
|
|
386
386
|
ToastAndroidType,
|
|
387
387
|
ToastIosType,
|
|
388
388
|
stopNativeScrollEvent,
|
|
389
389
|
getAppChannelType,
|
|
390
390
|
isAndroidDevice,
|
|
391
391
|
isH5AndJdShopView,
|
|
392
392
|
isChartH5,
|
|
393
393
|
isH5AndJdShopViewNativeScroll,
|
|
394
394
|
isIosDevice,
|
|
395
395
|
isJdAndAndroidDevice,
|
|
396
396
|
isJdAndIosDevice,
|
|
397
397
|
isJdApp,
|
|
398
398
|
isWxApp,
|
|
399
399
|
isWxMiniH5View,
|
|
400
400
|
isJdAndHarmonyDevice,
|
|
401
401
|
isH5AndJingGouMini,
|
|
402
402
|
urlCookie,
|
|
403
403
|
sgmCustomReport,
|
|
404
404
|
isMemberPage,
|
|
405
405
|
isH5AndJdShopViewH5Scroll,
|
|
406
406
|
isH5AndJdShopH5CustomScrollView,
|
|
407
407
|
isAppClassifyPage,
|
|
408
408
|
isAppHomeForMarketPage,
|
|
409
409
|
isPc,
|
|
410
410
|
ipLoc_djd,
|
|
411
411
|
jdAppVersionCompare,
|
|
412
412
|
isTjScence,
|
|
413
413
|
isH5AdnJxMini,
|
|
414
414
|
isTjM,
|
|
415
415
|
isTjJxM,
|
|
416
416
|
isTJApp,
|
|
417
417
|
isH5AdnHaoWuJie,
|
|
418
418
|
tjChannel,
|
|
419
419
|
dealNativePixelToCssPixel,
|
|
420
420
|
isAppStowShop,
|
|
421
421
|
isJdAndroidX5Core,
|
|
422
422
|
parseQueryUrlObj,
|
|
423
423
|
addHttps,
|
|
424
424
|
clearTaroStorageKey,
|
|
425
425
|
countStringify,
|
|
426
426
|
dateFormat,
|
|
427
427
|
dealAddress,
|
|
428
428
|
dealShopContentData as originDealShopContentData,
|
|
429
429
|
debounce,
|
|
430
430
|
filterUrlQueryData,
|
|
431
431
|
formatTabActiveMenuType,
|
|
432
432
|
getAvifSupport,
|
|
433
433
|
getWebpSupport,
|
|
434
434
|
getTaroStorageKeyValue,
|
|
435
435
|
getWxAppCookieStr,
|
|
436
436
|
isH5,
|
|
437
437
|
isMin,
|
|
438
438
|
isJdMin,
|
|
439
439
|
isWxMin,
|
|
440
440
|
isWxMinAndWxapp,
|
|
441
441
|
isJdMinAndHarmony,
|
|
442
442
|
lodashThrottle,
|
|
443
443
|
objectToUrlEncode,
|
|
444
444
|
parseQueryUrlString,
|
|
445
445
|
removeTaroStorageKey,
|
|
446
446
|
setLowSmallPicUrl,
|
|
447
447
|
setTaroStorage,
|
|
448
448
|
showFailToast,
|
|
449
449
|
showNormalToast,
|
|
450
450
|
showSuccessToast,
|
|
451
451
|
sliceArrToChunkList,
|
|
452
452
|
throttle,
|
|
453
453
|
getQualityImageNew,
|
|
454
454
|
getQualityImageOld,
|
|
455
455
|
isOpenJdAppUrl,
|
|
456
456
|
jdOpenAppParams,
|
|
457
457
|
createJdOpenAppUrl,
|
|
458
458
|
isEmpty,
|
|
459
459
|
getJdAppReportPageSource,
|
|
460
460
|
dealJdOpenAppData,
|
|
461
461
|
SgmCustomCode,
|
|
462
462
|
} from '../common/sgmCustomCode'
|
|
463
463
|
const getNum = Number(num)
|
|
464
464
|
let _changeLayoutWidth = layoutWidth
|
|
465
465
|
if (!_changeLayoutWidth) {
|
|
466
466
|
_changeLayoutWidth =
|
|
467
467
|
_ShopSystemInfo && _ShopSystemInfo?.windowWidth
|
|
468
468
|
? _ShopSystemInfo.windowWidth
|
|
469
469
|
: Taro.getSystemInfoSync()?.windowWidth
|
|
470
470
|
}
|
|
471
471
|
return Math.round((getNum / widthSize) * _changeLayoutWidth)
|
|
472
472
|
changeSize,
|
|
473
473
|
designWidth = 750,
|
|
474
474
|
systemInfo,
|
|
475
475
|
const getRootFontSize =
|
|
476
476
|
(40 * (systemInfo?.windowWidth ?? _ShopSystemInfo.windowWidth)) / 750
|
|
477
477
|
const getRealRootFontSize =
|
|
478
478
|
getRootFontSize > 40 ? 40 : getRootFontSize < 20 ? 20 : getRootFontSize
|
|
479
479
|
return Math.ceil(
|
|
480
480
|
(((parseInt(String(changeSize), 10) / 40) * 750) / designWidth) *
|
|
481
481
|
getRealRootFontSize,
|
|
482
482
|
)
|
|
483
483
|
console.log(
|
|
484
484
|
'获取系统宽度systemInfo?.windowWidth',
|
|
485
485
|
systemInfo?.windowWidth,
|
|
486
486
|
'taroToTransformRoutimePXNumber(changeWidth)',
|
|
487
487
|
taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo),
|
|
488
488
|
)
|
|
489
489
|
return buildType === BUILD_TYPE.CLASSIFY && systemInfo?.windowWidth
|
|
490
490
|
? systemInfo?.windowWidth -
|
|
491
491
|
taroToTransformRoutimePXNumber(changeWidth, 750, systemInfo)
|
|
492
492
|
: systemInfo?.windowWidth ?? 0
|
|
493
493
|
const systemInfo = Taro.getSystemInfoSync()
|
|
494
494
|
if (params && params?.pageWidth && params?.pageHeight) {
|
|
495
495
|
systemInfo.windowWidth = params?.pageWidth
|
|
496
496
|
systemInfo.windowHeight = params?.pageHeight
|
|
497
497
|
}
|
|
498
498
|
systemInfo['containerWidth'] = getContainerWidth(buildType, systemInfo)
|
|
499
499
|
console.warn('====获取系统信息=====', systemInfo)
|
|
500
500
|
return systemInfo
|
|
501
501
|
let result: boolean | null = null
|
|
502
502
|
return function() {
|
|
503
503
|
if (result === null) {
|
|
504
504
|
const appVersionCheckPass = jdAppVersionCompare(MPAAS_CONFIG_APP_VERSION) >= 0
|
|
505
505
|
if(!isJdApp){
|
|
506
506
|
console.warn("🚗 ~~ file: utils.ts:191 站外H5默认打开图片优化~")
|
|
507
507
|
isIgnoreOptimizeFromServer = true
|
|
508
508
|
result = true
|
|
509
509
|
return true
|
|
510
510
|
}
|
|
511
511
|
const enableAvifOptimize = appVersionCheckPass
|
|
512
512
|
if(enableAvifOptimize){
|
|
513
513
|
const configData = global.getDynamicConfig('avifSwitch')
|
|
514
514
|
console.warn("🚗 ~~ file: utils.ts:196 ~~ global.getDynamicConfig ~~ buildType:", buildType)
|
|
515
515
|
console.warn("🚗 ~~ file: utils.ts:197 ~~ global.getDynamicConfig ~~ configData:", configData)
|
|
516
516
|
const { globalOn = true, ignoreOptimizeFromServer = false, page = {}, grayscale = {}, whiteList = [], blackList = [] } = configData || {}
|
|
517
517
|
const {shopId = '0', venderId = '0'} = parseQueryUrlObj
|
|
518
518
|
let imageEnableResult = true
|
|
519
519
|
isIgnoreOptimizeFromServer = ignoreOptimizeFromServer
|
|
520
520
|
console.warn("🚗 ~~ file: index.h5.ts:213 ~~ returnfunction ~~ grayscale[buildType]:", grayscale[buildType])
|
|
521
521
|
console.warn("🚗 ~~ file: index.h5.ts:213 ~~ returnfunction ~~ isInGrayscale(grayscale[buildType]:", isInGrayscale(grayscale[buildType]))
|
|
522
522
|
if (blackList.find(item => item.sId === Number(shopId) || item.vId === Number(venderId))){
|
|
523
523
|
imageEnableResult = false
|
|
524
524
|
console.warn("🚗 ~~ file: utils.ts:198 命中黑名单~")
|
|
525
525
|
}else if(whiteList.find(item => item.sId === Number(shopId) || item.vId === Number(venderId))){
|
|
526
526
|
isIgnoreOptimizeFromServer = true
|
|
527
527
|
imageEnableResult = true
|
|
528
528
|
console.warn("🚗 ~~ file: utils.ts:205 命中白名单~")
|
|
529
529
|
}else if(grayscale[buildType] && isInGrayscale(grayscale[buildType], 'imageOptimizeSwitch')){
|
|
530
530
|
isIgnoreOptimizeFromServer = true
|
|
531
531
|
imageEnableResult = true
|
|
532
532
|
console.warn("🚗 ~~ file: utils.ts:214 命中灰度~")
|
|
533
533
|
}else{
|
|
534
534
|
imageEnableResult = globalOn === true || page[buildType] === true
|
|
535
535
|
if(globalOn === true){
|
|
536
536
|
isIgnoreOptimizeFromServer = true
|
|
537
537
|
console.warn("🚗 ~~ file: utils.ts:220 走全局开关控制逻辑,开关已打开~")
|
|
538
538
|
}else if(page[buildType] === true){
|
|
539
539
|
console.warn("🚗 ~~ file: utils.ts:220 走页面开关控制逻辑,开关已打开~")
|
|
540
540
|
}else{
|
|
541
541
|
console.warn("🚗 ~~ file: utils.ts:220 走全局或页面开关控制逻辑,开关未打开!")
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
result = imageEnableResult
|
|
545
545
|
return imageEnableResult
|
|
546
546
|
}else{
|
|
547
547
|
result = false
|
|
548
548
|
return false
|
|
549
549
|
}
|
|
550
550
|
} else {
|
|
551
551
|
return result
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
554
|
if(typeof options === 'object' && isImageOptimizeEnable()){
|
|
555
555
|
return getQualityImageNew(imgUrl, options, isIgnoreOptimizeFromServer)
|
|
556
556
|
}else{
|
|
557
557
|
return getQualityImageOld(imgUrl, options)
|
|
558
558
|
}
|
|
559
559
|
const getSystemInfo = getSystemAndContainerWidthInfo(params) || {
|
|
560
560
|
windowWidth: window.innerWidth,
|
|
561
561
|
containerWidth: getContainerWidth(buildType, {
|
|
562
562
|
windowWidth: window.innerWidth,
|
|
563
563
|
}),
|
|
564
564
|
screenWidth: window.innerWidth,
|
|
565
565
|
platform: '',
|
|
566
566
|
model: '',
|
|
567
567
|
system: '',
|
|
568
568
|
}
|
|
569
569
|
if (isJdApp && isAndroidDevice && getSystemInfo.windowWidth <= 0) {
|
|
570
570
|
getSystemInfo.windowWidth = getSystemInfo.screenWidth
|
|
571
571
|
getSystemInfo['containerWidth'] = getContainerWidth(
|
|
572
572
|
buildType,
|
|
573
573
|
getSystemInfo,
|
|
574
574
|
)
|
|
575
575
|
}
|
|
576
576
|
return getSystemInfo
|
|
577
577
|
console.log('进入commonshowToast, 传入参数options为: ', options)
|
|
578
578
|
const params = Object.assign(
|
|
579
579
|
{},
|
|
580
580
|
{
|
|
581
581
|
title: '',
|
|
582
582
|
duration: 1500,
|
|
583
583
|
},
|
|
584
584
|
options,
|
|
585
585
|
)
|
|
586
586
|
params.duration = params.duration / 1000
|
|
587
587
|
if (isJdApp) {
|
|
588
588
|
const showSuccessType = isIosDevice
|
|
589
589
|
? ToastIosType.SUCCESS
|
|
590
590
|
: ToastAndroidType.SUCCESS
|
|
591
591
|
const duration = isAndroidDevice ? 0 : params.duration
|
|
592
592
|
nativePageShowToast(options.title, showSuccessType, duration)
|
|
593
593
|
console.log('执行原生toast success')
|
|
594
594
|
} else {
|
|
595
595
|
showSuccessToast(options)
|
|
596
596
|
}
|
|
597
597
|
const params = Object.assign(
|
|
598
598
|
{},
|
|
599
599
|
{
|
|
600
600
|
title: '',
|
|
601
601
|
duration: 1500,
|
|
602
602
|
},
|
|
603
603
|
options,
|
|
604
604
|
)
|
|
605
605
|
params.duration = params.duration / 1000
|
|
606
606
|
if (isJdApp) {
|
|
607
607
|
const showSuccessType = isIosDevice
|
|
608
608
|
? ToastIosType.FAIL
|
|
609
609
|
: ToastAndroidType.FAIL
|
|
610
610
|
const duration = isAndroidDevice ? 0 : params.duration
|
|
611
611
|
nativePageShowToast(options.title, showSuccessType, duration)
|
|
612
612
|
console.log('执行原生toast fail')
|
|
613
613
|
} else {
|
|
614
614
|
console.log('执行H5 toast fail')
|
|
615
615
|
showFailToast(options)
|
|
616
616
|
}
|
|
617
617
|
const params = Object.assign(
|
|
618
618
|
{},
|
|
619
619
|
{
|
|
620
620
|
title: '',
|
|
621
621
|
duration: 1500,
|
|
622
622
|
},
|
|
623
623
|
options,
|
|
624
624
|
)
|
|
625
625
|
params.duration = params.duration / 1000
|
|
626
626
|
if (isJdApp) {
|
|
627
627
|
const showSuccessType = isIosDevice ?
|
|
628
628
|
ToastIosType.NORMAL :
|
|
629
629
|
ToastAndroidType.NORMAL
|
|
630
630
|
const duration = isAndroidDevice ? 0 : params.duration
|
|
631
631
|
nativePageShowToast(options.title, showSuccessType, duration)
|
|
632
632
|
} else {
|
|
633
633
|
showNormalToast(options)
|
|
634
634
|
}
|
|
635
635
|
const createLoadingEle = document.createElement('div')
|
|
636
636
|
createLoadingEle.id = 'J_shopLoading'
|
|
637
637
|
createLoadingEle.className = `d-shop-loading flexible-center-box ${customClassName}`
|
|
638
638
|
createLoadingEle.innerHTML =
|
|
639
639
|
`<div class='d-loading-content'>
|
|
640
640
|
<span class='d-shop-loading-icon'></span>
|
|
641
641
|
<p class='d-shop-text'>${text}</p>
|
|
642
642
|
</div>`
|
|
643
643
|
const getEle = document.body
|
|
644
644
|
? document.body
|
|
645
645
|
: document.getElementsByTagName('body')[0]
|
|
646
646
|
getEle.appendChild(createLoadingEle)
|
|
647
647
|
const getEle = document.getElementById('J_shopLoading')
|
|
648
648
|
getEle && getEle.remove()
|
|
649
649
|
const systemInfo: UtilsInterFace.taroGetSystemInfoSyncRes = getReviseSystemInfo(
|
|
650
650
|
params,
|
|
651
651
|
)
|
|
652
652
|
if (!systemInfo.system && window) {
|
|
653
653
|
systemInfo.system = window.navigator.userAgent
|
|
654
654
|
systemInfo.isChrome = !!systemInfo?.system.match(/chrome/i)
|
|
655
655
|
}
|
|
656
656
|
const isIOS = !!systemInfo?.system.match(/ios/i)
|
|
657
657
|
const isAndroid = !!systemInfo?.system.match(/android/i)
|
|
658
658
|
systemInfo.navBarHeight = 0
|
|
659
659
|
systemInfo.statusBarHeight = 0
|
|
660
660
|
systemInfo.capsulePosition = null
|
|
661
661
|
systemInfo.isIOS = isIOS
|
|
662
662
|
systemInfo.isAndroid = isAndroid
|
|
663
663
|
_ShopSystemInfo = systemInfo
|
|
664
664
|
return systemInfo
|
|
665
665
|
return originDealShopContentData(pageData, sgmCustomReport, isvdev)
|
|
666
666
|
const numScale = Number(scale)
|
|
667
667
|
if(isNaN(numScale)){
|
|
668
668
|
console.warn(`The 'scale' parameter of the 'isInGrayscale' function is invalid! Expected a number, but received ${scale}`)
|
|
669
669
|
return false
|
|
670
670
|
}
|
|
671
671
|
const { venderId } = global.info.queryInfo || {}
|
|
672
672
|
const id = venderId
|
|
673
673
|
if(!id && numScale !== 1){
|
|
674
674
|
return false
|
|
675
675
|
}
|
|
676
676
|
const useScale = Math.max(0, Math.min(1, numScale))
|
|
677
677
|
const isMatch = numScale === 1 || Math.floor(Number(id) % (1 / useScale)) === 0
|
|
678
678
|
if(reportKey){
|
|
679
679
|
sgmCustomReport({
|
|
680
680
|
code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`),
|
|
681
681
|
msg: '灰度调用',
|
|
682
682
|
})
|
|
683
683
|
console.log(`基于KEY[${reportKey}]的灰度调用1次~`, getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_invoke`))
|
|
684
684
|
if(isMatch){
|
|
685
685
|
sgmCustomReport({
|
|
686
686
|
code: getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`),
|
|
687
687
|
msg: '灰度命中',
|
|
688
688
|
})
|
|
689
689
|
console.log(`基于KEY[${reportKey}]的命中1次灰度!`, getSgmCustomCode(`${SgmCustomCode.GRAYSCALE}_${reportKey}_hit`))
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
692
|
return isMatch
|
|
693
693
|
isJdApp,
|
|
694
694
|
isWxApp,
|
|
695
695
|
isIosDevice,
|
|
696
696
|
isAndroidDevice,
|
|
697
697
|
isJdAndIosDevice,
|
|
698
698
|
isJdAndAndroidDevice,
|
|
699
699
|
isJdAndHarmonyDevice,
|
|
700
700
|
isJdAndroidX5Core,
|
|
701
701
|
isMin,
|
|
702
702
|
isWxMin,
|
|
703
703
|
isWxMinAndWxapp,
|
|
704
704
|
isJdMinAndHarmony,
|
|
705
705
|
isJdMin,
|
|
706
706
|
isH5,
|
|
707
707
|
isH5AndJdShopView,
|
|
708
708
|
isChartH5,
|
|
709
709
|
isH5AndJdShopViewNativeScroll,
|
|
710
710
|
isH5AndJdShopViewH5Scroll,
|
|
711
711
|
isH5AndJdShopH5CustomScrollView,
|
|
712
712
|
isH5AndJingGouMini,
|
|
713
713
|
isWxMiniH5View,
|
|
714
714
|
urlCookie,
|
|
715
715
|
sliceArrToChunkList,
|
|
716
716
|
dealAddress,
|
|
717
717
|
objectToUrlEncode,
|
|
718
718
|
parseQueryUrlString,
|
|
719
719
|
setLowSmallPicUrl,
|
|
720
720
|
setTaroStorage,
|
|
721
721
|
getTaroStorageKeyValue,
|
|
722
722
|
removeTaroStorageKey,
|
|
723
723
|
clearTaroStorageKey,
|
|
724
724
|
getAvifSupport,
|
|
725
725
|
getWebpSupport,
|
|
726
726
|
getQualityImage,
|
|
727
727
|
countStringify,
|
|
728
728
|
getWxAppCookieStr,
|
|
729
729
|
getSystemInfos,
|
|
730
730
|
pxTransformFromData,
|
|
731
731
|
dealShopContentDataAndReport as dealShopContentData,
|
|
732
732
|
dateFormat,
|
|
733
733
|
throttle,
|
|
734
734
|
lodashThrottle,
|
|
735
735
|
debounce,
|
|
736
736
|
addHttps,
|
|
737
737
|
commonShowSuccessToast as showSuccessToast,
|
|
738
738
|
commonShowFailToast as showFailToast,
|
|
739
739
|
commonShowNormalToast as showNormalToast,
|
|
740
740
|
showShopLoading,
|
|
741
741
|
hideShopLoading,
|
|
742
742
|
stopNativeScrollEvent,
|
|
743
743
|
getAppChannelType,
|
|
744
744
|
formatTabActiveMenuType,
|
|
745
745
|
filterUrlQueryData,
|
|
746
746
|
sgmCustomReport,
|
|
747
747
|
isMemberPage,
|
|
748
748
|
getFloorDataToDataDefines,
|
|
749
749
|
isOpenJdAppUrl,
|
|
750
750
|
jdOpenAppParams,
|
|
751
751
|
createJdOpenAppUrl,
|
|
752
752
|
isEmpty,
|
|
753
753
|
getJdAppReportPageSource,
|
|
754
754
|
isAppClassifyPage,
|
|
755
755
|
isAppHomeForMarketPage,
|
|
756
756
|
isImageOptimizeEnable,
|
|
757
757
|
isPc,
|
|
758
758
|
ipLoc_djd,
|
|
759
759
|
isTjScence,
|
|
760
760
|
isH5AdnJxMini,
|
|
761
761
|
isTjM,
|
|
762
762
|
isTjJxM,
|
|
763
763
|
isTJApp,
|
|
764
764
|
isH5AdnHaoWuJie,
|
|
765
765
|
tjChannel,
|
|
766
766
|
dealJdOpenAppData,
|
|
767
767
|
jdAppVersionCompare,
|
|
768
768
|
dealNativePixelToCssPixel,
|
|
769
769
|
isAppStowShop,
|
|
770
770
|
getSgmCustomCode,
|
|
771
771
|
handleSgmCodeTaroVersion,
|
|
772
772
|
isInGrayscale,
|