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