@conecli/cone-render 0.9.1-shop2.10 → 0.9.1-shop2.12
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.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/jdplayerSdk.ts +1 -0
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/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.module.scss +8 -0
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/isv/Floor/index.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.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/open/api/index.ts +1 -1
- package/dist/sass/app.h5.scss +5 -0
- 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 +1 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
1
|
TaroEventType,
|
|
3
2
|
getQualityImage,
|
|
4
3
|
isH5AndJdShopView,
|
|
5
4
|
isJdApp,
|
|
6
5
|
isChartH5,
|
|
7
6
|
isH5AndJdShopViewH5Scroll,
|
|
8
7
|
isAppStowShop
|
|
9
8
|
getNativePageScrollRes,
|
|
10
9
|
latestFromNativeMsgStorage,
|
|
11
10
|
const {
|
|
12
11
|
src,
|
|
13
12
|
lazyLoad,
|
|
14
13
|
imagRenderingSet,
|
|
15
14
|
width,
|
|
16
15
|
height,
|
|
17
16
|
className,
|
|
18
17
|
isSkuImage,
|
|
19
18
|
hideErrorImage,
|
|
20
19
|
style,
|
|
21
20
|
backgroundColor,
|
|
22
21
|
errorSrc,
|
|
23
22
|
onLoad,
|
|
24
23
|
onError,
|
|
25
24
|
...otherOption
|
|
26
25
|
} = props
|
|
27
26
|
getNetWorkType === NetWorkTypeQuality.default &&
|
|
28
27
|
(getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
|
|
29
28
|
const [loadSuccess, setLoadSuccess] = useState(false)
|
|
30
29
|
const [imageErrState, setImageErrState] = useState(false)
|
|
31
30
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
32
31
|
const [imgSrc, setImgSrc] = useState(src)
|
|
33
32
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
34
33
|
const componentShowStateRef = useRef(false)
|
|
35
34
|
const needShowHighVersion =
|
|
36
35
|
isH5AndJdShopViewH5Scroll &&
|
|
37
36
|
!(
|
|
38
37
|
global.info.queryInfo?.downgraded &&
|
|
39
38
|
global.info.queryInfo.downgraded === 'true'
|
|
40
39
|
)
|
|
41
40
|
const imageError = useCallback(
|
|
42
41
|
(e) => {
|
|
43
42
|
console.log('图片加载错误', e)
|
|
44
43
|
errorSrc && setImgSrc(errorSrc)
|
|
45
44
|
hideErrorImage && setImageErrState(true)
|
|
46
45
|
typeof onError === 'function' && onError(e, src, props)
|
|
47
46
|
},
|
|
48
47
|
[src],
|
|
49
48
|
)
|
|
50
49
|
|
|
51
50
|
const imageLoad = useCallback(
|
|
52
51
|
(_src, event) => {
|
|
53
52
|
setLoadSuccess(true)
|
|
54
53
|
typeof onLoad === 'function' && onLoad(event, src, props)
|
|
55
54
|
},
|
|
56
55
|
[src],
|
|
57
56
|
)
|
|
58
57
|
|
|
59
58
|
const changeStyleIncludeWidthAndHeightAndBgColor = () => {
|
|
60
59
|
const changeStyle = {}
|
|
61
60
|
width && (changeStyle['width'] = width)
|
|
62
61
|
height && (changeStyle['height'] = height)
|
|
63
62
|
backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
|
|
64
63
|
return changeStyle
|
|
65
64
|
}
|
|
66
65
|
useEffect(() => {
|
|
67
66
|
if(needShowHighVersion) return
|
|
68
67
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
69
68
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
70
69
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
71
70
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
72
71
|
})
|
|
73
72
|
}, [])
|
|
74
73
|
|
|
75
74
|
const dealPageScrollInfo = (res) => {
|
|
76
75
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
77
76
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
78
77
|
if (componentLazyRef.current) {
|
|
79
78
|
const eleClientRect =
|
|
80
79
|
componentLazyRef.current.getBoundingClientRect()
|
|
81
80
|
const getContainerHeightOffSetY =
|
|
82
81
|
displayHeight * 1.5 + offSetY
|
|
83
82
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
84
83
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
85
84
|
if (!componentShowStateRef.current) {
|
|
86
85
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
87
86
|
componentShowStateRef.current = true
|
|
88
87
|
setComponentShowState(true)
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
return (
|
|
94
93
|
(isH5AndJdShopView && global?.config?.needImageLazy !== false && !needShowHighVersion && !isAppStowShop) ? (
|
|
95
94
|
<View
|
|
96
95
|
ref={ componentLazyRef }
|
|
97
96
|
className={classNames(
|
|
98
97
|
imageStyle['d-app-lazy-image'],
|
|
99
98
|
{
|
|
100
99
|
[imageStyle['d-lazy-sku-image']]: isSkuImage,
|
|
101
100
|
},
|
|
102
101
|
{
|
|
103
102
|
[imageStyle['d-hide-image-error']]: imageErrState,
|
|
104
103
|
},
|
|
105
104
|
{
|
|
106
105
|
[imageStyle['d-load-completed']]: loadSuccess,
|
|
107
106
|
},
|
|
108
107
|
{
|
|
109
108
|
'd-imag-rendering-crisp-edges':
|
|
110
109
|
!taroJdBaseInfo.info.pageInfo.isVipShop &&
|
|
111
110
|
imagRenderingSet,
|
|
112
111
|
},
|
|
113
112
|
'J_html5ImageBg',
|
|
114
113
|
className,
|
|
115
114
|
)}
|
|
116
115
|
style={{
|
|
117
116
|
...style,
|
|
118
117
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
119
118
|
}}
|
|
120
119
|
{...otherOption}
|
|
121
120
|
>
|
|
122
121
|
{(componentShowState || lazyLoad === false) && <img
|
|
123
122
|
src={getQualityImage(
|
|
124
123
|
imgSrc,
|
|
125
124
|
taroJdBaseInfo.info.pageInfo.isVipShop
|
|
126
125
|
? NetWorkTypeQuality['perfect']
|
|
127
126
|
: NetWorkTypeQuality[getNetWorkType],
|
|
128
127
|
)}
|
|
129
128
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
130
129
|
onError={imageError}
|
|
131
130
|
/>}
|
|
132
131
|
</View>
|
|
133
132
|
) : (
|
|
134
133
|
<Image
|
|
135
134
|
style={{
|
|
136
135
|
...style,
|
|
137
136
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
138
137
|
}}
|
|
139
138
|
className={classNames(
|
|
140
139
|
imageStyle['d-lazy-image'],
|
|
141
140
|
{
|
|
142
141
|
[imageStyle['d-lazy-sku-image']]: isSkuImage,
|
|
143
142
|
},
|
|
144
143
|
{
|
|
145
144
|
[imageStyle['d-hide-image-error']]: imageErrState,
|
|
146
145
|
},
|
|
147
146
|
{
|
|
148
147
|
[imageStyle['d-load-completed']]: loadSuccess,
|
|
149
148
|
},
|
|
150
149
|
{
|
|
151
150
|
'd-imag-rendering-crisp-edges': imagRenderingSet,
|
|
152
151
|
},
|
|
153
152
|
className,
|
|
154
153
|
)}
|
|
155
154
|
src={getQualityImage(
|
|
156
155
|
imgSrc,
|
|
157
156
|
NetWorkTypeQuality[getNetWorkType],
|
|
158
157
|
)}
|
|
159
158
|
lazyLoad={isChartH5 ? false : lazyLoad}
|
|
160
159
|
onError={imageError}
|
|
161
160
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
162
161
|
{...otherOption}
|
|
163
162
|
/>
|
|
164
163
|
)
|
|
165
164
|
)
|
|
166
165
|
lazyLoad: true,
|
|
167
166
|
isSkuImage: false,
|
|
168
167
|
hideErrorImage: false,
|
|
169
168
|
imagRenderingSet: true,
|
|
170
169
|
src: null,
|
|
171
170
|
style: null,
|
|
172
171
|
width: null,
|
|
173
172
|
height: null,
|
|
174
173
|
backgroundColor: null,
|
|
175
174
|
className: null,
|
|
176
175
|
errorSrc: null,
|
|
177
176
|
onLoad: null,
|
|
178
177
|
onError: null,
|
|
178
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
179
179
|
TaroEventType,
|
|
180
180
|
const {
|
|
181
181
|
src,
|
|
182
182
|
lazyLoad,
|
|
183
183
|
imagRenderingSet,
|
|
184
184
|
width,
|
|
185
185
|
height,
|
|
186
186
|
className,
|
|
187
187
|
isSkuImage,
|
|
188
188
|
hideErrorImage,
|
|
189
189
|
style,
|
|
190
190
|
backgroundColor,
|
|
191
191
|
errorSrc,
|
|
192
192
|
onLoad,
|
|
193
193
|
onError,
|
|
194
194
|
...otherOption
|
|
195
195
|
} = props
|
|
196
196
|
getNetWorkType === NetWorkTypeQuality.default &&
|
|
197
197
|
(getNetWorkType = global.info.sysInfo.netWorkType)
|
|
198
198
|
const [loadSuccess, setLoadSuccess] = useState(false)
|
|
199
199
|
const [imageErrState, setImageErrState] = useState(false)
|
|
200
200
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
201
201
|
const measureRef = useRef < HTMLElement | null > (null)
|
|
202
202
|
const [measureComplete, setMeasureComplete] = useState(false)
|
|
203
203
|
const [imgSrc, setImgSrc] = useState(src)
|
|
204
204
|
const [hasRetrySuccess, setHasRetrySuccess] = useState(false)
|
|
205
205
|
const hasRetryRef = useRef(false)
|
|
206
206
|
const componentShowStateRef = useRef(false)
|
|
207
207
|
const requestSrcRef = useRef(src)
|
|
208
208
|
const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
|
|
209
209
|
const enableAvifOptimize = isImageOptimizeEnable()
|
|
210
210
|
|
|
211
211
|
const getRequestSrc = useCallback((src) => {
|
|
212
212
|
const requestSrc = getQualityImage(
|
|
213
213
|
imgSrc,
|
|
214
214
|
{ isSkuImage, size: measureRef?.current?.offsetWidth }
|
|
215
215
|
)
|
|
216
216
|
requestSrcRef.current = requestSrc
|
|
217
217
|
return requestSrc
|
|
218
218
|
}, [src])
|
|
219
219
|
const imageErrorRetry = (src) => {
|
|
220
220
|
return new Promise((resolve, reject) => {
|
|
221
221
|
if(fetch && window && window.Image){
|
|
222
222
|
fetch(src)
|
|
223
223
|
.then(response => {
|
|
224
224
|
const {ok, status} = response
|
|
225
225
|
if (ok) {
|
|
226
226
|
response.blob().then(blob => {
|
|
227
227
|
const url = URL.createObjectURL(blob)
|
|
228
228
|
const img = new window.Image()
|
|
229
229
|
img.src = url;
|
|
230
230
|
img.onload = () => {
|
|
231
231
|
resolve({
|
|
232
232
|
ok: true,
|
|
233
233
|
url
|
|
234
234
|
})
|
|
235
235
|
setTimeout(() => {
|
|
236
236
|
URL.revokeObjectURL(url)
|
|
237
237
|
}, 1000)
|
|
238
238
|
};
|
|
239
239
|
img.onerror = () => {
|
|
240
240
|
resolve({
|
|
241
241
|
ok: false,
|
|
242
242
|
text: '图片解析异常',
|
|
243
243
|
type: 'imageParseError',
|
|
244
244
|
})
|
|
245
245
|
URL.revokeObjectURL(url)
|
|
246
246
|
};
|
|
247
247
|
})
|
|
248
248
|
}else {
|
|
249
249
|
if(status === 404){
|
|
250
250
|
resolve({
|
|
251
251
|
ok: false,
|
|
252
252
|
text: '访问图片不存在',
|
|
253
253
|
type: 'noSuchUrlImage',
|
|
254
254
|
})
|
|
255
255
|
}else{
|
|
256
256
|
resolve({
|
|
257
257
|
ok: false,
|
|
258
258
|
status: status,
|
|
259
259
|
text: '其它图片问题',
|
|
260
260
|
type: 'otherImageError',
|
|
261
261
|
})
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
})
|
|
265
265
|
.catch(error => {
|
|
266
266
|
resolve({
|
|
267
267
|
ok: false,
|
|
268
268
|
text: '网络异常',
|
|
269
269
|
type: 'networkError',
|
|
270
270
|
})
|
|
271
271
|
console.error('LazyLoadImage imageErrorRetry() error:', error)
|
|
272
272
|
});
|
|
273
273
|
}else{
|
|
274
274
|
resolve({
|
|
275
275
|
ok: false,
|
|
276
276
|
text: '不支持重试',
|
|
277
277
|
type: 'notSupportRetry',
|
|
278
278
|
})
|
|
279
279
|
}
|
|
280
280
|
})
|
|
281
281
|
|
|
282
282
|
const imageErrorHandle = useCallback(
|
|
283
283
|
(e) => {
|
|
284
284
|
console.log(' ==============> 图片加载错误', e)
|
|
285
285
|
if (!hasRetryRef.current) {
|
|
286
286
|
hasRetryRef.current = true
|
|
287
287
|
if(src){
|
|
288
288
|
try{
|
|
289
289
|
imageErrorRetry(requestSrcRef.current).then((result) => {
|
|
290
290
|
const { status, ok, text, type, url } = result || {}
|
|
291
291
|
if(ok){
|
|
292
292
|
setImgSrc(url)
|
|
293
293
|
setHasRetrySuccess(true)
|
|
294
294
|
}else{
|
|
295
295
|
errorSrc && setImgSrc(errorSrc)
|
|
296
296
|
hideErrorImage && setImageErrState(true)
|
|
297
297
|
typeof onError === 'function' && onError(e, src, props)
|
|
298
298
|
const { shopId, venderId } = global.info.queryInfo || {}
|
|
299
299
|
sgmCustomReport({
|
|
300
300
|
code: getSgmCustomCode(`${SgmCustomCode.IMAGE_LOAD}_${type}`),
|
|
301
301
|
msg: {
|
|
302
302
|
shopId,
|
|
303
303
|
venderId,
|
|
304
304
|
originSrc: src,
|
|
305
305
|
requestSrc: requestSrcRef.current,
|
|
306
306
|
status,
|
|
307
307
|
text
|
|
308
308
|
},
|
|
309
309
|
})
|
|
310
310
|
}
|
|
311
311
|
})
|
|
312
312
|
}catch(e){
|
|
313
313
|
console.error('LazyLoadImage imageErrorHandle() error:', e)
|
|
314
314
|
errorSrc && setImgSrc(errorSrc)
|
|
315
315
|
hideErrorImage && setImageErrState(true)
|
|
316
316
|
typeof onError === 'function' && onError(e, src, props)
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
},
|
|
321
321
|
[src, hasRetryRef.current],
|
|
322
322
|
)
|
|
323
323
|
|
|
324
324
|
|
|
325
325
|
const imageLoad = useCallback(
|
|
326
326
|
(_src, event) => {
|
|
327
327
|
setLoadSuccess(true)
|
|
328
328
|
typeof onLoad === 'function' && onLoad(event, src, props)
|
|
329
329
|
},
|
|
330
330
|
[src],
|
|
331
331
|
)
|
|
332
332
|
|
|
333
333
|
const changeStyleIncludeWidthAndHeightAndBgColor = () => {
|
|
334
334
|
const changeStyle = {}
|
|
335
335
|
width && (changeStyle['width'] = width)
|
|
336
336
|
height && (changeStyle['height'] = height)
|
|
337
337
|
backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
|
|
338
338
|
return changeStyle
|
|
339
339
|
}
|
|
340
340
|
useEffect(() => {
|
|
341
341
|
setMeasureComplete(true)
|
|
342
342
|
if (needShowHighVersion) return
|
|
343
343
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
344
344
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
345
345
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
346
346
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
347
347
|
})
|
|
348
348
|
}, [])
|
|
349
349
|
|
|
350
350
|
const dealPageScrollInfo = (res) => {
|
|
351
351
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
352
352
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
353
353
|
if (measureRef.current) {
|
|
354
354
|
const eleClientRect =
|
|
355
355
|
measureRef.current.getBoundingClientRect()
|
|
356
356
|
const getContainerHeightOffSetY =
|
|
357
357
|
displayHeight * 1.5 + offSetY
|
|
358
358
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
359
359
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
360
360
|
if (!componentShowStateRef.current) {
|
|
361
361
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
362
362
|
componentShowStateRef.current = true
|
|
363
363
|
setComponentShowState(true)
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
return (
|
|
369
369
|
isH5AndJdShopView &&
|
|
370
370
|
global?.config?.needImageLazy !== false &&
|
|
371
371
|
!needShowHighVersion &&
|
|
372
372
|
!isAppStowShop ? (
|
|
373
373
|
<View
|
|
374
374
|
ref={measureRef}
|
|
375
375
|
className={classNames(
|
|
376
376
|
imageStyle["d-app-lazy-image"],
|
|
377
377
|
{
|
|
378
378
|
[imageStyle["d-lazy-sku-image"]]: isSkuImage,
|
|
379
379
|
},
|
|
380
380
|
{
|
|
381
381
|
[imageStyle["d-hide-image-error"]]: imageErrState,
|
|
382
382
|
},
|
|
383
383
|
{
|
|
384
384
|
[imageStyle["d-load-completed"]]: loadSuccess,
|
|
385
385
|
},
|
|
386
386
|
{
|
|
387
387
|
"d-imag-rendering-crisp-edges":
|
|
388
388
|
!global.info.pageInfo.isVipShop && imagRenderingSet,
|
|
389
389
|
},
|
|
390
390
|
"J_html5ImageBg",
|
|
391
391
|
className
|
|
392
392
|
)}
|
|
393
393
|
style={{
|
|
394
394
|
...style,
|
|
395
395
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
396
396
|
}}
|
|
397
397
|
{...otherOption}
|
|
398
398
|
>
|
|
399
399
|
{(componentShowState || lazyLoad === false) && (
|
|
400
400
|
<img
|
|
401
401
|
src={getQualityImage(
|
|
402
402
|
imgSrc,
|
|
403
403
|
global.info.pageInfo.isVipShop
|
|
404
404
|
? NetWorkTypeQuality["perfect"]
|
|
405
405
|
: NetWorkTypeQuality[getNetWorkType]
|
|
406
406
|
)}
|
|
407
407
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
408
408
|
onError={imageErrorHandle}
|
|
409
409
|
/>
|
|
410
410
|
)}
|
|
411
411
|
</View>
|
|
412
412
|
) : enableAvifOptimize ? (
|
|
413
413
|
[
|
|
414
414
|
measureComplete ? (
|
|
415
415
|
<Image
|
|
416
416
|
key={hasRetrySuccess? "realImageRetry": "realImage"}
|
|
417
417
|
style={{
|
|
418
418
|
...style,
|
|
419
419
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
420
420
|
}}
|
|
421
421
|
className={classNames(
|
|
422
422
|
imageStyle["d-lazy-image"],
|
|
423
423
|
{
|
|
424
424
|
[imageStyle["d-lazy-sku-image"]]: isSkuImage,
|
|
425
425
|
},
|
|
426
426
|
{
|
|
427
427
|
[imageStyle["d-hide-image-error"]]: imageErrState,
|
|
428
428
|
},
|
|
429
429
|
{
|
|
430
430
|
[imageStyle["d-load-completed"]]: loadSuccess,
|
|
431
431
|
},
|
|
432
432
|
{
|
|
433
433
|
"d-imag-rendering-crisp-edges": imagRenderingSet,
|
|
434
434
|
},
|
|
435
435
|
className
|
|
436
436
|
)}
|
|
437
437
|
src={hasRetrySuccess? imgSrc: getRequestSrc(imgSrc)}
|
|
438
438
|
lazyLoad={isChartH5 ? false : lazyLoad}
|
|
439
439
|
onError={imageErrorHandle}
|
|
440
440
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
441
441
|
{...otherOption}
|
|
442
442
|
/>
|
|
443
443
|
) : (
|
|
444
444
|
<Image
|
|
445
445
|
key={"defaultImage"}
|
|
446
446
|
style={{
|
|
447
447
|
...style,
|
|
448
448
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
449
449
|
}}
|
|
450
450
|
className={classNames(
|
|
451
451
|
imageStyle["d-lazy-image"],
|
|
452
452
|
{
|
|
453
453
|
[imageStyle["d-lazy-sku-image"]]: isSkuImage,
|
|
454
454
|
},
|
|
455
455
|
{
|
|
456
456
|
[imageStyle["d-hide-image-error"]]: imageErrState,
|
|
457
457
|
},
|
|
458
458
|
{
|
|
459
459
|
[imageStyle["d-load-completed"]]: loadSuccess,
|
|
460
460
|
},
|
|
461
461
|
{
|
|
462
462
|
"d-imag-rendering-crisp-edges": imagRenderingSet,
|
|
463
463
|
},
|
|
464
464
|
className
|
|
465
465
|
)}
|
|
466
466
|
src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
|
|
467
467
|
/>
|
|
468
468
|
),
|
|
469
469
|
loadSuccess ? null : <View key={"measureRef"} ref={measureRef}></View>,
|
|
470
470
|
]
|
|
471
471
|
) : (
|
|
472
472
|
<Image
|
|
473
473
|
style={{
|
|
474
474
|
...style,
|
|
475
475
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
476
476
|
}}
|
|
477
477
|
className={classNames(
|
|
478
478
|
imageStyle["d-lazy-image"],
|
|
479
479
|
{
|
|
480
480
|
[imageStyle["d-lazy-sku-image"]]: isSkuImage,
|
|
481
481
|
},
|
|
482
482
|
{
|
|
483
483
|
[imageStyle["d-hide-image-error"]]: imageErrState,
|
|
484
484
|
},
|
|
485
485
|
{
|
|
486
486
|
[imageStyle["d-load-completed"]]: loadSuccess,
|
|
487
487
|
},
|
|
488
488
|
{
|
|
489
489
|
"d-imag-rendering-crisp-edges": imagRenderingSet,
|
|
490
490
|
},
|
|
491
491
|
className
|
|
492
492
|
)}
|
|
493
493
|
src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
|
|
494
494
|
lazyLoad={isChartH5 ? false : lazyLoad}
|
|
495
495
|
onError={imageErrorHandle}
|
|
496
496
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
497
497
|
{...otherOption}
|
|
498
498
|
/>
|
|
499
499
|
)
|
|
500
500
|
)
|
|
501
501
|
lazyLoad: true,
|
|
502
502
|
isSkuImage: false,
|
|
503
503
|
hideErrorImage: false,
|
|
504
504
|
imagRenderingSet: true,
|
|
505
505
|
src: null,
|
|
506
506
|
style: null,
|
|
507
507
|
width: null,
|
|
508
508
|
height: null,
|
|
509
509
|
backgroundColor: null,
|
|
510
510
|
className: null,
|
|
511
511
|
errorSrc: null,
|
|
512
512
|
onLoad: null,
|
|
513
513
|
onError: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useEffect, useContext, useState } from 'react'
|
|
2
1
|
const { title, openAppParams, style, hasCommonHeader = true, hasDownloadTips = true, headerParams } = props
|
|
3
2
|
useEffect(() => {
|
|
4
3
|
hasCommonHeader && initCommonHeader()
|
|
5
4
|
hasDownloadTips && initDownloadAppLayerConfigData()
|
|
6
5
|
}, [])
|
|
7
6
|
const initCommonHeader = () => {
|
|
8
7
|
if (window?.MCommonHeaderBottom) {
|
|
9
8
|
const mchb = new MCommonHeaderBottom()
|
|
10
9
|
const headerArg = {
|
|
11
10
|
moduleName: 'shop',
|
|
12
11
|
hrederId: 'm_common_header',
|
|
13
12
|
title,
|
|
14
13
|
stype: 1,
|
|
15
14
|
onClickJdkey: function () {
|
|
16
15
|
console.log('==>m_common_header jdkey click.')
|
|
17
16
|
},
|
|
18
17
|
...headerParams
|
|
19
18
|
}
|
|
20
19
|
mchb.header(headerArg)
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
const initDownloadAppLayerConfigData = () => {
|
|
24
23
|
const getEle = document.getElementById('m_common_tip')
|
|
25
24
|
getEle &&
|
|
26
25
|
window.$ &&
|
|
27
26
|
window.$.downloadAppLayerConfigData &&
|
|
28
27
|
window.$.downloadAppLayerConfigData({
|
|
29
28
|
tipId: 'm_common_tip',
|
|
30
29
|
M_sourceFrom: 'jshop',
|
|
31
30
|
bottom: 74,
|
|
32
31
|
onClickTipX: () => {
|
|
33
32
|
Taro.eventCenter.trigger(
|
|
34
33
|
TaroEventType.DOWN_LOAD_APP_CLOSE_CHANGE,
|
|
35
34
|
true,
|
|
36
35
|
)
|
|
37
36
|
},
|
|
38
37
|
downloadAppPlugIn: {
|
|
39
38
|
M_sourceFrom: 'jshop',
|
|
40
39
|
openAppBtnId: 'download_openapp',
|
|
41
40
|
downAppURl: '//conecli.com/downloadApp/download.html?channel=jd-m',
|
|
42
41
|
inteneUrl: 'openapp.jdmobile://virtual?',
|
|
43
42
|
inteneUrlParams: {
|
|
44
43
|
category: 'jump',
|
|
45
44
|
des: 'jshopMain',
|
|
46
45
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
47
46
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
48
47
|
sourceType: global.info.queryInfo?.sourceType || 'M-H5',
|
|
49
48
|
sourceValue: global.info.queryInfo?.sourceValue || 'Mshop',
|
|
50
49
|
...openAppParams,
|
|
51
50
|
},
|
|
52
51
|
},
|
|
53
52
|
})
|
|
54
53
|
}
|
|
55
54
|
return !isWxMiniH5View && !isJdApp ? (
|
|
56
55
|
<View
|
|
57
56
|
className={mobileCommonHeaderStyle['d-mobile-header-layout']}
|
|
58
57
|
style={style}
|
|
59
58
|
>
|
|
60
59
|
<View
|
|
61
60
|
id="m_common_tip"
|
|
62
61
|
className={mobileCommonHeaderStyle['d-mobile-common-tip']}
|
|
63
62
|
/>
|
|
64
63
|
{hasCommonHeader && (
|
|
65
64
|
<View
|
|
66
65
|
id="m_common_header"
|
|
67
66
|
className={mobileCommonHeaderStyle['d-mobile-common-header']}
|
|
68
67
|
/>
|
|
69
68
|
)}
|
|
70
69
|
</View>
|
|
71
70
|
) : null
|
|
72
71
|
title: '店铺',
|
|
73
72
|
openAppParams: {},
|
|
73
|
+
import React, {useEffect, useRef} from 'react'
|
|
74
74
|
const { title, openAppParams, style, hasCommonHeader = true, hasDownloadTips = true, headerParams } = props
|
|
75
75
|
const headerRef:any = useRef(null)
|
|
76
76
|
useEffect(() => {
|
|
77
77
|
hasCommonHeader && initCommonHeader()
|
|
78
78
|
hasDownloadTips && initDownloadAppLayerConfigData()
|
|
79
79
|
}, [])
|
|
80
80
|
const scrollEventFunc = () => {
|
|
81
81
|
const stickyTop = headerRef.current?.getBoundingClientRect()?.top || 0;
|
|
82
82
|
const rootScrollEleNode = document.querySelector('#J_shopHomeRoot')
|
|
83
83
|
if (rootScrollEleNode && rootScrollEleNode.scrollTop > stickyTop) {
|
|
84
84
|
headerRef.current.classList.add('d-mobile-header-sticky');
|
|
85
85
|
} else {
|
|
86
86
|
headerRef.current.classList.remove('d-mobile-header-sticky');
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
useEffect(() => {
|
|
90
90
|
if(!headerRef.current) return
|
|
91
91
|
const rootScrollEleNode = document.querySelector('#J_shopHomeRoot')
|
|
92
92
|
rootScrollEleNode && rootScrollEleNode.addEventListener('scroll', scrollEventFunc);
|
|
93
93
|
return () => {
|
|
94
94
|
rootScrollEleNode && rootScrollEleNode.removeEventListener('scroll', scrollEventFunc)
|
|
95
95
|
}
|
|
96
96
|
},[])
|
|
97
97
|
const initCommonHeader = () => {
|
|
98
98
|
if (window?.MCommonHeaderBottom) {
|
|
99
99
|
const mchb = new MCommonHeaderBottom()
|
|
100
100
|
const headerArg = {
|
|
101
101
|
moduleName: 'shop',
|
|
102
102
|
hrederId: 'm_common_header',
|
|
103
103
|
title,
|
|
104
104
|
stype: 1,
|
|
105
105
|
onClickJdkey: function () {
|
|
106
106
|
console.log('==>m_common_header jdkey click.')
|
|
107
107
|
},
|
|
108
108
|
...headerParams
|
|
109
109
|
}
|
|
110
110
|
mchb.header(headerArg)
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
const initDownloadAppLayerConfigData = () => {
|
|
114
114
|
const getEle = document.getElementById('m_common_tip')
|
|
115
115
|
getEle &&
|
|
116
116
|
window.$ &&
|
|
117
117
|
window.$.downloadAppLayerConfigData &&
|
|
118
118
|
window.$.downloadAppLayerConfigData({
|
|
119
119
|
tipId: 'm_common_tip',
|
|
120
120
|
M_sourceFrom: 'jshop',
|
|
121
121
|
bottom: 74,
|
|
122
122
|
onClickTipX: () => {
|
|
123
123
|
Taro.eventCenter.trigger(
|
|
124
124
|
TaroEventType.DOWN_LOAD_APP_CLOSE_CHANGE,
|
|
125
125
|
true,
|
|
126
126
|
)
|
|
127
127
|
},
|
|
128
128
|
downloadAppPlugIn: {
|
|
129
129
|
M_sourceFrom: 'jshop',
|
|
130
130
|
openAppBtnId: 'download_openapp',
|
|
131
131
|
downAppURl: '//conecli.com/downloadApp/download.html?channel=jd-m',
|
|
132
132
|
inteneUrl: 'openapp.jdmobile://virtual?',
|
|
133
133
|
inteneUrlParams: {
|
|
134
134
|
category: 'jump',
|
|
135
135
|
des: 'jshopMain',
|
|
136
136
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
137
137
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
138
138
|
sourceType: global.info.queryInfo?.sourceType || 'M-H5',
|
|
139
139
|
sourceValue: global.info.queryInfo?.sourceValue || 'Mshop',
|
|
140
140
|
...openAppParams,
|
|
141
141
|
},
|
|
142
142
|
},
|
|
143
143
|
})
|
|
144
144
|
}
|
|
145
145
|
return !isWxMiniH5View && !isJdApp ? (
|
|
146
146
|
<View
|
|
147
147
|
className={mobileCommonHeaderStyle['d-mobile-header-layout']}
|
|
148
148
|
style={style}
|
|
149
149
|
ref={headerRef}
|
|
150
150
|
>
|
|
151
151
|
<View
|
|
152
152
|
id="m_common_tip"
|
|
153
153
|
className={mobileCommonHeaderStyle['d-mobile-common-tip']}
|
|
154
154
|
/>
|
|
155
155
|
{hasCommonHeader && (
|
|
156
156
|
<View
|
|
157
157
|
id="m_common_header"
|
|
158
158
|
className={mobileCommonHeaderStyle['d-mobile-common-header']}
|
|
159
159
|
/>
|
|
160
160
|
)}
|
|
161
161
|
</View>
|
|
162
162
|
) : null
|
|
163
163
|
title: '店铺',
|
|
164
164
|
openAppParams: {},
|