@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 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
|
TaroEventType,
|
|
3
2
|
WEBVIEW_STATE,
|
|
4
3
|
M_H5_ROOT_ELE_NODE,
|
|
5
4
|
props: ComponentInterFace.InOrOutViewObserverProps,
|
|
6
5
|
const { children, inViewCallback, outViewCallback, threshold = 0 } = props
|
|
7
6
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
8
7
|
const componentObserverRef = useRef<HTMLElement | null>(null)
|
|
9
8
|
const componentShowStateRef = useRef(false)
|
|
10
9
|
if (isH5AndJdShopView) {
|
|
11
10
|
useEffect(() => {
|
|
12
11
|
const latestRes =
|
|
13
12
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
14
13
|
dealPageScrollInfo(latestRes)
|
|
15
14
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
16
15
|
dealPageScrollInfo(res)
|
|
17
16
|
})
|
|
18
17
|
Taro.eventCenter.on(
|
|
19
18
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
20
19
|
(state) => {
|
|
21
20
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
22
21
|
},
|
|
23
22
|
)
|
|
24
23
|
return function cleanup() {
|
|
25
24
|
Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
|
|
26
25
|
dealPageScrollInfo(res)
|
|
27
26
|
})
|
|
28
27
|
Taro.eventCenter.off(
|
|
29
28
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
30
29
|
(state) => {
|
|
31
30
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
32
31
|
},
|
|
33
32
|
)
|
|
34
33
|
}
|
|
35
34
|
}, [])
|
|
36
35
|
useEffect(() => {
|
|
37
36
|
if (componentShowState) {
|
|
38
37
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
39
38
|
console.log('app=>in可视区域')
|
|
40
39
|
} else {
|
|
41
40
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
42
41
|
console.log('app=>out可视区域')
|
|
43
42
|
}
|
|
44
43
|
}, [componentShowState])
|
|
45
44
|
|
|
46
45
|
const handleInOrOutView = (type: boolean) => {
|
|
47
46
|
componentShowStateRef.current = type
|
|
48
47
|
setComponentShowState(type)
|
|
49
48
|
console.log('handleInOrOutView', type)
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
const dealPageScrollInfo = (res) => {
|
|
53
52
|
console.log('dealPageScrollInfo===', res)
|
|
54
53
|
|
|
55
54
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
56
55
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
57
56
|
console.log(
|
|
58
57
|
'处理后dealPageScrollInfo===displayHeight=offSetY',
|
|
59
58
|
displayHeight,
|
|
60
59
|
offSetY,
|
|
61
60
|
)
|
|
62
61
|
if (componentObserverRef.current) {
|
|
63
62
|
const eleClientRect =
|
|
64
63
|
componentObserverRef.current.getBoundingClientRect()
|
|
65
64
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
66
65
|
const eleHeight = Math.ceil(eleClientRect.height)
|
|
67
66
|
console.log(
|
|
68
67
|
'==========================eleOffsetTop, eleHeight',
|
|
69
68
|
eleOffsetTop,
|
|
70
69
|
eleHeight,
|
|
71
70
|
)
|
|
72
71
|
if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
|
|
73
72
|
const isOutView =
|
|
74
73
|
offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
|
|
75
74
|
displayHeight - (eleOffsetTop - offSetY) <
|
|
76
75
|
Math.ceil(eleHeight * threshold)
|
|
77
76
|
|
|
78
77
|
console.log(
|
|
79
78
|
'比较isOutView',
|
|
80
79
|
isOutView,
|
|
81
80
|
offSetY,
|
|
82
81
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
83
82
|
displayHeight - (eleOffsetTop - offSetY),
|
|
84
83
|
Math.ceil(eleHeight * threshold),
|
|
85
84
|
)
|
|
86
85
|
handleInOrOutView(!isOutView)
|
|
87
86
|
} else {
|
|
88
87
|
const isInView =
|
|
89
88
|
offSetY >
|
|
90
89
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
|
|
91
90
|
offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
|
|
92
91
|
console.log(
|
|
93
92
|
'比较isInView',
|
|
94
93
|
isInView,
|
|
95
94
|
offSetY,
|
|
96
95
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
|
|
97
96
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
98
97
|
)
|
|
99
98
|
handleInOrOutView(isInView)
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
return <View ref={componentObserverRef}>{children}</View>
|
|
104
103
|
} else {
|
|
105
104
|
const rootDom = document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
|
|
106
105
|
const { ref, inView } = useInView({
|
|
107
106
|
threshold,
|
|
108
107
|
triggerOnce: false,
|
|
109
108
|
root: rootDom || null,
|
|
110
109
|
rootMargin: `0px 0px 0px 0px`,
|
|
111
110
|
})
|
|
112
111
|
useEffect(() => {
|
|
113
112
|
if (inView) {
|
|
114
113
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
115
114
|
console.log('其他h5=>in可视区域')
|
|
116
115
|
} else {
|
|
117
116
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
118
117
|
console.log('其他h5=>out可视区域')
|
|
119
118
|
}
|
|
120
119
|
}, [inView])
|
|
121
120
|
return <View ref={ref}>{children}</View>
|
|
122
121
|
}
|
|
123
122
|
children: null,
|
|
124
123
|
className: '',
|
|
125
124
|
inViewCallback: null,
|
|
126
125
|
outViewCallback: null,
|
|
127
126
|
threshold: 0,
|
|
127
|
+
import Taro from '@tarojs/taro'
|
|
128
128
|
TaroEventType,
|
|
129
129
|
WEBVIEW_STATE,
|
|
130
130
|
M_H5_ROOT_ELE_NODE,
|
|
131
131
|
latestFromNativeMsgStorage,
|
|
132
132
|
getNativePageScrollRes,
|
|
133
133
|
props: ComponentInterFace.InOrOutViewObserverProps,
|
|
134
134
|
const {
|
|
135
135
|
children,
|
|
136
136
|
style,
|
|
137
137
|
inViewCallback,
|
|
138
138
|
outViewCallback,
|
|
139
139
|
threshold = 0,
|
|
140
140
|
} = props
|
|
141
141
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
142
142
|
const componentObserverRef = useRef<HTMLElement | null>(null)
|
|
143
143
|
const componentShowStateRef = useRef(false)
|
|
144
144
|
if (isH5AndJdShopView) {
|
|
145
145
|
useEffect(() => {
|
|
146
146
|
const latestRes =
|
|
147
147
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
148
148
|
dealPageScrollInfo(latestRes)
|
|
149
149
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
150
150
|
dealPageScrollInfo(res)
|
|
151
151
|
})
|
|
152
152
|
Taro.eventCenter.on(
|
|
153
153
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
154
154
|
(state) => {
|
|
155
155
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
156
156
|
},
|
|
157
157
|
)
|
|
158
158
|
return function cleanup() {
|
|
159
159
|
Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
|
|
160
160
|
dealPageScrollInfo(res)
|
|
161
161
|
})
|
|
162
162
|
Taro.eventCenter.off(
|
|
163
163
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
164
164
|
(state) => {
|
|
165
165
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
166
166
|
},
|
|
167
167
|
)
|
|
168
168
|
}
|
|
169
169
|
}, [])
|
|
170
170
|
useEffect(() => {
|
|
171
171
|
if (componentShowState) {
|
|
172
172
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
173
173
|
console.log('app=>in可视区域')
|
|
174
174
|
} else {
|
|
175
175
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
176
176
|
console.log('app=>out可视区域')
|
|
177
177
|
}
|
|
178
178
|
}, [componentShowState])
|
|
179
179
|
|
|
180
180
|
const handleInOrOutView = (type: boolean) => {
|
|
181
181
|
componentShowStateRef.current = type
|
|
182
182
|
setComponentShowState(type)
|
|
183
183
|
console.log('handleInOrOutView', type)
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const dealPageScrollInfo = (res) => {
|
|
187
187
|
console.log('dealPageScrollInfo===', res)
|
|
188
188
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
189
189
|
if (
|
|
190
190
|
typeof displayHeight === 'undefined' ||
|
|
191
191
|
typeof offSetY === 'undefined'
|
|
192
192
|
)
|
|
193
193
|
return
|
|
194
194
|
console.log(
|
|
195
195
|
'处理后dealPageScrollInfo===displayHeight=offSetY',
|
|
196
196
|
displayHeight,
|
|
197
197
|
offSetY,
|
|
198
198
|
)
|
|
199
199
|
if (componentObserverRef.current) {
|
|
200
200
|
const eleClientRect =
|
|
201
201
|
componentObserverRef.current.getBoundingClientRect()
|
|
202
202
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
203
203
|
const eleHeight = Math.ceil(eleClientRect.height)
|
|
204
204
|
console.log(
|
|
205
205
|
'==========================eleOffsetTop, eleHeight',
|
|
206
206
|
eleOffsetTop,
|
|
207
207
|
eleHeight,
|
|
208
208
|
)
|
|
209
209
|
if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
|
|
210
210
|
const isOutView =
|
|
211
211
|
offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
|
|
212
212
|
displayHeight - (eleOffsetTop - offSetY) <
|
|
213
213
|
Math.ceil(eleHeight * threshold)
|
|
214
214
|
console.log(
|
|
215
215
|
'比较isOutView',
|
|
216
216
|
isOutView,
|
|
217
217
|
offSetY,
|
|
218
218
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
219
219
|
displayHeight - (eleOffsetTop - offSetY),
|
|
220
220
|
Math.ceil(eleHeight * threshold),
|
|
221
221
|
)
|
|
222
222
|
handleInOrOutView(!isOutView)
|
|
223
223
|
} else {
|
|
224
224
|
const isInView =
|
|
225
225
|
offSetY >
|
|
226
226
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
|
|
227
227
|
offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
|
|
228
228
|
console.log(
|
|
229
229
|
'比较isInView',
|
|
230
230
|
isInView,
|
|
231
231
|
offSetY,
|
|
232
232
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
|
|
233
233
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
234
234
|
)
|
|
235
235
|
handleInOrOutView(isInView)
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
return (
|
|
240
240
|
<View ref={componentObserverRef} style={style}>
|
|
241
241
|
{children}
|
|
242
242
|
</View>
|
|
243
243
|
)
|
|
244
244
|
} else {
|
|
245
245
|
const rootDom = document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
|
|
246
246
|
const { ref, inView } = useInView({
|
|
247
247
|
threshold,
|
|
248
248
|
triggerOnce: false,
|
|
249
249
|
root: rootDom || null,
|
|
250
250
|
rootMargin: `0px 0px 0px 0px`,
|
|
251
251
|
})
|
|
252
252
|
useEffect(() => {
|
|
253
253
|
if (inView) {
|
|
254
254
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
255
255
|
console.log('其他h5=>in可视区域')
|
|
256
256
|
} else {
|
|
257
257
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
258
258
|
console.log('其他h5=>out可视区域')
|
|
259
259
|
}
|
|
260
260
|
}, [inView])
|
|
261
261
|
return (
|
|
262
262
|
<View ref={ref} style={style}>
|
|
263
263
|
{children}
|
|
264
264
|
</View>
|
|
265
265
|
)
|
|
266
266
|
}
|
|
267
267
|
children: null,
|
|
268
268
|
style: {},
|
|
269
269
|
className: '',
|
|
270
270
|
inViewCallback: null,
|
|
271
271
|
outViewCallback: null,
|
|
272
272
|
threshold: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { Button, View } from '@tarojs/components'
|
|
2
1
|
NetWorkErrorSubTip,
|
|
3
2
|
subMessage,
|
|
4
3
|
backgroundColorWhite,
|
|
5
4
|
const useErrorTip = message != '' ? message : NetWorkErrorTip[netWorkDataType]
|
|
6
5
|
const useErrorSubTip = subMessage? subMessage: NetWorkErrorSubTip[netWorkDataType]
|
|
7
6
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
8
7
|
const maxHeight = latestRes.displayHeight || 546
|
|
9
8
|
style={{maxHeight}}
|
|
10
9
|
{useErrorSubTip? <View className={netWorkErrorStyle['d-error-sub-tip']}>{useErrorSubTip}</View>: null}
|
|
11
10
|
<Button
|
|
12
11
|
onClick={refershInitData}
|
|
13
12
|
className={classNames(
|
|
14
13
|
netWorkErrorStyle['d-opt-btn'],
|
|
15
14
|
'd-button-no-border',
|
|
16
15
|
)}
|
|
17
16
|
plain
|
|
18
17
|
size="mini"
|
|
19
18
|
>
|
|
20
19
|
重新加载
|
|
21
20
|
</Button>
|
|
22
21
|
)}
|
|
23
22
|
subMessage: '',
|
|
23
|
+
import { Button, View } from '@tarojs/components'
|
|
24
24
|
NetWorkErrorSubTip,
|
|
25
25
|
subMessage,
|
|
26
26
|
backgroundColorWhite,
|
|
27
27
|
const useErrorTip = message != '' ? message : NetWorkErrorTip[netWorkDataType]
|
|
28
28
|
const useErrorSubTip = subMessage? subMessage: NetWorkErrorSubTip[netWorkDataType]
|
|
29
29
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
30
30
|
const maxHeight = latestRes.displayHeight || 546
|
|
31
31
|
style={{maxHeight: isMemberPage ? '100vh' : maxHeight}}
|
|
32
32
|
{useErrorSubTip? <View className={netWorkErrorStyle['d-error-sub-tip']}>{useErrorSubTip}</View>: null}
|
|
33
33
|
<Button
|
|
34
34
|
onClick={refershInitData}
|
|
35
35
|
className={classNames(
|
|
36
36
|
netWorkErrorStyle['d-opt-btn'],
|
|
37
37
|
'd-button-no-border',
|
|
38
38
|
)}
|
|
39
39
|
plain
|
|
40
40
|
size="mini"
|
|
41
41
|
>
|
|
42
42
|
重新加载
|
|
43
43
|
</Button>
|
|
44
44
|
)}
|
|
45
45
|
subMessage: '',
|
|
File without changes
|