@conecli/cone-render 0.8.19 → 0.8.20-beta.0
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/index.jd.ts +1 -1
- package/dist/common/isvStorage/index.h5.ts +1 -0
- package/dist/common/isvStorage/index.ts +1 -0
- package/dist/common/token/const.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -0
- package/dist/common/token/index.ts +1 -0
- package/dist/common/token/token.jd.ts +1 -0
- package/dist/common/token/token.ts +1 -0
- package/dist/common/token/token.wxapp.ts +1 -0
- package/dist/components/base/CommonFloorHead/index.module.scss +1 -1
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CustomVideo/const.ts +1 -0
- package/dist/components/base/CustomVideo/index.module.scss +40 -64
- 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/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +3 -0
- 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/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -0
- package/dist/components/floorItem.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/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/createReportFloorData.ts +1 -1
- package/dist/jumpEventReport/index.h5.ts +1 -1
- package/dist/jumpEventReport/index.weapp.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/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.jdb.ts +1 -0
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/index.ts +1 -1
- package/dist/open/api/jump/business.ts +1 -0
- package/dist/open/api/jump/index.ts +1 -0
- package/dist/open/api/jump/minPath.ts +1 -0
- package/dist/open/api/jump/side.ts +1 -0
- package/dist/open/api/jump/webUrl.ts +1 -0
- package/dist/open/api/jump copy.ts +1 -0
- package/dist/open/api/moduleUtil.ts +1 -1
- package/dist/open/api/request.ts +1 -0
- package/dist/open/api/shopMember.ts +1 -0
- package/dist/open/api/userToken.ts +1 -0
- package/dist/service/bMallConst.ts +1 -0
- package/dist/service/bMallConst.wxapp.ts +1 -0
- package/dist/service/fetchGateway.ts +1 -0
- package/dist/service/fetchJsonp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -0
- package/dist/service/http/colorSign.wxapp.ts +1 -0
- package/dist/service/http/const.ts +1 -0
- package/dist/service/http/http.ts +1 -0
- package/dist/service/http/httpInterceptors.jd.ts +1 -0
- package/dist/service/http/httpInterceptors.ts +1 -0
- package/dist/service/http/index.ts +1 -0
- package/dist/service/requestServer.ts +1 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.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/ready.ts +1 -0
- package/dist/utils/utils.ts +1 -1
- package/package.json +5 -4
- package/dist/components/base/Price/index.module.scss +0 -136
- package/dist/open/api/jump.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
1
|
if (!isH5 || !ref.current) return
|
|
3
2
|
playVideo()
|
|
4
3
|
manualPauseStateRef.current = false
|
|
5
4
|
}
|
|
6
5
|
if (!isH5 || !ref.current) return
|
|
7
6
|
pauseVideo()
|
|
8
7
|
manualPauseStateRef.current = true
|
|
9
8
|
}
|
|
10
9
|
if (!isH5 || !ref.current) return
|
|
11
10
|
}, [])
|
|
11
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
12
12
|
isH5,
|
|
13
13
|
addHttps,
|
|
14
14
|
isH5AndJingGouMini,
|
|
15
15
|
isH5AndJdShopView,
|
|
16
16
|
(props: ComponentInterFace.CustomVideoProps, ref: any) => {
|
|
17
17
|
const {
|
|
18
18
|
style,
|
|
19
19
|
videoStyle,
|
|
20
20
|
src,
|
|
21
21
|
width,
|
|
22
22
|
height,
|
|
23
23
|
controls,
|
|
24
24
|
poster,
|
|
25
25
|
autoplay,
|
|
26
26
|
loop,
|
|
27
27
|
showMuteBtn,
|
|
28
28
|
muteButtonPostion,
|
|
29
29
|
showFullscreenBtn,
|
|
30
30
|
muteBtnPicSrcObj,
|
|
31
31
|
muteBtnClassName,
|
|
32
32
|
muteBtnStyle,
|
|
33
33
|
objectFit,
|
|
34
34
|
mockAutoplay,
|
|
35
35
|
threshold,
|
|
36
36
|
onPlayCallback,
|
|
37
37
|
onPauseCallback,
|
|
38
38
|
onVideoApiCall,
|
|
39
39
|
inViewCallback,
|
|
40
40
|
outViewCallback,
|
|
41
41
|
} = props
|
|
42
42
|
const [videoMutedState, setVideoMutedState] = useState(MUTED)
|
|
43
43
|
const manualPauseStateRef = useRef(false)
|
|
44
44
|
const initPlayStatusRef = useRef(false)
|
|
45
45
|
const isInViewStateRef = useRef(false)
|
|
46
46
|
const disposeRef = useRef<Function | null>()
|
|
47
47
|
ref === null && (ref = useRef<HTMLVideoElement | null>())
|
|
48
48
|
|
|
49
49
|
const playVideo = useCallback(() => {
|
|
50
50
|
if (ref && ref.current) {
|
|
51
51
|
const result = ref.current.play()
|
|
52
52
|
result &&
|
|
53
53
|
result
|
|
54
54
|
.then(() => {
|
|
55
55
|
console.log('播放成功')
|
|
56
56
|
})
|
|
57
57
|
.catch((e) => {
|
|
58
58
|
console.log('playVideo Error:', e.message)
|
|
59
59
|
})
|
|
60
60
|
}
|
|
61
61
|
}, [])
|
|
62
62
|
|
|
63
63
|
const pauseVideo = useCallback(() => {
|
|
64
64
|
if (ref && ref.current) {
|
|
65
65
|
console.log('pauseVideo')
|
|
66
66
|
ref.current.pause()
|
|
67
67
|
}
|
|
68
68
|
}, [])
|
|
69
69
|
|
|
70
70
|
useEffect(() => {
|
|
71
71
|
if (!isH5 || !ref.current) return
|
|
72
72
|
if (autoplay && mockAutoplay) {
|
|
73
73
|
|
|
74
74
|
const callInitAutoplay = () => {
|
|
75
75
|
console.log(
|
|
76
76
|
'callInitAutoplay:',
|
|
77
77
|
autoplay,
|
|
78
78
|
'initPlayStatusRef:',
|
|
79
79
|
initPlayStatusRef.current,
|
|
80
80
|
'isInViewStateRef:',
|
|
81
81
|
isInViewStateRef.current,
|
|
82
82
|
'paused:',
|
|
83
83
|
ref.current.paused,
|
|
84
84
|
)
|
|
85
85
|
if (
|
|
86
86
|
autoplay &&
|
|
87
87
|
mockAutoplay &&
|
|
88
88
|
!initPlayStatusRef.current &&
|
|
89
89
|
isInViewStateRef.current &&
|
|
90
90
|
ref.current.paused
|
|
91
91
|
) {
|
|
92
92
|
console.log('callInitAutoplay playVideo')
|
|
93
93
|
playVideo()
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
const onWeixinJSBridgeReady = (e) => {
|
|
97
97
|
console.log('onWeixinJSBridgeReady:', e.type)
|
|
98
98
|
callInitAutoplay()
|
|
99
99
|
}
|
|
100
100
|
const onTouchstart = (e) => {
|
|
101
101
|
console.log('onTouchstart:', e.type)
|
|
102
102
|
callInitAutoplay()
|
|
103
103
|
}
|
|
104
104
|
const onScroll = (e) => {
|
|
105
105
|
console.log('onScroll:', e.type)
|
|
106
106
|
callInitAutoplay()
|
|
107
107
|
}
|
|
108
108
|
const onPlay = (e) => {
|
|
109
109
|
console.log('onPlay:', e.type)
|
|
110
110
|
if (!initPlayStatusRef.current) {
|
|
111
111
|
const dispose = disposeRef.current
|
|
112
112
|
console.log('onPlay dispose:', dispose)
|
|
113
113
|
dispose && dispose()
|
|
114
114
|
disposeRef.current = null
|
|
115
115
|
}
|
|
116
116
|
initPlayStatusRef.current = true
|
|
117
117
|
}
|
|
118
118
|
document?.addEventListener('WeixinJSBridgeReady', onWeixinJSBridgeReady)
|
|
119
119
|
document?.addEventListener('touchstart', onTouchstart)
|
|
120
120
|
document?.addEventListener('scroll', onScroll)
|
|
121
121
|
ref.current.addEventListener('play', onPlay)
|
|
122
122
|
const dispose = () => {
|
|
123
123
|
console.log('调用dispose')
|
|
124
124
|
document?.removeEventListener(
|
|
125
125
|
'WeixinJSBridgeReady',
|
|
126
126
|
onWeixinJSBridgeReady,
|
|
127
127
|
)
|
|
128
128
|
document?.removeEventListener('touchstart', onTouchstart)
|
|
129
129
|
document?.removeEventListener('scroll', onScroll)
|
|
130
130
|
ref?.current?.removeEventListener('play', onPlay)
|
|
131
131
|
}
|
|
132
132
|
disposeRef.current = dispose
|
|
133
133
|
}
|
|
134
134
|
!autoplay && (manualPauseStateRef.current = true)
|
|
135
135
|
const handleVideoPlayApiCall = () => {
|
|
136
136
|
if (!isH5 || !ref.current) return
|
|
137
137
|
playVideo()
|
|
138
138
|
manualPauseStateRef.current = false
|
|
139
139
|
}
|
|
140
140
|
const handleVideoPauseApiCall = () => {
|
|
141
141
|
if (!isH5 || !ref.current) return
|
|
142
142
|
pauseVideo()
|
|
143
143
|
manualPauseStateRef.current = true
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const handleVideoSeekApiCall = (position: number) => {
|
|
147
147
|
console.log('video定位至', position)
|
|
148
148
|
if (!isH5 || !ref.current) return
|
|
149
149
|
if (typeof position === 'undefined' || typeof position !== 'number')
|
|
150
150
|
return
|
|
151
151
|
ref.current.currentTime = position
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
if (onVideoApiCall) {
|
|
155
155
|
onVideoApiCall({
|
|
156
156
|
play: handleVideoPlayApiCall,
|
|
157
157
|
pause: handleVideoPauseApiCall,
|
|
158
158
|
seek: handleVideoSeekApiCall,
|
|
159
159
|
})
|
|
160
160
|
}
|
|
161
161
|
return () => {
|
|
162
162
|
const dispose = disposeRef.current
|
|
163
163
|
dispose && dispose()
|
|
164
164
|
disposeRef.current = null
|
|
165
165
|
}
|
|
166
166
|
}, [])
|
|
167
167
|
|
|
168
168
|
const handleMuted = useCallback(() => {
|
|
169
169
|
if (!isH5 || !ref.current) return
|
|
170
170
|
const handleMutedState = ref.current.muted
|
|
171
171
|
if (handleMutedState === true) {
|
|
172
172
|
ref.current.muted = false
|
|
173
173
|
setVideoMutedState(false)
|
|
174
174
|
} else {
|
|
175
175
|
ref.current.muted = true
|
|
176
176
|
setVideoMutedState(true)
|
|
177
177
|
}
|
|
178
178
|
}, [videoMutedState])
|
|
179
179
|
|
|
180
180
|
const handleVideoInViewCallback = useCallback(() => {
|
|
181
181
|
if (!isH5 || !ref.current) return
|
|
182
182
|
isInViewStateRef.current = true
|
|
183
183
|
console.log(
|
|
184
184
|
'进入可视区域,initPlayStatusRef:',
|
|
185
185
|
initPlayStatusRef.current,
|
|
186
186
|
'isInViewStateRef:',
|
|
187
187
|
isInViewStateRef.current,
|
|
188
188
|
)
|
|
189
189
|
if (
|
|
190
190
|
autoplay &&
|
|
191
191
|
mockAutoplay &&
|
|
192
192
|
!initPlayStatusRef.current &&
|
|
193
193
|
ref.current.paused
|
|
194
194
|
) {
|
|
195
195
|
console.log('进入可视区域了 callInitAutoplay playVideo')
|
|
196
196
|
playVideo()
|
|
197
197
|
} else if (!manualPauseStateRef.current && ref.current.paused) {
|
|
198
198
|
playVideo()
|
|
199
199
|
}
|
|
200
200
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
201
201
|
}, [])
|
|
202
202
|
|
|
203
203
|
const handleVideoOutViewCallback = useCallback(() => {
|
|
204
204
|
if (!isH5 || !ref.current) return
|
|
205
205
|
isInViewStateRef.current = false
|
|
206
206
|
console.log(
|
|
207
207
|
'不在可视区域, 视频暂停了, isInViewStateRef:',
|
|
208
208
|
isInViewStateRef.current,
|
|
209
209
|
)
|
|
210
210
|
pauseVideo()
|
|
211
211
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
212
212
|
}, [])
|
|
213
213
|
|
|
214
214
|
const getVideoWidthAndHeightStyle = () => {
|
|
215
215
|
const style = {}
|
|
216
216
|
width && (style['width'] = width)
|
|
217
217
|
height && (style['height'] = height)
|
|
218
218
|
return style
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
const getMuteBtnBackgroundImageStyle = useCallback(() => {
|
|
222
222
|
const isMutedPicSrc = muteBtnPicSrcObj?.IS_MUTED
|
|
223
223
|
const notMutedPicSrc = muteBtnPicSrcObj?.NOT_MUTED
|
|
224
224
|
const finalIsMutedPicSrc =
|
|
225
225
|
typeof isMutedPicSrc !== 'undefined' && isMutedPicSrc !== ''
|
|
226
226
|
? isMutedPicSrc
|
|
227
227
|
: DEFAULT_MUTE_BTN_PIC.IS_MUTED
|
|
228
228
|
const finalNotMutedPicSrc =
|
|
229
229
|
typeof notMutedPicSrc !== 'undefined' && notMutedPicSrc !== ''
|
|
230
230
|
? notMutedPicSrc
|
|
231
231
|
: DEFAULT_MUTE_BTN_PIC.NOT_MUTED
|
|
232
232
|
return {
|
|
233
233
|
backgroundImage: `url(${
|
|
234
234
|
videoMutedState ? finalIsMutedPicSrc : finalNotMutedPicSrc
|
|
235
235
|
})`,
|
|
236
236
|
}
|
|
237
237
|
}, [videoMutedState])
|
|
238
238
|
console.log('autoplay:', autoplay, 'muted:', MUTED)
|
|
239
239
|
console.log('isH5:', isH5, 'isH5AndJingGouMini:', isH5AndJingGouMini)
|
|
240
240
|
return src ? (
|
|
241
241
|
<InOrOutViewObserver
|
|
242
242
|
inViewCallback={handleVideoInViewCallback}
|
|
243
243
|
outViewCallback={handleVideoOutViewCallback}
|
|
244
244
|
threshold={threshold}
|
|
245
245
|
>
|
|
246
246
|
{isH5 ? (
|
|
247
247
|
<View
|
|
248
248
|
className={customVideoStyle['d-video-wrap']}
|
|
249
249
|
style={{ ...style, ...getVideoWidthAndHeightStyle() }}
|
|
250
250
|
>
|
|
251
251
|
<video
|
|
252
252
|
style={{ ...videoStyle }}
|
|
253
253
|
className={customVideoStyle['d-video-play']}
|
|
254
254
|
src={src}
|
|
255
255
|
controls={controls}
|
|
256
256
|
poster={poster ? addHttps(poster) : ''}
|
|
257
257
|
ref={ref}
|
|
258
258
|
loop={loop}
|
|
259
259
|
autoPlay={autoplay}
|
|
260
260
|
muted={MUTED}
|
|
261
261
|
x5-playsinline="true"
|
|
262
262
|
playsInline
|
|
263
263
|
webkit-playsinline="true"
|
|
264
264
|
controlsList={
|
|
265
265
|
isH5AndJdShopView
|
|
266
266
|
? 'nodownload nofullscreen noremoteplayback'
|
|
267
267
|
: ''
|
|
268
268
|
}
|
|
269
269
|
onPlay={onPlayCallback}
|
|
270
270
|
onPause={onPauseCallback}
|
|
271
271
|
/>
|
|
272
272
|
{!controls && showMuteBtn && (
|
|
273
273
|
<View
|
|
274
274
|
className={classNames(
|
|
275
275
|
customVideoStyle['d-video-mute-btn'],
|
|
276
276
|
customVideoStyle[`d-mute-btn-${muteButtonPostion}`],
|
|
277
277
|
`${muteBtnClassName}`,
|
|
278
278
|
)}
|
|
279
279
|
style={{ ...getMuteBtnBackgroundImageStyle(), ...muteBtnStyle }}
|
|
280
280
|
onClick={handleMuted}
|
|
281
281
|
></View>
|
|
282
282
|
)}
|
|
283
283
|
</View>
|
|
284
284
|
) : (
|
|
285
285
|
<Video
|
|
286
286
|
style={{ ...videoStyle }}
|
|
287
287
|
ref={ref}
|
|
288
288
|
className={customVideoStyle['d-video-play']}
|
|
289
289
|
src={src}
|
|
290
290
|
controls={controls}
|
|
291
291
|
poster={poster ? addHttps(poster) : ''}
|
|
292
292
|
loop={loop}
|
|
293
293
|
autoplay={autoplay}
|
|
294
294
|
muted={MUTED}
|
|
295
295
|
showMuteBtn={showMuteBtn}
|
|
296
296
|
showFullscreenBtn={showFullscreenBtn}
|
|
297
297
|
objectFit={objectFit}
|
|
298
298
|
onPlay={onPlayCallback}
|
|
299
299
|
onPause={onPauseCallback}
|
|
300
300
|
/>
|
|
301
301
|
)}
|
|
302
302
|
</InOrOutViewObserver>
|
|
303
303
|
) : null
|
|
304
304
|
},
|
|
305
305
|
const buildType = process.env.BUILD_TYPE
|
|
306
306
|
const mockAutoplay = buildType === BUILD_TYPE.DECORATE ? false : true
|
|
307
307
|
return mockAutoplay
|
|
308
308
|
style: {},
|
|
309
309
|
videoStyle: {},
|
|
310
310
|
className: '',
|
|
311
311
|
src: '',
|
|
312
312
|
width: '100%',
|
|
313
313
|
height: '100%',
|
|
314
314
|
controls: false,
|
|
315
315
|
poster: '',
|
|
316
316
|
autoplay: true,
|
|
317
317
|
mockAutoplay: getDefaultMockAutoplay(),
|
|
318
318
|
loop: true,
|
|
319
319
|
showMuteBtn: true,
|
|
320
320
|
muteButtonPostion: 'topLeft',
|
|
321
321
|
muteBtnPicSrcObj: DEFAULT_MUTE_BTN_PIC,
|
|
322
322
|
muteBtnClassName: '',
|
|
323
323
|
muteBtnStyle: {},
|
|
324
324
|
showFullscreenBtn: false,
|
|
325
325
|
objectFit: 'cover',
|
|
326
326
|
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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
2
|
title: '',
|
|
3
3
|
message: null,
|
|
4
4
|
className: '',
|
|
5
5
|
maskCloseable: false,
|
|
6
6
|
show: true,
|
|
7
7
|
hasFooter: true,
|
|
8
8
|
isCustom: false,
|
|
9
9
|
titleNode: null,
|
|
10
10
|
bodyNode: null,
|
|
11
11
|
footerNode: null,
|
|
12
12
|
closeBtnText: '取消',
|
|
13
13
|
closeBtnHideState: false,
|
|
14
14
|
confirmBtnText: '确定',
|
|
15
15
|
confirmBtnHideState: false,
|
|
16
16
|
onBeforeConfirm: null,
|
|
17
17
|
onConfirm: null,
|
|
18
18
|
onClose: null,
|
|
19
19
|
onBackground: null,
|
|
20
20
|
onHide: null,
|
|
21
21
|
onInit: null,
|
|
22
22
|
isFormDialog: false,
|
|
23
23
|
onFormSubmit: null,
|
|
24
24
|
onFormReset: null,
|
|
25
25
|
forbiddenBgScrollState: true,
|
|
26
26
|
const [dialogShowState, setDialogShowState] = useState(false)
|
|
27
27
|
const [dialogConfig, setDialogConfig] =
|
|
28
28
|
useState<ComponentInterFace.DialogConfigProps>({
|
|
29
29
|
type: DialogType.BASE,
|
|
30
30
|
})
|
|
31
31
|
const dialogBackFnRef = useRef<ComponentInterFace.DialogConfigBackFn>({})
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
|
|
34
34
|
Taro.eventCenter.on(TaroEventType.DIALOG, (res) => {
|
|
35
35
|
res.show ? dialogInit(res) : setDialogShowState(false)
|
|
36
36
|
})
|
|
37
37
|
return () => {
|
|
38
38
|
Taro.eventCenter.off(TaroEventType.DIALOG)
|
|
39
39
|
}
|
|
40
40
|
}, [])
|
|
41
41
|
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
if (dialogConfig.forbiddenBgScrollState && taroJdBaseInfo.rootEleNode) {
|
|
44
44
|
!dialogShowState ? taroJdBaseInfo.rootEleNode.classList.remove('over-hidden') : taroJdBaseInfo.rootEleNode.classList.add('over-hidden')
|
|
45
45
|
}
|
|
46
46
|
}, [dialogConfig, dialogShowState])
|
|
47
47
|
const dialogInit = useCallback((opts) => {
|
|
48
48
|
const {
|
|
49
49
|
onBeforeConfirm,
|
|
50
50
|
onConfirm,
|
|
51
51
|
onClose,
|
|
52
52
|
onBackground,
|
|
53
53
|
onHide,
|
|
54
54
|
onInit,
|
|
55
55
|
onFormSubmit,
|
|
56
56
|
onFormReset,
|
|
57
57
|
...otherOpts
|
|
58
58
|
} = opts
|
|
59
59
|
const dialogOpts = Object.assign(
|
|
60
60
|
{},
|
|
61
61
|
{
|
|
62
62
|
...dialogDefaultConfig,
|
|
63
63
|
type: DialogType.BASE,
|
|
64
64
|
},
|
|
65
65
|
otherOpts,
|
|
66
66
|
)
|
|
67
67
|
dialogBackFnRef.current = {
|
|
68
68
|
onInit,
|
|
69
69
|
onBeforeConfirm,
|
|
70
70
|
onConfirm,
|
|
71
71
|
onClose,
|
|
72
72
|
onBackground,
|
|
73
73
|
onHide,
|
|
74
74
|
onFormSubmit,
|
|
75
75
|
onFormReset,
|
|
76
76
|
}
|
|
77
77
|
setDialogConfig(dialogOpts)
|
|
78
78
|
setDialogShowState(true)
|
|
79
79
|
}, [])
|
|
80
80
|
const hideDialog = useCallback(() => {
|
|
81
81
|
setDialogShowState(false)
|
|
82
82
|
}, [])
|
|
83
83
|
const closeDialog = useCallback(() => {
|
|
84
84
|
hideDialog()
|
|
85
85
|
dialogBackFnRef.current.onHide &&
|
|
86
86
|
typeof dialogBackFnRef.current.onHide === 'function' &&
|
|
87
87
|
dialogBackFnRef.current.onHide(dialogConfig)
|
|
88
88
|
}, [dialogConfig])
|
|
89
89
|
|
|
90
90
|
const updateDialogContentFn = (changeDialogConfig) => {
|
|
91
91
|
setDialogConfig({
|
|
92
92
|
...dialogConfig,
|
|
93
93
|
...changeDialogConfig
|
|
94
94
|
})
|
|
95
95
|
}
|
|
96
96
|
useEffect(() => {
|
|
97
97
|
dialogShowState &&
|
|
98
98
|
dialogBackFnRef.current.onInit &&
|
|
99
99
|
typeof dialogBackFnRef.current.onInit === 'function' &&
|
|
100
100
|
dialogBackFnRef.current.onInit(hideDialog, dialogConfig, updateDialogContentFn)
|
|
101
101
|
}, [dialogShowState])
|
|
102
102
|
|
|
103
103
|
const dialogConfirmFn = useCallback(
|
|
104
104
|
(e) => {
|
|
105
105
|
e.stopPropagation()
|
|
106
106
|
if (
|
|
107
107
|
dialogBackFnRef.current.onBeforeConfirm &&
|
|
108
108
|
typeof dialogBackFnRef.current.onBeforeConfirm === 'function'
|
|
109
109
|
) {
|
|
110
110
|
dialogBackFnRef.current.onBeforeConfirm(
|
|
111
111
|
hideDialog,
|
|
112
112
|
dialogConfig,
|
|
113
113
|
)
|
|
114
114
|
} else {
|
|
115
115
|
closeDialog()
|
|
116
116
|
dialogBackFnRef.current.onConfirm &&
|
|
117
117
|
typeof dialogBackFnRef.current.onConfirm === 'function' &&
|
|
118
118
|
dialogBackFnRef.current.onConfirm(dialogConfig)
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
[dialogConfig],
|
|
122
122
|
)
|
|
123
123
|
const dialogCloseFn = useCallback(
|
|
124
124
|
(e) => {
|
|
125
125
|
e.stopPropagation()
|
|
126
126
|
closeDialog()
|
|
127
127
|
dialogBackFnRef.current.onClose &&
|
|
128
128
|
typeof dialogBackFnRef.current.onClose === 'function' &&
|
|
129
129
|
dialogBackFnRef.current.onClose(dialogConfig)
|
|
130
130
|
},
|
|
131
131
|
[dialogConfig],
|
|
132
132
|
)
|
|
133
133
|
const dialogBackgroundFn = useCallback(() => {
|
|
134
134
|
if (dialogConfig.maskCloseable) {
|
|
135
135
|
closeDialog()
|
|
136
136
|
}
|
|
137
137
|
if (
|
|
138
138
|
dialogBackFnRef.current.onBackground &&
|
|
139
139
|
typeof dialogBackFnRef.current.onBackground === 'function'
|
|
140
140
|
) {
|
|
141
141
|
dialogBackFnRef.current.onBackground()
|
|
142
142
|
}
|
|
143
143
|
}, [dialogConfig])
|
|
144
144
|
const dialogFormSubmit = useCallback((e) => {
|
|
145
145
|
if (
|
|
146
146
|
dialogBackFnRef.current.onFormSubmit &&
|
|
147
147
|
typeof dialogBackFnRef.current.onFormSubmit === 'function'
|
|
148
148
|
) {
|
|
149
149
|
dialogBackFnRef.current.onFormSubmit(e,hideDialog, dialogConfig)
|
|
150
150
|
}
|
|
151
151
|
}, [dialogConfig])
|
|
152
152
|
const dialogFormReset = useCallback((e) => {
|
|
153
153
|
if (
|
|
154
154
|
dialogBackFnRef.current.onFormReset &&
|
|
155
155
|
typeof dialogBackFnRef.current.onFormReset === 'function'
|
|
156
156
|
) {
|
|
157
157
|
dialogBackFnRef.current.onFormReset(e,hideDialog, dialogConfig)
|
|
158
158
|
}
|
|
159
159
|
}, [dialogConfig])
|
|
160
160
|
const renderCustomViewCompontent = (children) => {
|
|
161
161
|
return dialogConfig.isFormDialog ?
|
|
162
162
|
<Form className={classNames(dialogStyle['d-form-dialog'])} onSubmit={dialogFormSubmit}
|
|
163
163
|
onReset={dialogFormReset}>{children}</Form> : <>{children}</>
|
|
164
164
|
}
|
|
165
165
|
return dialogShowState ? renderCustomViewCompontent(
|
|
166
166
|
<>
|
|
167
167
|
<View
|
|
168
168
|
className={dialogStyle['d-dialog-layout']}
|
|
169
169
|
onClick={dialogBackgroundFn}
|
|
170
170
|
>
|
|
171
171
|
<View
|
|
172
172
|
className={classNames(
|
|
173
173
|
dialogStyle['d-dialog-wrap'],
|
|
174
174
|
dialogStyle[`d-dialog-type-${dialogConfig.type}`],
|
|
175
175
|
'flexible-center-box',
|
|
176
176
|
dialogConfig.className,
|
|
177
177
|
)}
|
|
178
178
|
>
|
|
179
179
|
{dialogConfig.isCustom ? (
|
|
180
180
|
dialogConfig.bodyNode ? (
|
|
181
181
|
dialogConfig.bodyNode
|
|
182
182
|
) : null
|
|
183
183
|
) : (
|
|
184
184
|
<View
|
|
185
185
|
className={classNames(
|
|
186
186
|
dialogStyle['d-dialog-content'],
|
|
187
187
|
'd-dialog-content',
|
|
188
188
|
)}
|
|
189
189
|
onClick={(e) => e.stopPropagation()}
|
|
190
190
|
>
|
|
191
191
|
{dialogConfig.title && dialogConfig.title != '' && (
|
|
192
192
|
<View
|
|
193
193
|
className={classNames(
|
|
194
194
|
dialogStyle['d-dialog-header'],
|
|
195
195
|
'd-dialog-header',
|
|
196
196
|
)}
|
|
197
197
|
>
|
|
198
198
|
{dialogConfig.title}
|
|
199
199
|
</View>
|
|
200
200
|
)}
|
|
201
201
|
{dialogConfig.message && (
|
|
202
202
|
<View
|
|
203
203
|
className={classNames(
|
|
204
204
|
dialogStyle['d-dialog-body'],
|
|
205
205
|
'd-dialog-body',
|
|
206
206
|
)}
|
|
207
207
|
dangerouslySetInnerHTML={{
|
|
208
208
|
__html: dialogConfig.message,
|
|
209
209
|
}}
|
|
210
210
|
/>
|
|
211
211
|
)}
|
|
212
212
|
{dialogConfig.bodyNode && (
|
|
213
213
|
<View
|
|
214
214
|
className={classNames(
|
|
215
215
|
dialogStyle['d-dialog-body'],
|
|
216
216
|
'd-dialog-body',
|
|
217
217
|
)}
|
|
218
218
|
>
|
|
219
219
|
{dialogConfig.bodyNode
|
|
220
220
|
? dialogConfig.bodyNode
|
|
221
221
|
: null}
|
|
222
222
|
</View>
|
|
223
223
|
)}
|
|
224
224
|
{dialogConfig.footerNode ? (
|
|
225
225
|
dialogConfig.footerNode
|
|
226
226
|
) : dialogConfig.hasFooter ? (
|
|
227
227
|
<View
|
|
228
228
|
className={classNames(
|
|
229
229
|
dialogStyle['d-dialog-footer'],
|
|
230
230
|
'd-dialog-footer',
|
|
231
231
|
'flexible-box',
|
|
232
232
|
)}
|
|
233
233
|
>
|
|
234
234
|
{!dialogConfig.closeBtnHideState && (
|
|
235
235
|
<Button
|
|
236
236
|
className={classNames(
|
|
237
237
|
dialogStyle['d-dialog-btn'],
|
|
238
238
|
dialogStyle[
|
|
239
239
|
'd-dialog-cancel-btn'
|
|
240
240
|
],
|
|
241
241
|
'd-dialog-cancel-btn',
|
|
242
242
|
'adaptive-box-flex',
|
|
243
243
|
)}
|
|
244
244
|
form-type={dialogConfig.isFormDialog ? 'reset' : ''}
|
|
245
245
|
onClick={dialogCloseFn}
|
|
246
246
|
>
|
|
247
247
|
{dialogConfig.closeBtnText}
|
|
248
248
|
</Button>
|
|
249
249
|
)}
|
|
250
250
|
{!dialogConfig.confirmBtnHideState && (
|
|
251
251
|
<Button
|
|
252
252
|
className={classNames(
|
|
253
253
|
dialogStyle['d-dialog-btn'],
|
|
254
254
|
dialogStyle[
|
|
255
255
|
'd-dialog-ensure-btn'
|
|
256
256
|
],
|
|
257
257
|
'd-dialog-ensure-btn',
|
|
258
258
|
'adaptive-box-flex',
|
|
259
259
|
)}
|
|
260
260
|
onClick={dialogConfirmFn}
|
|
261
261
|
form-type={dialogConfig.isFormDialog ? 'submit' : ''}
|
|
262
262
|
>
|
|
263
263
|
{dialogConfig.confirmBtnText}
|
|
264
264
|
</Button>
|
|
265
265
|
)}
|
|
266
266
|
</View>
|
|
267
267
|
) : null}
|
|
268
268
|
</View>
|
|
269
269
|
)
|
|
270
270
|
}
|
|
271
271
|
</View>
|
|
272
272
|
</View>
|
|
273
273
|
</>,
|
|
274
274
|
) : null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
const inViewCallback = () => {
|
|
3
2
|
console.log('埋点收到进入可视区域的回到啦!', reportData)
|
|
4
3
|
addReportData(reportData)
|
|
5
4
|
}
|
|
6
5
|
exposureStyle.root,
|
|
7
6
|
className,
|
|
8
7
|
)} height={'100%'} inViewCallback={inViewCallback}></InViewRender>
|
|
8
|
+
import Taro from '@tarojs/taro'
|
|
9
9
|
const inViewCallback = () => {
|
|
10
10
|
console.log('埋点收到进入可视区域的回到啦!', reportData)
|
|
11
11
|
addReportData(reportData)
|
|
12
12
|
}
|
|
13
13
|
exposureStyle.root,
|
|
14
14
|
className,
|
|
15
15
|
)} height={'100%'} inViewCallback={inViewCallback}></InViewRender>
|