@conecli/cone-render 0.9.1-shop2.9 → 0.10.1-beta.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/assets/icon_blue_info.svg +1 -0
- 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/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/NetworkDataError/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +67 -0
- package/dist/components/debug/DebugLayout/index.tsx +1 -0
- package/dist/components/debug/DebugLayout/utils.ts +1 -0
- 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/jumpEventReport/web.tjm.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 +42 -39
- 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
|
getQualityImage,
|
|
180
180
|
isH5AndJdShopView,
|
|
181
181
|
isJdApp,
|
|
182
182
|
isChartH5,
|
|
183
183
|
isH5AndJdShopViewH5Scroll,
|
|
184
184
|
isAppStowShop,
|
|
185
185
|
sgmCustomReport,
|
|
186
186
|
isImageOptimizeEnable,
|
|
187
187
|
getNativePageScrollRes,
|
|
188
188
|
latestFromNativeMsgStorage,
|
|
189
189
|
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAeCAMAAABT0xOcAAAAe1BMVEUAAADx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fELy0NOAAAAKHRSTlMApwmfFtYm9rWveHDm70yJHYJaD2k8IeIr6pY2X0HHfsGRZDHdu1XNmO+CqgAAAu9JREFUSMfNlNmymzAQRAchkCUhdrMZbLze/v8vjIRMKN8kRR7ykFNeVIPV9Ewj039P1TR8+eILjL7RdLFFJUO8QMS7ZmyDJvZ0nDYGY+aKKDSJpY3OwWX6uFUEY/peCNEbY4Rp6AABixFYkLQRAK3VOmAjUrawMt1GrfWtXD7rlFF3uiA6HV/p0TF1tBECEVskYe+7qqW08mqT1jruneu21/72JfHoSZ7faj2bJu6mOlgEa3qjEXKeL/ACV1s5YSbqYP6stXUeX2FZnV3wuBSZqnVWqDNCIvaFRzZIiGAIw+CS/1brQCslgOQdUBoW10C2EFJei7AkygOlAnmGeMprJq/NjhZpAIrepOpOte2Oq9EXjupIMVoiXduQ9rTo7KsODhxJYaAGuJPjgRvdkRD1KP9CawRwettyF5SbVLZ49ZbuMJxGW93XisXPKA/oXNMDEReJT6N0OfZ2V4RqX4tFQPbOQbntwrl8oXCOQmu2hVosSr6j5QcW+uvukZJP37CWzL7tQs2lH8B53Nd6eq192N/72mdfa52XhdXPx6zcXKYgikLXbaNP66M27edoAO2X+RkQ9tVRhoWC6IZkCZAbHHa1SgDHNdHDsbrLr0ojKTkfDWp6+WPh1APakMAXbVrb6B/Mn+311zlETJZOCJYChttWxedUIyvyi9bLt+J4IPcLvVYypBNaDG5TguCzmct3rUkAPSdHJRLyDEjXQ6Un3GZQBamxaU09gJg+/r+4gqV0uzixXjBfLnDzixrjhDJGNoDXXqvK76OEJaO3L1bx/FQOCSxqcfJVUWiXCydEPowHeIqaZnf3wmvNRsBiC28ttEnS+1oy+lNtOMVAzayZCwsQ5ESNREgvKKuNjjI/ewNHr9Y4N5Is98llx2U8iOQXcKczhDwAM6ObayaanfWDDwhJcMvpU8ucr6+cPji5a8+UEVMCMNo97tLm0MU2uoMmi850yrc8s8Khyzuj7+Q6U7GPMCt8mOtGljP6l/wAUcBZ6lceL/8AAAAASUVORK5CYII='
|
|
190
190
|
'https://img14.360buyimg.com/imagetools/jfs/t1/222907/25/7012/5824/61c4797cEbcd17c7f/6c76fc71e4fdb5a5.png'
|
|
191
191
|
const {
|
|
192
192
|
src,
|
|
193
193
|
lazyLoad,
|
|
194
194
|
imagRenderingSet,
|
|
195
195
|
width,
|
|
196
196
|
height,
|
|
197
197
|
className,
|
|
198
198
|
isSkuImage,
|
|
199
199
|
hideErrorImage,
|
|
200
200
|
style,
|
|
201
201
|
backgroundColor,
|
|
202
202
|
errorSrc,
|
|
203
203
|
onLoad,
|
|
204
204
|
onError,
|
|
205
205
|
...otherOption
|
|
206
206
|
} = props
|
|
207
207
|
getNetWorkType === NetWorkTypeQuality.default &&
|
|
208
208
|
(getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
|
|
209
209
|
const [loadSuccess, setLoadSuccess] = useState(false)
|
|
210
210
|
const [imageErrState, setImageErrState] = useState(false)
|
|
211
211
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
212
212
|
const measureRef = useRef<HTMLElement | null>(null)
|
|
213
213
|
const [measureComplete, setMeasureComplete] = useState(false)
|
|
214
214
|
const [imgSrc, setImgSrc] = useState(src)
|
|
215
215
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
216
216
|
const componentShowStateRef = useRef(false)
|
|
217
217
|
const requestSrcRef = useRef(src)
|
|
218
218
|
const needShowHighVersion =
|
|
219
219
|
isH5AndJdShopViewH5Scroll &&
|
|
220
220
|
!(
|
|
221
221
|
global.info.queryInfo?.downgraded &&
|
|
222
222
|
global.info.queryInfo.downgraded === 'true'
|
|
223
223
|
)
|
|
224
224
|
const enableAvifOptimize = isImageOptimizeEnable()
|
|
225
225
|
|
|
226
226
|
const getRequestSrc = useCallback(
|
|
227
227
|
src => {
|
|
228
228
|
const requestSrc = getQualityImage(imgSrc, {
|
|
229
229
|
isSkuImage,
|
|
230
230
|
size: measureRef?.current?.offsetWidth,
|
|
231
231
|
})
|
|
232
232
|
requestSrcRef.current = requestSrc
|
|
233
233
|
return requestSrc
|
|
234
234
|
},
|
|
235
235
|
[src],
|
|
236
236
|
)
|
|
237
237
|
const imageError = useCallback(
|
|
238
238
|
e => {
|
|
239
239
|
console.log(' ==============> 图片加载错误', e)
|
|
240
240
|
errorSrc && setImgSrc(errorSrc)
|
|
241
241
|
hideErrorImage && setImageErrState(true)
|
|
242
242
|
typeof onError === 'function' && onError(e, src, props)
|
|
243
243
|
const { shopId, venderId } = global.info.queryInfo || {}
|
|
244
244
|
sgmCustomReport({
|
|
245
245
|
code: 'jshopViewImageLoadError',
|
|
246
246
|
msg: {
|
|
247
247
|
shopId,
|
|
248
248
|
venderId,
|
|
249
249
|
buildType,
|
|
250
250
|
originSrc: src,
|
|
251
251
|
requestSrc: requestSrcRef.current,
|
|
252
252
|
},
|
|
253
253
|
})
|
|
254
254
|
},
|
|
255
255
|
[src],
|
|
256
256
|
)
|
|
257
257
|
|
|
258
258
|
const imageLoad = useCallback(
|
|
259
259
|
(_src, event) => {
|
|
260
260
|
setLoadSuccess(true)
|
|
261
261
|
typeof onLoad === 'function' && onLoad(event, src, props)
|
|
262
262
|
},
|
|
263
263
|
[src],
|
|
264
264
|
)
|
|
265
265
|
|
|
266
266
|
const changeStyleIncludeWidthAndHeightAndBgColor = () => {
|
|
267
267
|
const changeStyle = {}
|
|
268
268
|
width && (changeStyle['width'] = width)
|
|
269
269
|
height && (changeStyle['height'] = height)
|
|
270
270
|
backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
|
|
271
271
|
return changeStyle
|
|
272
272
|
}
|
|
273
273
|
useEffect(() => {
|
|
274
274
|
setMeasureComplete(true)
|
|
275
275
|
if (needShowHighVersion) return
|
|
276
276
|
const latestRes =
|
|
277
277
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
278
278
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
279
279
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, res => {
|
|
280
280
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
281
281
|
})
|
|
282
282
|
}, [])
|
|
283
283
|
|
|
284
284
|
const dealPageScrollInfo = res => {
|
|
285
285
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
286
286
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
|
|
287
287
|
return
|
|
288
288
|
if (measureRef.current) {
|
|
289
289
|
const eleClientRect = measureRef.current.getBoundingClientRect()
|
|
290
290
|
const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
|
|
291
291
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
292
292
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
293
293
|
if (!componentShowStateRef.current) {
|
|
294
294
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
295
295
|
componentShowStateRef.current = true
|
|
296
296
|
setComponentShowState(true)
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
return isH5AndJdShopView &&
|
|
302
302
|
global?.config?.needImageLazy !== false &&
|
|
303
303
|
!needShowHighVersion &&
|
|
304
304
|
!isAppStowShop ? (
|
|
305
305
|
<View
|
|
306
306
|
ref={measureRef}
|
|
307
307
|
className={classNames(
|
|
308
308
|
imageStyle['d-app-lazy-image'],
|
|
309
309
|
{
|
|
310
310
|
[imageStyle['d-lazy-sku-image']]: isSkuImage,
|
|
311
311
|
},
|
|
312
312
|
{
|
|
313
313
|
[imageStyle['d-hide-image-error']]: imageErrState,
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
[imageStyle['d-load-completed']]: loadSuccess,
|
|
317
317
|
},
|
|
318
318
|
{
|
|
319
319
|
'd-imag-rendering-crisp-edges':
|
|
320
320
|
!taroJdBaseInfo.info.pageInfo.isVipShop && imagRenderingSet,
|
|
321
321
|
},
|
|
322
322
|
'J_html5ImageBg',
|
|
323
323
|
className,
|
|
324
324
|
)}
|
|
325
325
|
style={{
|
|
326
326
|
...style,
|
|
327
327
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
328
328
|
}}
|
|
329
329
|
{...otherOption}
|
|
330
330
|
>
|
|
331
331
|
{(componentShowState || lazyLoad === false) && (
|
|
332
332
|
<img
|
|
333
333
|
src={getQualityImage(
|
|
334
334
|
imgSrc,
|
|
335
335
|
taroJdBaseInfo.info.pageInfo.isVipShop
|
|
336
336
|
? NetWorkTypeQuality['perfect']
|
|
337
337
|
: NetWorkTypeQuality[getNetWorkType],
|
|
338
338
|
)}
|
|
339
339
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
340
340
|
onError={imageError}
|
|
341
341
|
/>
|
|
342
342
|
)}
|
|
343
343
|
</View>
|
|
344
344
|
) : enableAvifOptimize ? (
|
|
345
345
|
[
|
|
346
346
|
measureComplete ? (
|
|
347
347
|
<Image
|
|
348
348
|
key={'realImage'}
|
|
349
349
|
style={{
|
|
350
350
|
...style,
|
|
351
351
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
352
352
|
}}
|
|
353
353
|
className={classNames(
|
|
354
354
|
imageStyle['d-lazy-image'],
|
|
355
355
|
{
|
|
356
356
|
[imageStyle['d-lazy-sku-image']]: isSkuImage,
|
|
357
357
|
},
|
|
358
358
|
{
|
|
359
359
|
[imageStyle['d-hide-image-error']]: imageErrState,
|
|
360
360
|
},
|
|
361
361
|
{
|
|
362
362
|
[imageStyle['d-load-completed']]: loadSuccess,
|
|
363
363
|
},
|
|
364
364
|
{
|
|
365
365
|
'd-imag-rendering-crisp-edges': imagRenderingSet,
|
|
366
366
|
},
|
|
367
367
|
className,
|
|
368
368
|
)}
|
|
369
369
|
src={getRequestSrc(imgSrc)}
|
|
370
370
|
lazyLoad={isChartH5 ? false : lazyLoad}
|
|
371
371
|
onError={imageError}
|
|
372
372
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
373
373
|
{...otherOption}
|
|
374
374
|
/>
|
|
375
375
|
) : (
|
|
376
376
|
<Image
|
|
377
377
|
key={'defaultImage'}
|
|
378
378
|
style={{
|
|
379
379
|
...style,
|
|
380
380
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
381
381
|
}}
|
|
382
382
|
className={classNames(
|
|
383
383
|
imageStyle['d-lazy-image'],
|
|
384
384
|
{
|
|
385
385
|
[imageStyle['d-lazy-sku-image']]: isSkuImage,
|
|
386
386
|
},
|
|
387
387
|
{
|
|
388
388
|
[imageStyle['d-hide-image-error']]: imageErrState,
|
|
389
389
|
},
|
|
390
390
|
{
|
|
391
391
|
[imageStyle['d-load-completed']]: loadSuccess,
|
|
392
392
|
},
|
|
393
393
|
{
|
|
394
394
|
'd-imag-rendering-crisp-edges': imagRenderingSet,
|
|
395
395
|
},
|
|
396
396
|
className,
|
|
397
397
|
)}
|
|
398
398
|
src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
|
|
399
399
|
/>
|
|
400
400
|
),
|
|
401
401
|
loadSuccess ? null : <View key={'measureRef'} ref={measureRef}></View>,
|
|
402
402
|
]
|
|
403
403
|
) : (
|
|
404
404
|
<Image
|
|
405
405
|
style={{
|
|
406
406
|
...style,
|
|
407
407
|
...changeStyleIncludeWidthAndHeightAndBgColor(),
|
|
408
408
|
}}
|
|
409
409
|
className={classNames(
|
|
410
410
|
imageStyle['d-lazy-image'],
|
|
411
411
|
{
|
|
412
412
|
[imageStyle['d-lazy-sku-image']]: isSkuImage,
|
|
413
413
|
},
|
|
414
414
|
{
|
|
415
415
|
[imageStyle['d-hide-image-error']]: imageErrState,
|
|
416
416
|
},
|
|
417
417
|
{
|
|
418
418
|
[imageStyle['d-load-completed']]: loadSuccess,
|
|
419
419
|
},
|
|
420
420
|
{
|
|
421
421
|
'd-imag-rendering-crisp-edges': imagRenderingSet,
|
|
422
422
|
},
|
|
423
423
|
className,
|
|
424
424
|
)}
|
|
425
425
|
src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
|
|
426
426
|
lazyLoad={isChartH5 ? false : lazyLoad}
|
|
427
427
|
onError={imageError}
|
|
428
428
|
onLoad={imageLoad.bind(this, imgSrc)}
|
|
429
429
|
{...otherOption}
|
|
430
430
|
/>
|
|
431
431
|
)
|
|
432
432
|
lazyLoad: true,
|
|
433
433
|
isSkuImage: false,
|
|
434
434
|
hideErrorImage: false,
|
|
435
435
|
imagRenderingSet: true,
|
|
436
436
|
src: null,
|
|
437
437
|
style: null,
|
|
438
438
|
width: null,
|
|
439
439
|
height: null,
|
|
440
440
|
backgroundColor: null,
|
|
441
441
|
className: null,
|
|
442
442
|
errorSrc: null,
|
|
443
443
|
onLoad: null,
|
|
444
444
|
onError: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { Button, View } from '@tarojs/components'
|
|
2
1
|
NetWorkErrorList,
|
|
3
2
|
NetWorkErrorTip,
|
|
4
3
|
NetWorkErrorSubTip,
|
|
5
4
|
NetWorkShowType,
|
|
6
5
|
NetWork_Image_Type,
|
|
7
6
|
const {
|
|
8
7
|
className,
|
|
9
8
|
message,
|
|
10
9
|
subMessage,
|
|
11
10
|
btnLabel,
|
|
12
11
|
backgroundColorWhite,
|
|
13
12
|
netWorkDataType,
|
|
14
13
|
netWorkShowType,
|
|
15
14
|
netWorkImageType,
|
|
16
15
|
refreshCallBackFn,
|
|
17
16
|
viewMaxHeight
|
|
18
17
|
} = props
|
|
19
18
|
const refershInitData = useCallback(() => {
|
|
20
19
|
refreshCallBackFn && refreshCallBackFn(true)
|
|
21
20
|
}, [])
|
|
22
21
|
const useErrorTip = message != '' ? message : NetWorkErrorTip[netWorkDataType]
|
|
23
22
|
const useErrorSubTip = subMessage
|
|
24
23
|
? subMessage
|
|
25
24
|
: NetWorkErrorSubTip[netWorkDataType]
|
|
26
25
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
27
26
|
const maxHeight = latestRes.displayHeight || 546
|
|
28
27
|
return NetWorkErrorList.includes(netWorkDataType as NETWORK_DATA_TYPE) ? (
|
|
29
28
|
<View
|
|
30
29
|
style={{ maxHeight: viewMaxHeight !== '' ? viewMaxHeight : isMemberPage ? '100vh' : maxHeight }}
|
|
31
30
|
className={classNames(
|
|
32
31
|
netWorkErrorStyle['d-shop-network'],
|
|
33
32
|
{
|
|
34
33
|
[netWorkErrorStyle['d-shop-network-white']]: backgroundColorWhite,
|
|
35
34
|
},
|
|
36
35
|
{
|
|
37
36
|
[netWorkErrorStyle['d-shop-network-part']]:
|
|
38
37
|
netWorkShowType === NetWorkShowType.PART,
|
|
39
38
|
},
|
|
40
39
|
{
|
|
41
40
|
[netWorkErrorStyle['d-network-jd-shop-view']]: isH5AndJdShopView,
|
|
42
41
|
},
|
|
43
42
|
'flexible-center-box',
|
|
44
43
|
className,
|
|
45
44
|
)}
|
|
46
45
|
>
|
|
47
46
|
<View className={classNames(netWorkErrorStyle['d-error-content'],'d-error-content')}>
|
|
48
47
|
<View
|
|
49
48
|
className={classNames(
|
|
50
49
|
netWorkErrorStyle['d-error-type'],
|
|
51
50
|
netWorkErrorStyle[`d-${netWorkDataType}`],
|
|
52
51
|
netWorkErrorStyle[`d-${netWorkImageType}`],
|
|
53
52
|
'd-error-type'
|
|
54
53
|
)}
|
|
55
54
|
/>
|
|
56
55
|
<View className={classNames(netWorkErrorStyle['d-error-tip'],'d-error-tip')}>
|
|
57
56
|
{useErrorTip}
|
|
58
57
|
</View>
|
|
59
58
|
{useErrorSubTip ? <View className={classNames(netWorkErrorStyle['d-error-sub-tip'],'d-error-sub-tip')}>{useErrorSubTip}</View> : null}
|
|
60
59
|
<View className={'flexible-horizontal-center-box'}>
|
|
61
60
|
{refreshCallBackFn && (
|
|
62
61
|
<Button
|
|
63
62
|
onClick={refershInitData}
|
|
64
63
|
className={classNames(
|
|
65
64
|
netWorkErrorStyle['d-opt-btn'],
|
|
66
65
|
'd-button-no-border',
|
|
67
66
|
'd-opt-btn'
|
|
68
67
|
)}
|
|
69
68
|
plain
|
|
70
69
|
size="mini"
|
|
71
70
|
>
|
|
72
71
|
{btnLabel}
|
|
73
72
|
</Button>
|
|
74
73
|
)}
|
|
75
74
|
</View>
|
|
76
75
|
</View>
|
|
77
76
|
</View>
|
|
78
77
|
) : null
|
|
79
78
|
className: '',
|
|
80
79
|
message: '',
|
|
81
80
|
subMessage: '',
|
|
82
81
|
btnLabel: '重新加载',
|
|
83
82
|
backgroundColorWhite: false,
|
|
84
83
|
netWorkDataType: NETWORK_DATA_TYPE.NORMAL,
|
|
85
84
|
netWorkImageType: NetWork_Image_Type.No_Data_Default_Tip,
|
|
86
85
|
netWorkShowType: NetWorkShowType.FULL,
|
|
87
86
|
refreshCallBackFn: null,
|
|
88
87
|
viewMaxHeight: ''
|
|
88
|
+
import { Button, View } from "@tarojs/components";
|
|
89
89
|
NetWorkErrorList,
|
|
90
90
|
NetWorkErrorTip,
|
|
91
91
|
NetWorkErrorSubTip,
|
|
92
92
|
NetWorkShowType,
|
|
93
93
|
NetWork_Image_Type,
|
|
94
94
|
const {
|
|
95
95
|
className,
|
|
96
96
|
message,
|
|
97
97
|
subMessage,
|
|
98
98
|
btnLabel,
|
|
99
99
|
backgroundColorWhite,
|
|
100
100
|
netWorkDataType,
|
|
101
101
|
netWorkShowType,
|
|
102
102
|
netWorkImageType,
|
|
103
103
|
refreshCallBackFn,
|
|
104
104
|
viewMaxHeight,
|
|
105
105
|
} = props;
|
|
106
106
|
const refershInitData = useCallback(() => {
|
|
107
107
|
refreshCallBackFn && refreshCallBackFn(true);
|
|
108
108
|
}, []);
|
|
109
109
|
const useErrorTip =
|
|
110
110
|
message != "" ? message : NetWorkErrorTip[netWorkDataType];
|
|
111
111
|
const useErrorSubTip = subMessage
|
|
112
112
|
? subMessage
|
|
113
113
|
: NetWorkErrorSubTip[netWorkDataType];
|
|
114
114
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {};
|
|
115
115
|
const maxHeight = latestRes.displayHeight || 546;
|
|
116
116
|
return NetWorkErrorList.includes(netWorkDataType as NETWORK_DATA_TYPE) ? (
|
|
117
117
|
<View
|
|
118
118
|
style={{
|
|
119
119
|
maxHeight:
|
|
120
120
|
viewMaxHeight !== ""
|
|
121
121
|
? viewMaxHeight
|
|
122
122
|
: isMemberPage || isAppStowShop
|
|
123
123
|
? "100vh"
|
|
124
124
|
: maxHeight,
|
|
125
125
|
}}
|
|
126
126
|
className={classNames(
|
|
127
127
|
netWorkErrorStyle["d-shop-network"],
|
|
128
128
|
{
|
|
129
129
|
[netWorkErrorStyle["d-shop-network-white"]]: backgroundColorWhite,
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
[netWorkErrorStyle["d-shop-network-part"]]:
|
|
133
133
|
netWorkShowType === NetWorkShowType.PART,
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
[netWorkErrorStyle["d-network-jd-shop-view"]]: isH5AndJdShopView,
|
|
137
137
|
},
|
|
138
138
|
"flexible-center-box",
|
|
139
139
|
className
|
|
140
140
|
)}
|
|
141
141
|
>
|
|
142
142
|
<View
|
|
143
143
|
className={classNames(
|
|
144
144
|
netWorkErrorStyle["d-error-content"],
|
|
145
145
|
"d-error-content"
|
|
146
146
|
)}
|
|
147
147
|
>
|
|
148
148
|
<View
|
|
149
149
|
className={classNames(
|
|
150
150
|
netWorkErrorStyle["d-error-type"],
|
|
151
151
|
netWorkErrorStyle[`d-${netWorkDataType}`],
|
|
152
152
|
netWorkErrorStyle[`d-${netWorkImageType}`],
|
|
153
153
|
"d-error-type"
|
|
154
154
|
)}
|
|
155
155
|
/>
|
|
156
156
|
<View
|
|
157
157
|
className={classNames(
|
|
158
158
|
netWorkErrorStyle["d-error-tip"],
|
|
159
159
|
"d-error-tip"
|
|
160
160
|
)}
|
|
161
161
|
>
|
|
162
162
|
{useErrorTip}
|
|
163
163
|
</View>
|
|
164
164
|
{useErrorSubTip ? (
|
|
165
165
|
<View
|
|
166
166
|
className={classNames(
|
|
167
167
|
netWorkErrorStyle["d-error-sub-tip"],
|
|
168
168
|
"d-error-sub-tip"
|
|
169
169
|
)}
|
|
170
170
|
>
|
|
171
171
|
{useErrorSubTip}
|
|
172
172
|
</View>
|
|
173
173
|
) : null}
|
|
174
174
|
<View className={"flexible-horizontal-center-box"}>
|
|
175
175
|
{refreshCallBackFn && (
|
|
176
176
|
<Button
|
|
177
177
|
onClick={refershInitData}
|
|
178
178
|
className={classNames(
|
|
179
179
|
netWorkErrorStyle["d-opt-btn"],
|
|
180
180
|
"d-button-no-border",
|
|
181
181
|
"d-opt-btn"
|
|
182
182
|
)}
|
|
183
183
|
plain
|
|
184
184
|
size="mini"
|
|
185
185
|
>
|
|
186
186
|
{btnLabel}
|
|
187
187
|
</Button>
|
|
188
188
|
)}
|
|
189
189
|
</View>
|
|
190
190
|
</View>
|
|
191
191
|
</View>
|
|
192
192
|
) : null;
|
|
193
193
|
className: "",
|
|
194
194
|
message: "",
|
|
195
195
|
subMessage: "",
|
|
196
196
|
btnLabel: "重新加载",
|
|
197
197
|
backgroundColorWhite: false,
|
|
198
198
|
netWorkDataType: NETWORK_DATA_TYPE.NORMAL,
|
|
199
199
|
netWorkImageType: NetWork_Image_Type.No_Data_Default_Tip,
|
|
200
200
|
netWorkShowType: NetWorkShowType.FULL,
|
|
201
201
|
refreshCallBackFn: null,
|
|
202
202
|
viewMaxHeight: "",
|