@conecli/cone-render 0.8.28 → 0.8.30
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/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.ts +1 -1
- package/dist/components/base/CommonFloorHead/index.module.scss +1 -1
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CustomVideo/index.module.scss +3 -2
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +6 -2
- package/dist/components/base/Dialog/index.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/{const.ts → Base/const.ts} +0 -0
- package/dist/components/base/Price/Base/index.module.scss +136 -0
- package/dist/components/base/Price/Base/index.tsx +1 -0
- package/dist/components/base/Price/Double/index.module.scss +158 -0
- package/dist/components/base/Price/Double/index.tsx +1 -0
- package/dist/components/base/Price/index.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/service/bMallConst.ts +1 -1
- package/dist/service/bMallConst.wxapp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/colorSign.wxapp.ts +1 -0
- package/dist/service/http/const.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jm-common.js +1 -1
- package/dist/utils/memberFormatUtils.js +1 -0
- package/dist/utils/priceUtils.js +1 -0
- package/dist/utils/utils.ts +1 -1
- package/package.json +3 -3
- package/dist/components/base/Price/index.module.scss +0 -136
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
1
|
isH5,
|
|
3
2
|
addHttps,
|
|
4
3
|
isH5AndJingGouMini,
|
|
5
4
|
isH5AndJdShopView,
|
|
6
5
|
(props: ComponentInterFace.CustomVideoProps, ref: any) => {
|
|
7
6
|
const {
|
|
8
7
|
style,
|
|
9
8
|
videoStyle,
|
|
10
9
|
src,
|
|
11
10
|
width,
|
|
12
11
|
height,
|
|
13
12
|
controls,
|
|
14
13
|
poster,
|
|
15
14
|
autoplay,
|
|
16
15
|
loop,
|
|
17
16
|
showMuteBtn,
|
|
18
17
|
muteButtonPostion,
|
|
19
18
|
showFullscreenBtn,
|
|
20
19
|
muteBtnPicSrcObj,
|
|
21
20
|
muteBtnClassName,
|
|
22
21
|
objectFit,
|
|
23
22
|
mockAutoplay,
|
|
24
23
|
threshold,
|
|
25
24
|
onPlayCallback,
|
|
26
25
|
onPauseCallback,
|
|
27
26
|
onVideoApiCall,
|
|
28
27
|
inViewCallback,
|
|
29
28
|
outViewCallback,
|
|
30
29
|
} = props
|
|
31
30
|
const [videoMutedState, setVideoMutedState] = useState(MUTED)
|
|
32
31
|
const manualPauseStateRef = useRef(false)
|
|
33
32
|
const initPlayStatusRef = useRef(false)
|
|
34
33
|
const isInViewStateRef = useRef(false)
|
|
35
34
|
const disposeRef = useRef<Function | null>()
|
|
36
35
|
ref === null && (ref = useRef<HTMLVideoElement | null>())
|
|
37
36
|
|
|
38
37
|
const playVideo = useCallback(() => {
|
|
39
38
|
if (ref && ref.current) {
|
|
40
39
|
const result = ref.current.play()
|
|
41
40
|
result &&
|
|
42
41
|
result
|
|
43
42
|
.then(() => {
|
|
44
43
|
console.log('播放成功')
|
|
45
44
|
})
|
|
46
45
|
.catch((e) => {
|
|
47
46
|
console.log('playVideo Error:', e.message)
|
|
48
47
|
})
|
|
49
48
|
}
|
|
50
49
|
}, [])
|
|
51
50
|
|
|
52
51
|
const pauseVideo = useCallback(() => {
|
|
53
52
|
if (ref && ref.current) {
|
|
54
53
|
console.log('pauseVideo')
|
|
55
54
|
ref.current.pause()
|
|
56
55
|
}
|
|
57
56
|
}, [])
|
|
58
57
|
|
|
59
58
|
useEffect(() => {
|
|
60
59
|
if (!isH5 || !ref.current) return
|
|
61
60
|
if (autoplay && mockAutoplay) {
|
|
62
61
|
|
|
63
62
|
const callInitAutoplay = () => {
|
|
64
63
|
console.log(
|
|
65
64
|
'callInitAutoplay:',
|
|
66
65
|
autoplay,
|
|
67
66
|
'initPlayStatusRef:',
|
|
68
67
|
initPlayStatusRef.current,
|
|
69
68
|
'isInViewStateRef:',
|
|
70
69
|
isInViewStateRef.current,
|
|
71
70
|
'paused:',
|
|
72
71
|
ref.current.paused,
|
|
73
72
|
)
|
|
74
73
|
if (
|
|
75
74
|
autoplay &&
|
|
76
75
|
mockAutoplay &&
|
|
77
76
|
!initPlayStatusRef.current &&
|
|
78
77
|
isInViewStateRef.current &&
|
|
79
78
|
ref.current.paused
|
|
80
79
|
) {
|
|
81
80
|
console.log('callInitAutoplay playVideo')
|
|
82
81
|
playVideo()
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
const onWeixinJSBridgeReady = (e) => {
|
|
86
85
|
console.log('onWeixinJSBridgeReady:', e.type)
|
|
87
86
|
callInitAutoplay()
|
|
88
87
|
}
|
|
89
88
|
const onTouchstart = (e) => {
|
|
90
89
|
console.log('onTouchstart:', e.type)
|
|
91
90
|
callInitAutoplay()
|
|
92
91
|
}
|
|
93
92
|
const onScroll = (e) => {
|
|
94
93
|
console.log('onScroll:', e.type)
|
|
95
94
|
callInitAutoplay()
|
|
96
95
|
}
|
|
97
96
|
const onPlay = (e) => {
|
|
98
97
|
console.log('onPlay:', e.type)
|
|
99
98
|
if (!initPlayStatusRef.current) {
|
|
100
99
|
const dispose = disposeRef.current
|
|
101
100
|
console.log('onPlay dispose:', dispose)
|
|
102
101
|
dispose && dispose()
|
|
103
102
|
disposeRef.current = null
|
|
104
103
|
}
|
|
105
104
|
initPlayStatusRef.current = true
|
|
106
105
|
}
|
|
107
106
|
document?.addEventListener('WeixinJSBridgeReady', onWeixinJSBridgeReady)
|
|
108
107
|
document?.addEventListener('touchstart', onTouchstart)
|
|
109
108
|
document?.addEventListener('scroll', onScroll)
|
|
110
109
|
ref.current.addEventListener('play', onPlay)
|
|
111
110
|
const dispose = () => {
|
|
112
111
|
console.log('调用dispose')
|
|
113
112
|
document?.removeEventListener(
|
|
114
113
|
'WeixinJSBridgeReady',
|
|
115
114
|
onWeixinJSBridgeReady,
|
|
116
115
|
)
|
|
117
116
|
document?.removeEventListener('touchstart', onTouchstart)
|
|
118
117
|
document?.removeEventListener('scroll', onScroll)
|
|
119
118
|
ref?.current?.removeEventListener('play', onPlay)
|
|
120
119
|
}
|
|
121
120
|
disposeRef.current = dispose
|
|
122
121
|
}
|
|
123
122
|
!autoplay && (manualPauseStateRef.current = true)
|
|
124
123
|
const handleVideoPlayApiCall = () => {
|
|
125
124
|
if (!isH5 || !ref.current) return
|
|
126
125
|
playVideo()
|
|
127
126
|
manualPauseStateRef.current = false
|
|
128
127
|
}
|
|
129
128
|
const handleVideoPauseApiCall = () => {
|
|
130
129
|
if (!isH5 || !ref.current) return
|
|
131
130
|
pauseVideo()
|
|
132
131
|
manualPauseStateRef.current = true
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
if (onVideoApiCall) {
|
|
136
135
|
onVideoApiCall({
|
|
137
136
|
play: handleVideoPlayApiCall,
|
|
138
137
|
pause: handleVideoPauseApiCall,
|
|
139
138
|
})
|
|
140
139
|
}
|
|
141
140
|
return () => {
|
|
142
141
|
const dispose = disposeRef.current
|
|
143
142
|
dispose && dispose()
|
|
144
143
|
disposeRef.current = null
|
|
145
144
|
}
|
|
146
145
|
}, [])
|
|
147
146
|
|
|
148
147
|
const handleMuted = useCallback(() => {
|
|
149
148
|
if (!isH5 || !ref.current) return
|
|
150
149
|
const handleMutedState = ref.current.muted
|
|
151
150
|
if (handleMutedState === true) {
|
|
152
151
|
ref.current.muted = false
|
|
153
152
|
setVideoMutedState(false)
|
|
154
153
|
} else {
|
|
155
154
|
ref.current.muted = true
|
|
156
155
|
setVideoMutedState(true)
|
|
157
156
|
}
|
|
158
157
|
}, [videoMutedState])
|
|
159
158
|
|
|
160
159
|
const handleVideoInViewCallback = useCallback(() => {
|
|
161
160
|
if (!isH5 || !ref.current) return
|
|
162
161
|
isInViewStateRef.current = true
|
|
163
162
|
console.log(
|
|
164
163
|
'进入可视区域,initPlayStatusRef:',
|
|
165
164
|
initPlayStatusRef.current,
|
|
166
165
|
'isInViewStateRef:',
|
|
167
166
|
isInViewStateRef.current,
|
|
168
167
|
)
|
|
169
168
|
if (
|
|
170
169
|
autoplay &&
|
|
171
170
|
mockAutoplay &&
|
|
172
171
|
!initPlayStatusRef.current &&
|
|
173
172
|
ref.current.paused
|
|
174
173
|
) {
|
|
175
174
|
console.log('进入可视区域了 callInitAutoplay playVideo')
|
|
176
175
|
playVideo()
|
|
177
176
|
} else if (!manualPauseStateRef.current && ref.current.paused) {
|
|
178
177
|
playVideo()
|
|
179
178
|
}
|
|
180
179
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
181
180
|
}, [])
|
|
182
181
|
|
|
183
182
|
const handleVideoOutViewCallback = useCallback(() => {
|
|
184
183
|
if (!isH5 || !ref.current) return
|
|
185
184
|
isInViewStateRef.current = false
|
|
186
185
|
console.log(
|
|
187
186
|
'不在可视区域, 视频暂停了, isInViewStateRef:',
|
|
188
187
|
isInViewStateRef.current,
|
|
189
188
|
)
|
|
190
189
|
pauseVideo()
|
|
191
190
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
192
191
|
}, [])
|
|
193
192
|
|
|
194
193
|
const getVideoWidthAndHeightStyle = () => {
|
|
195
194
|
const style = {}
|
|
196
195
|
width && (style['width'] = width)
|
|
197
196
|
height && (style['height'] = height)
|
|
198
197
|
return style
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
const getMuteBtnBackgroundImageStyle = useCallback(() => {
|
|
202
201
|
const isMutedPicSrc = muteBtnPicSrcObj?.IS_MUTED
|
|
203
202
|
const notMutedPicSrc = muteBtnPicSrcObj?.NOT_MUTED
|
|
204
203
|
const finalIsMutedPicSrc =
|
|
205
204
|
typeof isMutedPicSrc !== 'undefined' && isMutedPicSrc !== ''
|
|
206
205
|
? isMutedPicSrc
|
|
207
206
|
: DEFAULT_MUTE_BTN_PIC.IS_MUTED
|
|
208
207
|
const finalNotMutedPicSrc =
|
|
209
208
|
typeof notMutedPicSrc !== 'undefined' && notMutedPicSrc !== ''
|
|
210
209
|
? notMutedPicSrc
|
|
211
210
|
: DEFAULT_MUTE_BTN_PIC.NOT_MUTED
|
|
212
211
|
return {
|
|
213
212
|
backgroundImage: `url(${
|
|
214
213
|
videoMutedState ? finalIsMutedPicSrc : finalNotMutedPicSrc
|
|
215
214
|
})`,
|
|
216
215
|
}
|
|
217
216
|
}, [videoMutedState])
|
|
218
217
|
console.log('autoplay:', autoplay, 'muted:', MUTED)
|
|
219
218
|
console.log('isH5:', isH5, 'isH5AndJingGouMini:', isH5AndJingGouMini)
|
|
220
219
|
return src ? (
|
|
221
220
|
<InOrOutViewObserver
|
|
222
221
|
inViewCallback={handleVideoInViewCallback}
|
|
223
222
|
outViewCallback={handleVideoOutViewCallback}
|
|
224
223
|
threshold={threshold}
|
|
225
224
|
>
|
|
226
225
|
{isH5 ? (
|
|
227
226
|
<View
|
|
228
227
|
className={customVideoStyle['d-video-wrap']}
|
|
229
228
|
style={{ ...style, ...getVideoWidthAndHeightStyle() }}
|
|
230
229
|
>
|
|
231
230
|
<video
|
|
232
231
|
style={{ ...videoStyle }}
|
|
233
232
|
className={customVideoStyle['d-video-play']}
|
|
234
233
|
src={src}
|
|
235
234
|
controls={controls}
|
|
236
235
|
poster={poster ? addHttps(poster) : ''}
|
|
237
236
|
ref={ref}
|
|
238
237
|
loop={loop}
|
|
239
238
|
autoPlay={autoplay}
|
|
240
239
|
muted={MUTED}
|
|
241
240
|
x5-playsinline="true"
|
|
242
241
|
playsInline
|
|
243
242
|
webkit-playsinline="true"
|
|
244
243
|
controlsList={
|
|
245
244
|
isH5AndJdShopView
|
|
246
245
|
? 'nodownload nofullscreen noremoteplayback'
|
|
247
246
|
: ''
|
|
248
247
|
}
|
|
249
248
|
onPlay={onPlayCallback}
|
|
250
249
|
onPause={onPauseCallback}
|
|
251
250
|
/>
|
|
252
251
|
{!controls && showMuteBtn && (
|
|
253
252
|
<View
|
|
254
253
|
className={classNames(
|
|
255
254
|
customVideoStyle['d-video-mute-btn'],
|
|
256
255
|
customVideoStyle[`d-mute-btn-${muteButtonPostion}`],
|
|
257
256
|
`${muteBtnClassName}`,
|
|
258
257
|
)}
|
|
259
258
|
style={getMuteBtnBackgroundImageStyle()}
|
|
260
259
|
onClick={handleMuted}
|
|
261
260
|
></View>
|
|
262
261
|
)}
|
|
263
262
|
</View>
|
|
264
263
|
) : (
|
|
265
264
|
<Video
|
|
266
265
|
style={{ ...videoStyle }}
|
|
267
266
|
ref={ref}
|
|
268
267
|
className={customVideoStyle['d-video-play']}
|
|
269
268
|
src={src}
|
|
270
269
|
controls={controls}
|
|
271
270
|
poster={poster ? addHttps(poster) : ''}
|
|
272
271
|
loop={loop}
|
|
273
272
|
autoplay={autoplay}
|
|
274
273
|
muted={MUTED}
|
|
275
274
|
showMuteBtn={showMuteBtn}
|
|
276
275
|
showFullscreenBtn={showFullscreenBtn}
|
|
277
276
|
objectFit={objectFit}
|
|
278
277
|
onPlay={onPlayCallback}
|
|
279
278
|
onPause={onPauseCallback}
|
|
280
279
|
/>
|
|
281
280
|
)}
|
|
282
281
|
</InOrOutViewObserver>
|
|
283
282
|
) : null
|
|
284
283
|
},
|
|
285
284
|
const buildType = process.env.BUILD_TYPE
|
|
286
285
|
const mockAutoplay = buildType === BUILD_TYPE.DECORATE ? false : true
|
|
287
286
|
return mockAutoplay
|
|
288
287
|
style: {},
|
|
289
288
|
videoStyle: {},
|
|
290
289
|
className: '',
|
|
291
290
|
src: '',
|
|
292
291
|
width: '100%',
|
|
293
292
|
height: '100%',
|
|
294
293
|
controls: false,
|
|
295
294
|
poster: '',
|
|
296
295
|
autoplay: true,
|
|
297
296
|
mockAutoplay: getDefaultMockAutoplay(),
|
|
298
297
|
loop: true,
|
|
299
298
|
showMuteBtn: true,
|
|
300
299
|
muteButtonPostion: 'topLeft',
|
|
301
300
|
muteBtnPicSrcObj: DEFAULT_MUTE_BTN_PIC,
|
|
302
301
|
muteBtnClassName: '',
|
|
303
302
|
showFullscreenBtn: false,
|
|
304
303
|
objectFit: 'cover',
|
|
305
304
|
threshold: 0.6,
|
|
305
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
306
306
|
isH5,
|
|
307
307
|
addHttps,
|
|
308
308
|
isH5AndJingGouMini,
|
|
309
309
|
isH5AndJdShopView,
|
|
310
310
|
(props: ComponentInterFace.CustomVideoProps, ref: any) => {
|
|
311
311
|
const {
|
|
312
312
|
style,
|
|
313
313
|
videoStyle,
|
|
314
314
|
src,
|
|
315
315
|
width,
|
|
316
316
|
height,
|
|
317
317
|
controls,
|
|
318
318
|
poster,
|
|
319
319
|
autoplay,
|
|
320
320
|
loop,
|
|
321
321
|
showMuteBtn,
|
|
322
322
|
muteButtonPostion,
|
|
323
323
|
showFullscreenBtn,
|
|
324
324
|
muteBtnPicSrcObj,
|
|
325
325
|
muteBtnClassName,
|
|
326
326
|
muteBtnStyle,
|
|
327
327
|
objectFit,
|
|
328
328
|
mockAutoplay,
|
|
329
329
|
threshold,
|
|
330
330
|
onPlayCallback,
|
|
331
331
|
onPauseCallback,
|
|
332
332
|
onVideoApiCall,
|
|
333
333
|
inViewCallback,
|
|
334
334
|
outViewCallback,
|
|
335
335
|
} = props
|
|
336
336
|
const [videoMutedState, setVideoMutedState] = useState(MUTED)
|
|
337
337
|
const manualPauseStateRef = useRef(false)
|
|
338
338
|
const initPlayStatusRef = useRef(false)
|
|
339
339
|
const isInViewStateRef = useRef(false)
|
|
340
340
|
const disposeRef = useRef<Function | null>()
|
|
341
341
|
ref === null && (ref = useRef<HTMLVideoElement | null>())
|
|
342
342
|
|
|
343
343
|
const playVideo = useCallback(() => {
|
|
344
344
|
if (ref && ref.current) {
|
|
345
345
|
const result = ref.current.play()
|
|
346
346
|
result &&
|
|
347
347
|
result
|
|
348
348
|
.then(() => {
|
|
349
349
|
console.log('播放成功')
|
|
350
350
|
})
|
|
351
351
|
.catch((e) => {
|
|
352
352
|
console.log('playVideo Error:', e.message)
|
|
353
353
|
})
|
|
354
354
|
}
|
|
355
355
|
}, [])
|
|
356
356
|
|
|
357
357
|
const pauseVideo = useCallback(() => {
|
|
358
358
|
if (ref && ref.current) {
|
|
359
359
|
console.log('pauseVideo')
|
|
360
360
|
ref.current.pause()
|
|
361
361
|
}
|
|
362
362
|
}, [])
|
|
363
363
|
|
|
364
364
|
useEffect(() => {
|
|
365
365
|
if (!isH5 || !ref.current) return
|
|
366
366
|
if (autoplay && mockAutoplay) {
|
|
367
367
|
|
|
368
368
|
const callInitAutoplay = () => {
|
|
369
369
|
console.log(
|
|
370
370
|
'callInitAutoplay:',
|
|
371
371
|
autoplay,
|
|
372
372
|
'initPlayStatusRef:',
|
|
373
373
|
initPlayStatusRef.current,
|
|
374
374
|
'isInViewStateRef:',
|
|
375
375
|
isInViewStateRef.current,
|
|
376
376
|
'paused:',
|
|
377
377
|
ref.current.paused,
|
|
378
378
|
)
|
|
379
379
|
if (
|
|
380
380
|
autoplay &&
|
|
381
381
|
mockAutoplay &&
|
|
382
382
|
!initPlayStatusRef.current &&
|
|
383
383
|
isInViewStateRef.current &&
|
|
384
384
|
ref.current.paused
|
|
385
385
|
) {
|
|
386
386
|
console.log('callInitAutoplay playVideo')
|
|
387
387
|
playVideo()
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
const onWeixinJSBridgeReady = (e) => {
|
|
391
391
|
console.log('onWeixinJSBridgeReady:', e.type)
|
|
392
392
|
callInitAutoplay()
|
|
393
393
|
}
|
|
394
394
|
const onTouchstart = (e) => {
|
|
395
395
|
console.log('onTouchstart:', e.type)
|
|
396
396
|
callInitAutoplay()
|
|
397
397
|
}
|
|
398
398
|
const onScroll = (e) => {
|
|
399
399
|
console.log('onScroll:', e.type)
|
|
400
400
|
callInitAutoplay()
|
|
401
401
|
}
|
|
402
402
|
const onPlay = (e) => {
|
|
403
403
|
console.log('onPlay:', e.type)
|
|
404
404
|
if (!initPlayStatusRef.current) {
|
|
405
405
|
const dispose = disposeRef.current
|
|
406
406
|
console.log('onPlay dispose:', dispose)
|
|
407
407
|
dispose && dispose()
|
|
408
408
|
disposeRef.current = null
|
|
409
409
|
}
|
|
410
410
|
initPlayStatusRef.current = true
|
|
411
411
|
}
|
|
412
412
|
document?.addEventListener('WeixinJSBridgeReady', onWeixinJSBridgeReady)
|
|
413
413
|
document?.addEventListener('touchstart', onTouchstart)
|
|
414
414
|
document?.addEventListener('scroll', onScroll)
|
|
415
415
|
ref.current.addEventListener('play', onPlay)
|
|
416
416
|
const dispose = () => {
|
|
417
417
|
console.log('调用dispose')
|
|
418
418
|
document?.removeEventListener(
|
|
419
419
|
'WeixinJSBridgeReady',
|
|
420
420
|
onWeixinJSBridgeReady,
|
|
421
421
|
)
|
|
422
422
|
document?.removeEventListener('touchstart', onTouchstart)
|
|
423
423
|
document?.removeEventListener('scroll', onScroll)
|
|
424
424
|
ref?.current?.removeEventListener('play', onPlay)
|
|
425
425
|
}
|
|
426
426
|
disposeRef.current = dispose
|
|
427
427
|
}
|
|
428
428
|
!autoplay && (manualPauseStateRef.current = true)
|
|
429
429
|
const handleVideoPlayApiCall = () => {
|
|
430
430
|
if (!isH5 || !ref.current) return
|
|
431
431
|
playVideo()
|
|
432
432
|
manualPauseStateRef.current = false
|
|
433
433
|
}
|
|
434
434
|
const handleVideoPauseApiCall = () => {
|
|
435
435
|
if (!isH5 || !ref.current) return
|
|
436
436
|
pauseVideo()
|
|
437
437
|
manualPauseStateRef.current = true
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
const handleVideoSeekApiCall = (position: number) => {
|
|
441
441
|
console.log('video定位至', position)
|
|
442
442
|
if (!isH5 || !ref.current) return
|
|
443
443
|
if (typeof position === 'undefined' || typeof position !== 'number')
|
|
444
444
|
return
|
|
445
445
|
ref.current.currentTime = position
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
if (onVideoApiCall) {
|
|
449
449
|
onVideoApiCall({
|
|
450
450
|
play: handleVideoPlayApiCall,
|
|
451
451
|
pause: handleVideoPauseApiCall,
|
|
452
452
|
seek: handleVideoSeekApiCall,
|
|
453
453
|
})
|
|
454
454
|
}
|
|
455
455
|
return () => {
|
|
456
456
|
const dispose = disposeRef.current
|
|
457
457
|
dispose && dispose()
|
|
458
458
|
disposeRef.current = null
|
|
459
459
|
}
|
|
460
460
|
}, [])
|
|
461
461
|
|
|
462
462
|
const handleMuted = useCallback(() => {
|
|
463
463
|
if (!isH5 || !ref.current) return
|
|
464
464
|
const handleMutedState = ref.current.muted
|
|
465
465
|
if (handleMutedState === true) {
|
|
466
466
|
ref.current.muted = false
|
|
467
467
|
setVideoMutedState(false)
|
|
468
468
|
} else {
|
|
469
469
|
ref.current.muted = true
|
|
470
470
|
setVideoMutedState(true)
|
|
471
471
|
}
|
|
472
472
|
}, [videoMutedState])
|
|
473
473
|
|
|
474
474
|
const handleVideoInViewCallback = useCallback(() => {
|
|
475
475
|
if (!isH5 || !ref.current) return
|
|
476
476
|
isInViewStateRef.current = true
|
|
477
477
|
console.log(
|
|
478
478
|
'进入可视区域,initPlayStatusRef:',
|
|
479
479
|
initPlayStatusRef.current,
|
|
480
480
|
'isInViewStateRef:',
|
|
481
481
|
isInViewStateRef.current,
|
|
482
482
|
)
|
|
483
483
|
if (
|
|
484
484
|
autoplay &&
|
|
485
485
|
mockAutoplay &&
|
|
486
486
|
!initPlayStatusRef.current &&
|
|
487
487
|
ref.current.paused
|
|
488
488
|
) {
|
|
489
489
|
console.log('进入可视区域了 callInitAutoplay playVideo')
|
|
490
490
|
playVideo()
|
|
491
491
|
} else if (!manualPauseStateRef.current && ref.current.paused) {
|
|
492
492
|
playVideo()
|
|
493
493
|
}
|
|
494
494
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
495
495
|
}, [])
|
|
496
496
|
|
|
497
497
|
const handleVideoOutViewCallback = useCallback(() => {
|
|
498
498
|
if (!isH5 || !ref.current) return
|
|
499
499
|
isInViewStateRef.current = false
|
|
500
500
|
console.log(
|
|
501
501
|
'不在可视区域, 视频暂停了, isInViewStateRef:',
|
|
502
502
|
isInViewStateRef.current,
|
|
503
503
|
)
|
|
504
504
|
pauseVideo()
|
|
505
505
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
506
506
|
}, [])
|
|
507
507
|
|
|
508
508
|
const getVideoWidthAndHeightStyle = () => {
|
|
509
509
|
const style = {}
|
|
510
510
|
width && (style['width'] = width)
|
|
511
511
|
height && (style['height'] = height)
|
|
512
512
|
return style
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
const getMuteBtnBackgroundImageStyle = useCallback(() => {
|
|
516
516
|
const isMutedPicSrc = muteBtnPicSrcObj?.IS_MUTED
|
|
517
517
|
const notMutedPicSrc = muteBtnPicSrcObj?.NOT_MUTED
|
|
518
518
|
const finalIsMutedPicSrc =
|
|
519
519
|
typeof isMutedPicSrc !== 'undefined' && isMutedPicSrc !== ''
|
|
520
520
|
? isMutedPicSrc
|
|
521
521
|
: DEFAULT_MUTE_BTN_PIC.IS_MUTED
|
|
522
522
|
const finalNotMutedPicSrc =
|
|
523
523
|
typeof notMutedPicSrc !== 'undefined' && notMutedPicSrc !== ''
|
|
524
524
|
? notMutedPicSrc
|
|
525
525
|
: DEFAULT_MUTE_BTN_PIC.NOT_MUTED
|
|
526
526
|
return {
|
|
527
527
|
backgroundImage: `url(${
|
|
528
528
|
videoMutedState ? finalIsMutedPicSrc : finalNotMutedPicSrc
|
|
529
529
|
})`,
|
|
530
530
|
}
|
|
531
531
|
}, [videoMutedState])
|
|
532
532
|
console.log('autoplay:', autoplay, 'muted:', MUTED)
|
|
533
533
|
console.log('isH5:', isH5, 'isH5AndJingGouMini:', isH5AndJingGouMini)
|
|
534
534
|
return src ? (
|
|
535
535
|
<InOrOutViewObserver
|
|
536
536
|
inViewCallback={handleVideoInViewCallback}
|
|
537
537
|
outViewCallback={handleVideoOutViewCallback}
|
|
538
538
|
threshold={threshold}
|
|
539
539
|
>
|
|
540
540
|
{isH5 ? (
|
|
541
541
|
<View
|
|
542
542
|
className={customVideoStyle['d-video-wrap']}
|
|
543
543
|
style={{ ...style, ...getVideoWidthAndHeightStyle() }}
|
|
544
544
|
>
|
|
545
545
|
<video
|
|
546
546
|
style={{ ...videoStyle }}
|
|
547
547
|
className={customVideoStyle['d-video-play']}
|
|
548
548
|
src={src}
|
|
549
549
|
controls={controls}
|
|
550
550
|
poster={poster ? addHttps(poster) : ''}
|
|
551
551
|
ref={ref}
|
|
552
552
|
loop={loop}
|
|
553
553
|
autoPlay={autoplay}
|
|
554
554
|
muted={MUTED}
|
|
555
555
|
x5-playsinline="true"
|
|
556
556
|
playsInline
|
|
557
557
|
webkit-playsinline="true"
|
|
558
558
|
controlsList={
|
|
559
559
|
isH5AndJdShopView
|
|
560
560
|
? 'nodownload nofullscreen noremoteplayback'
|
|
561
561
|
: ''
|
|
562
562
|
}
|
|
563
563
|
onPlay={onPlayCallback}
|
|
564
564
|
onPause={onPauseCallback}
|
|
565
565
|
/>
|
|
566
566
|
{!controls && showMuteBtn && (
|
|
567
567
|
<View
|
|
568
568
|
className={classNames(
|
|
569
569
|
customVideoStyle['d-video-mute-btn'],
|
|
570
570
|
customVideoStyle[`d-mute-btn-${muteButtonPostion}`],
|
|
571
571
|
`${muteBtnClassName}`,
|
|
572
572
|
)}
|
|
573
573
|
style={{ ...getMuteBtnBackgroundImageStyle(), ...muteBtnStyle }}
|
|
574
574
|
onClick={handleMuted}
|
|
575
575
|
></View>
|
|
576
576
|
)}
|
|
577
577
|
</View>
|
|
578
578
|
) : (
|
|
579
579
|
<Video
|
|
580
580
|
style={{ ...videoStyle }}
|
|
581
581
|
ref={ref}
|
|
582
582
|
className={customVideoStyle['d-video-play']}
|
|
583
583
|
src={src}
|
|
584
584
|
controls={controls}
|
|
585
585
|
poster={poster ? addHttps(poster) : ''}
|
|
586
586
|
loop={loop}
|
|
587
587
|
autoplay={autoplay}
|
|
588
588
|
muted={MUTED}
|
|
589
589
|
showMuteBtn={showMuteBtn}
|
|
590
590
|
showFullscreenBtn={showFullscreenBtn}
|
|
591
591
|
objectFit={objectFit}
|
|
592
592
|
onPlay={onPlayCallback}
|
|
593
593
|
onPause={onPauseCallback}
|
|
594
594
|
/>
|
|
595
595
|
)}
|
|
596
596
|
</InOrOutViewObserver>
|
|
597
597
|
) : null
|
|
598
598
|
},
|
|
599
599
|
const buildType = process.env.BUILD_TYPE
|
|
600
600
|
const mockAutoplay = buildType === BUILD_TYPE.DECORATE ? false : true
|
|
601
601
|
return mockAutoplay
|
|
602
602
|
style: {},
|
|
603
603
|
videoStyle: {},
|
|
604
604
|
className: '',
|
|
605
605
|
src: '',
|
|
606
606
|
width: '100%',
|
|
607
607
|
height: '100%',
|
|
608
608
|
controls: false,
|
|
609
609
|
poster: '',
|
|
610
610
|
autoplay: true,
|
|
611
611
|
mockAutoplay: getDefaultMockAutoplay(),
|
|
612
612
|
loop: true,
|
|
613
613
|
showMuteBtn: true,
|
|
614
614
|
muteButtonPostion: 'topLeft',
|
|
615
615
|
muteBtnPicSrcObj: DEFAULT_MUTE_BTN_PIC,
|
|
616
616
|
muteBtnClassName: '',
|
|
617
617
|
muteBtnStyle: {},
|
|
618
618
|
showFullscreenBtn: false,
|
|
619
619
|
objectFit: 'cover',
|
|
620
620
|
threshold: 0.6,
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
.d-dialog-footer {
|
|
41
41
|
.d-dialog-btn {
|
|
42
42
|
position: relative;
|
|
43
|
+
margin: 0;
|
|
43
44
|
display: block;
|
|
44
45
|
height: 88px;
|
|
45
46
|
line-height: 88px;
|
|
@@ -50,6 +51,8 @@
|
|
|
50
51
|
text-overflow: ellipsis;
|
|
51
52
|
white-space: nowrap;
|
|
52
53
|
box-sizing: border-box;
|
|
54
|
+
background-color: #fff;
|
|
55
|
+
border-radius: 0;
|
|
53
56
|
&:after {
|
|
54
57
|
content: '';
|
|
55
58
|
display: block;
|
|
@@ -62,6 +65,8 @@
|
|
|
62
65
|
-ms-transform: scaleX(0.5);
|
|
63
66
|
transform: scaleY(0.5);
|
|
64
67
|
pointer-events: none;
|
|
68
|
+
border: none;
|
|
69
|
+
border-radius: 0;
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
.d-dialog-ensure-btn {
|
|
@@ -81,8 +86,7 @@
|
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
.d-dialog-cancel-btn {
|
|
84
|
-
|
|
85
|
-
color: #000000;
|
|
89
|
+
color: #000;
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
}
|