@conecli/cone-render 0.8.42 → 0.8.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/const.ts +1 -1
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +3 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/remoteFloorItem.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/modules/ContainerFloorList/index.h5.module.scss +1 -0
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/open/api/request.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/sass/app.h5.scss +5 -0
- 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/sgmCodeUtils.ts +1 -1
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
const floorLoadWay = floorData?.floorExtInfo?.floorLoadWay
|
|
3
2
|
const isRemoteLoadFloor = floorLoadWay === 2
|
|
4
3
|
msg: `店铺h5楼层隐藏不显示。原因:模块js执行异常,楼层过滤。`,
|
|
5
4
|
floorIdx: floorData?.floorIdx,
|
|
6
5
|
moduleDesignerType: floorData?.floorExtInfo?.moduleDesignerType,
|
|
7
6
|
floorLoadWay,
|
|
8
7
|
floorKind: floorData?.floorExtInfo?.floorKind,
|
|
9
8
|
}
|
|
10
9
|
code: getSgmCustomCode(isRemoteLoadFloor ? SgmCustomCode.REMOTEMODULE_JS : SgmCustomCode.SYSTEMMODULE_JS),
|
|
11
10
|
msg: opt,
|
|
12
11
|
})
|
|
13
12
|
if(this.props.customErrorIsvFloorModule){
|
|
14
13
|
return this.props.customErrorIsvFloorModule
|
|
15
14
|
}
|
|
15
|
+
import React from 'react'
|
|
16
16
|
getBundleUrl,
|
|
17
17
|
formatPackResult,
|
|
18
18
|
getTaroVersion
|
|
19
19
|
const floorLoadWay = floorData?.floorExtInfo?.floorLoadWay
|
|
20
20
|
const floorKind = floorData?.floorExtInfo?.floorKind
|
|
21
21
|
const isRemoteLoadFloor = floorLoadWay === 2
|
|
22
22
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
23
23
|
const modularPackResultObj = formatPackResult(modularPackResult)
|
|
24
24
|
const bundleUrl = getBundleUrl(modularPackResultObj)
|
|
25
25
|
const taroVersion = getTaroVersion(modularPackResultObj)
|
|
26
26
|
msg: `店铺h5楼层隐藏不显示。原因:模块js执行异常,楼层过滤。`,
|
|
27
27
|
floorIdx: floorData?.floorIdx,
|
|
28
28
|
moduleDesignerType: floorData?.floorExtInfo?.moduleDesignerType,
|
|
29
29
|
floorLoadWay,
|
|
30
30
|
floorKind,
|
|
31
31
|
modularPackResult: {
|
|
32
32
|
bundleUrl,
|
|
33
33
|
taroVersion
|
|
34
34
|
},
|
|
35
35
|
}
|
|
36
36
|
const sgmCode = isRemoteLoadFloor ? (floorKind === FLOOR_KIND.PDC_SYSTEM_MODULE ? SgmCustomCode.SYSTEMPDCMODULE_JS : SgmCustomCode.REMOTEMODULE_JS) : SgmCustomCode.SYSTEMMODULE_JS
|
|
37
37
|
code: getSgmCustomCode(handleSgmCodeTaroVersion(sgmCode)),
|
|
38
38
|
msg: opt,
|
|
39
39
|
})
|
|
40
40
|
if(this.props.customErrorIsvFloorModule){
|
|
41
41
|
return this.props.customErrorIsvFloorModule
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro, { useRouter } from '@tarojs/taro'
|
|
2
1
|
SECTION_HOME_TAB_TYPE,
|
|
3
2
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
4
3
|
TaroEventType,
|
|
5
4
|
const {
|
|
6
5
|
children,
|
|
7
6
|
containerId,
|
|
8
7
|
type,
|
|
9
8
|
placeholder,
|
|
10
9
|
height,
|
|
11
10
|
floorData = {},
|
|
12
11
|
sectionType,
|
|
13
12
|
lazyNodeClassName,
|
|
14
13
|
} = props
|
|
15
14
|
const getRouterInfo = useRouter()
|
|
16
15
|
const getQueryData = getRouterInfo?.params || {}
|
|
17
16
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
18
17
|
const [componentRenderShowState, setComponentRenderShowState] =
|
|
19
18
|
useState(false)
|
|
20
19
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
21
20
|
const componentShowStateRef = useRef(false)
|
|
22
21
|
const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
|
|
23
22
|
const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector('#J_shopHomeRoot')
|
|
24
23
|
const { ref, inView } = useInView({
|
|
25
24
|
threshold: 0,
|
|
26
25
|
triggerOnce: true,
|
|
27
26
|
root: rootDom,
|
|
28
27
|
rootMargin: `0px 0px ${window.innerHeight}px 0px`,
|
|
29
28
|
})
|
|
30
29
|
useEffect(() => {
|
|
31
30
|
if(needShowHighVersion || !isH5AndJdShopView) return
|
|
32
31
|
if (type === LazyType.FLOOR) {
|
|
33
32
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
34
33
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes,false)
|
|
35
34
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
36
35
|
!componentShowStateRef.current && dealPageScrollInfo(res,true)
|
|
37
36
|
})
|
|
38
37
|
}
|
|
39
38
|
}, [])
|
|
40
39
|
useEffect(() => {
|
|
41
40
|
if((!needShowHighVersion && componentShowState === true) ||
|
|
42
41
|
(needShowHighVersion && inView && isH5AndJdShopView)
|
|
43
42
|
) {
|
|
44
43
|
console.log('>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!')
|
|
45
44
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
46
45
|
const modularPackResultObj = typeof modularPackResult === 'string' ? JSON.parse(modularPackResult) : modularPackResult
|
|
47
46
|
if (modularPackResultObj && modularPackResultObj.bundleUrl) {
|
|
48
47
|
const { bundleUrl } = modularPackResultObj
|
|
49
48
|
nativePageRegisterMessage(
|
|
50
49
|
Message_Type.NATIVE_INJECT_JS_FILE,
|
|
51
50
|
{
|
|
52
51
|
data: {
|
|
53
52
|
"bundleUrl": [bundleUrl]
|
|
54
53
|
},
|
|
55
54
|
},
|
|
56
55
|
)
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}, [componentShowState,inView])
|
|
60
59
|
|
|
61
60
|
const dealPageScrollInfo = (res,pageScrollTrigger) => {
|
|
62
61
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
63
62
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') {
|
|
64
63
|
const shopId = floorData?.floorExtInfo?.shopId
|
|
65
64
|
if(!lazyLayoutLoadErrorShopId[`${shopId}`] && pageScrollTrigger) {
|
|
66
65
|
const opt = {
|
|
67
66
|
msg: `店铺楼层懒加载失败。楼层顺序-floorIdx: ${floorData?.floorIdx}。`,
|
|
68
67
|
uid: floorData?.uid,
|
|
69
68
|
floorIdx: floorData?.floorIdx,
|
|
70
69
|
shopId: shopId,
|
|
71
70
|
moduleId: floorData?.moduleId,
|
|
72
71
|
moduleName: floorData?.moduleName,
|
|
73
72
|
middleTemplateId: floorData?.middleTemplateId,
|
|
74
73
|
modularPackResult: typeof floorData?.floorExtInfo?.modularPackResult == 'string' ? JSON.parse(floorData?.floorExtInfo?.modularPackResult) : floorData?.floorExtInfo?.modularPackResult,
|
|
75
74
|
}
|
|
76
75
|
sgmCustomReport({
|
|
77
76
|
code: getSgmCustomCode(SgmCustomCode.FLOORLAZYLOAD_DATA),
|
|
78
77
|
msg: opt,
|
|
79
78
|
})
|
|
80
79
|
lazyLayoutLoadErrorShopId[`${shopId}`] = true
|
|
81
80
|
}
|
|
82
81
|
return
|
|
83
82
|
}
|
|
84
83
|
if (componentLazyRef.current) {
|
|
85
84
|
const eleClientRect =
|
|
86
85
|
componentLazyRef.current.getBoundingClientRect()
|
|
87
86
|
const getContainerHeightOffSetY = displayHeight + offSetY
|
|
88
87
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
89
88
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
90
89
|
const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight
|
|
91
90
|
if (!componentShowStateRef.current) {
|
|
92
91
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
93
92
|
componentShowStateRef.current = true
|
|
94
93
|
setComponentShowState(true)
|
|
95
94
|
Taro.nextTick(() => {
|
|
96
95
|
setComponentRenderShowState(true)
|
|
97
96
|
})
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
return isH5AndJdShopView && !needShowHighVersion ? (
|
|
103
102
|
<div
|
|
104
103
|
id={`${containerId}_lazy`}
|
|
105
104
|
ref={componentLazyRef}
|
|
106
105
|
className={classNames(
|
|
107
106
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
108
107
|
'd-app-floor-lazy-load',
|
|
109
108
|
)}
|
|
110
109
|
style={{
|
|
111
110
|
minHeight: `${
|
|
112
111
|
componentRenderShowState ? 'auto' : height + 'px'
|
|
113
112
|
}`,
|
|
114
113
|
backgroundColor: componentRenderShowState
|
|
115
114
|
? 'transparent'
|
|
116
115
|
: '#ffffff',
|
|
117
116
|
}}
|
|
118
117
|
>
|
|
119
118
|
{componentShowState ? children : placeholder}
|
|
120
119
|
</div>
|
|
121
120
|
) : (
|
|
122
121
|
<div
|
|
123
122
|
id={`${containerId}_lazy`}
|
|
124
123
|
className={classNames(
|
|
125
124
|
lazyLayoutLoadStyle['d-mobile-floor-lazy-layout-load'],
|
|
126
125
|
'd-mobile-floor-lazy-load',
|
|
127
126
|
lazyNodeClassName,
|
|
128
127
|
)}
|
|
129
128
|
ref={ref}
|
|
130
129
|
style={{
|
|
131
130
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
132
131
|
backgroundColor: inView ? 'transparent' : '#ffffff',
|
|
133
132
|
}}
|
|
134
133
|
>
|
|
135
134
|
{}
|
|
136
135
|
{inView ? children : placeholder}
|
|
137
136
|
</div>
|
|
138
137
|
)
|
|
139
138
|
sectionType:
|
|
140
139
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
|
|
141
140
|
type: LazyType.FLOOR,
|
|
142
141
|
children: null,
|
|
143
142
|
placeholder: null,
|
|
144
143
|
height: 200,
|
|
145
144
|
className: '',
|
|
146
145
|
lazyNodeClassName: '',
|
|
146
|
+
import Taro, { useRouter } from '@tarojs/taro'
|
|
147
147
|
SECTION_HOME_TAB_TYPE,
|
|
148
148
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
149
149
|
TaroEventType,
|
|
150
150
|
const {
|
|
151
151
|
children,
|
|
152
152
|
containerId,
|
|
153
153
|
type,
|
|
154
154
|
placeholder,
|
|
155
155
|
height,
|
|
156
156
|
floorData = {},
|
|
157
157
|
sectionType,
|
|
158
158
|
lazyNodeClassName,
|
|
159
159
|
} = props
|
|
160
160
|
const getRouterInfo = useRouter()
|
|
161
161
|
const getQueryData = getRouterInfo?.params || {}
|
|
162
162
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
163
163
|
const [componentRenderShowState, setComponentRenderShowState] =
|
|
164
164
|
useState(false)
|
|
165
165
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
166
166
|
const componentShowStateRef = useRef(false)
|
|
167
167
|
const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
|
|
168
168
|
const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector('#J_shopHomeRoot')
|
|
169
169
|
const { ref, inView } = useInView({
|
|
170
170
|
threshold: 0,
|
|
171
171
|
triggerOnce: true,
|
|
172
172
|
root: rootDom,
|
|
173
173
|
rootMargin: `0px 0px ${window.innerHeight}px 0px`,
|
|
174
174
|
})
|
|
175
175
|
useEffect(() => {
|
|
176
176
|
if(needShowHighVersion || !isH5AndJdShopView) return
|
|
177
177
|
if (type === LazyType.FLOOR) {
|
|
178
178
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
179
179
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes,false)
|
|
180
180
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
181
181
|
!componentShowStateRef.current && dealPageScrollInfo(res,true)
|
|
182
182
|
})
|
|
183
183
|
}
|
|
184
184
|
}, [])
|
|
185
185
|
useEffect(() => {
|
|
186
186
|
if((!needShowHighVersion && componentShowState === true) ||
|
|
187
187
|
(needShowHighVersion && inView && isH5AndJdShopView)
|
|
188
188
|
) {
|
|
189
189
|
console.log('>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!')
|
|
190
190
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
191
191
|
const modularPackResultObj = typeof modularPackResult === 'string' ? JSON.parse(modularPackResult) : modularPackResult
|
|
192
192
|
if (modularPackResultObj && modularPackResultObj.bundleUrl) {
|
|
193
193
|
const { bundleUrl } = modularPackResultObj
|
|
194
194
|
nativePageRegisterMessage(
|
|
195
195
|
Message_Type.NATIVE_INJECT_JS_FILE,
|
|
196
196
|
{
|
|
197
197
|
data: {
|
|
198
198
|
"bundleUrl": [bundleUrl]
|
|
199
199
|
},
|
|
200
200
|
},
|
|
201
201
|
)
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
}, [componentShowState,inView])
|
|
205
205
|
|
|
206
206
|
const dealPageScrollInfo = (res,pageScrollTrigger) => {
|
|
207
207
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
208
208
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') {
|
|
209
209
|
const shopId = floorData?.floorExtInfo?.shopId
|
|
210
210
|
if(!lazyLayoutLoadErrorShopId[`${shopId}`] && pageScrollTrigger) {
|
|
211
211
|
const opt = {
|
|
212
212
|
msg: `店铺楼层懒加载失败。楼层顺序-floorIdx: ${floorData?.floorIdx}。`,
|
|
213
213
|
uid: floorData?.uid,
|
|
214
214
|
floorIdx: floorData?.floorIdx,
|
|
215
215
|
shopId: shopId,
|
|
216
216
|
moduleId: floorData?.moduleId,
|
|
217
217
|
moduleName: floorData?.moduleName,
|
|
218
218
|
middleTemplateId: floorData?.middleTemplateId
|
|
219
219
|
}
|
|
220
220
|
sgmCustomReport({
|
|
221
221
|
code: getSgmCustomCode(SgmCustomCode.FLOORLAZYLOAD_DATA),
|
|
222
222
|
msg: opt,
|
|
223
223
|
})
|
|
224
224
|
lazyLayoutLoadErrorShopId[`${shopId}`] = true
|
|
225
225
|
}
|
|
226
226
|
return
|
|
227
227
|
}
|
|
228
228
|
if (componentLazyRef.current) {
|
|
229
229
|
const eleClientRect =
|
|
230
230
|
componentLazyRef.current.getBoundingClientRect()
|
|
231
231
|
const getContainerHeightOffSetY = displayHeight + offSetY
|
|
232
232
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
233
233
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
234
234
|
const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight
|
|
235
235
|
if (!componentShowStateRef.current) {
|
|
236
236
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
237
237
|
componentShowStateRef.current = true
|
|
238
238
|
setComponentShowState(true)
|
|
239
239
|
Taro.nextTick(() => {
|
|
240
240
|
setComponentRenderShowState(true)
|
|
241
241
|
})
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
return isH5AndJdShopView && !needShowHighVersion ? (
|
|
247
247
|
<div
|
|
248
248
|
id={`${containerId}_lazy`}
|
|
249
249
|
ref={componentLazyRef}
|
|
250
250
|
className={classNames(
|
|
251
251
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
252
252
|
'd-app-floor-lazy-load',
|
|
253
253
|
)}
|
|
254
254
|
style={{
|
|
255
255
|
minHeight: `${
|
|
256
256
|
componentRenderShowState ? 'auto' : height + 'px'
|
|
257
257
|
}`,
|
|
258
258
|
backgroundColor: componentRenderShowState
|
|
259
259
|
? 'transparent'
|
|
260
260
|
: '#ffffff',
|
|
261
261
|
}}
|
|
262
262
|
>
|
|
263
263
|
{componentShowState ? children : placeholder}
|
|
264
264
|
</div>
|
|
265
265
|
) : (
|
|
266
266
|
<div
|
|
267
267
|
id={`${containerId}_lazy`}
|
|
268
268
|
className={classNames(
|
|
269
269
|
lazyLayoutLoadStyle['d-mobile-floor-lazy-layout-load'],
|
|
270
270
|
'd-mobile-floor-lazy-load',
|
|
271
271
|
lazyNodeClassName,
|
|
272
272
|
)}
|
|
273
273
|
ref={ref}
|
|
274
274
|
style={{
|
|
275
275
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
276
276
|
backgroundColor: inView ? 'transparent' : '#ffffff',
|
|
277
277
|
}}
|
|
278
278
|
>
|
|
279
279
|
{}
|
|
280
280
|
{inView ? children : placeholder}
|
|
281
281
|
</div>
|
|
282
282
|
)
|
|
283
283
|
sectionType:
|
|
284
284
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
|
|
285
285
|
type: LazyType.FLOOR,
|
|
286
286
|
children: null,
|
|
287
287
|
placeholder: null,
|
|
288
288
|
height: 200,
|
|
289
289
|
className: '',
|
|
290
290
|
lazyNodeClassName: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, {useEffect, useRef} from 'react'
|
|
2
1
|
const { title, openAppParams, style, hasCommonHeader = true, hasDownloadTips = true, headerParams } = props
|
|
3
2
|
const headerRef:any = useRef(null)
|
|
4
3
|
useEffect(() => {
|
|
5
4
|
hasCommonHeader && initCommonHeader()
|
|
6
5
|
hasDownloadTips && initDownloadAppLayerConfigData()
|
|
7
6
|
}, [])
|
|
8
7
|
const scrollEventFunc = () => {
|
|
9
8
|
const stickyTop = headerRef.current?.getBoundingClientRect()?.top || 0;
|
|
10
9
|
const rootScrollEleNode = document.querySelector('#J_shopHomeRoot')
|
|
11
10
|
if (rootScrollEleNode && rootScrollEleNode.scrollTop > stickyTop) {
|
|
12
11
|
headerRef.current.classList.add('d-mobile-header-sticky');
|
|
13
12
|
} else {
|
|
14
13
|
headerRef.current.classList.remove('d-mobile-header-sticky');
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
useEffect(() => {
|
|
18
17
|
if(!headerRef.current) return
|
|
19
18
|
const rootScrollEleNode = document.querySelector('#J_shopHomeRoot')
|
|
20
19
|
rootScrollEleNode && rootScrollEleNode.addEventListener('scroll', scrollEventFunc);
|
|
21
20
|
return () => {
|
|
22
21
|
rootScrollEleNode && rootScrollEleNode.removeEventListener('scroll', scrollEventFunc)
|
|
23
22
|
}
|
|
24
23
|
},[])
|
|
25
24
|
const initCommonHeader = () => {
|
|
26
25
|
if (window?.MCommonHeaderBottom) {
|
|
27
26
|
const mchb = new MCommonHeaderBottom()
|
|
28
27
|
const headerArg = {
|
|
29
28
|
moduleName: 'shop',
|
|
30
29
|
hrederId: 'm_common_header',
|
|
31
30
|
title,
|
|
32
31
|
stype: 1,
|
|
33
32
|
onClickJdkey: function () {
|
|
34
33
|
console.log('==>m_common_header jdkey click.')
|
|
35
34
|
},
|
|
36
35
|
...headerParams
|
|
37
36
|
}
|
|
38
37
|
mchb.header(headerArg)
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
const initDownloadAppLayerConfigData = () => {
|
|
42
41
|
const getEle = document.getElementById('m_common_tip')
|
|
43
42
|
getEle &&
|
|
44
43
|
window.$ &&
|
|
45
44
|
window.$.downloadAppLayerConfigData &&
|
|
46
45
|
window.$.downloadAppLayerConfigData({
|
|
47
46
|
tipId: 'm_common_tip',
|
|
48
47
|
M_sourceFrom: 'jshop',
|
|
49
48
|
bottom: 74,
|
|
50
49
|
onClickTipX: () => {
|
|
51
50
|
Taro.eventCenter.trigger(
|
|
52
51
|
TaroEventType.DOWN_LOAD_APP_CLOSE_CHANGE,
|
|
53
52
|
true,
|
|
54
53
|
)
|
|
55
54
|
},
|
|
56
55
|
downloadAppPlugIn: {
|
|
57
56
|
M_sourceFrom: 'jshop',
|
|
58
57
|
openAppBtnId: 'download_openapp',
|
|
59
58
|
downAppURl: '//conecli.com/downloadApp/download.html?channel=jd-m',
|
|
60
59
|
inteneUrl: 'openapp.jdmobile://virtual?',
|
|
61
60
|
inteneUrlParams: {
|
|
62
61
|
category: 'jump',
|
|
63
62
|
des: 'jshopMain',
|
|
64
63
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
65
64
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
66
65
|
sourceType: global.info.queryInfo?.sourceType || 'M-H5',
|
|
67
66
|
sourceValue: global.info.queryInfo?.sourceValue || 'Mshop',
|
|
68
67
|
...openAppParams,
|
|
69
68
|
},
|
|
70
69
|
},
|
|
71
70
|
})
|
|
72
71
|
}
|
|
73
72
|
return !isWxMiniH5View && !isJdApp ? (
|
|
74
73
|
<View
|
|
75
74
|
className={mobileCommonHeaderStyle['d-mobile-header-layout']}
|
|
76
75
|
style={style}
|
|
77
76
|
ref={headerRef}
|
|
78
77
|
>
|
|
79
78
|
<View
|
|
80
79
|
id="m_common_tip"
|
|
81
80
|
className={mobileCommonHeaderStyle['d-mobile-common-tip']}
|
|
82
81
|
/>
|
|
83
82
|
{hasCommonHeader && (
|
|
84
83
|
<View
|
|
85
84
|
id="m_common_header"
|
|
86
85
|
className={mobileCommonHeaderStyle['d-mobile-common-header']}
|
|
87
86
|
/>
|
|
88
87
|
)}
|
|
89
88
|
</View>
|
|
90
89
|
) : null
|
|
91
90
|
title: '店铺',
|
|
92
91
|
openAppParams: {},
|
|
92
|
+
import React, {useEffect, useRef} from 'react'
|
|
93
93
|
const { title, openAppParams, style, hasCommonHeader = true, hasDownloadTips = true, headerParams } = props
|
|
94
94
|
const headerRef:any = useRef(null)
|
|
95
95
|
useEffect(() => {
|
|
96
96
|
hasCommonHeader && initCommonHeader()
|
|
97
97
|
hasDownloadTips && initDownloadAppLayerConfigData()
|
|
98
98
|
}, [])
|
|
99
99
|
const isScrolledToTop = () => {
|
|
100
100
|
return window.scrollY !== undefined ? window.scrollY === 0 :
|
|
101
101
|
document.documentElement.scrollTop === 0 || document.body.scrollTop === 0;
|
|
102
102
|
}
|
|
103
103
|
const scrollEventFunc = () => {
|
|
104
104
|
if(!headerRef.current) return
|
|
105
105
|
const stickyTop = headerRef.current?.getBoundingClientRect()?.top || 0;
|
|
106
106
|
if(Math.trunc(stickyTop) <= 0 && !isScrolledToTop()) {
|
|
107
107
|
console.log('scroll 添加class',Math.trunc(stickyTop), isScrolledToTop())
|
|
108
108
|
headerRef.current.classList.add('d-mobile-header-sticky');
|
|
109
109
|
}else {
|
|
110
110
|
console.log('scroll 移除class',Math.trunc(stickyTop), isScrolledToTop())
|
|
111
111
|
headerRef.current.classList.remove('d-mobile-header-sticky');
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
useEffect(() => {
|
|
115
115
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL,() => {
|
|
116
116
|
scrollEventFunc()
|
|
117
117
|
})
|
|
118
118
|
},[])
|
|
119
119
|
const initCommonHeader = () => {
|
|
120
120
|
if (window?.MCommonHeaderBottom) {
|
|
121
121
|
const mchb = new MCommonHeaderBottom()
|
|
122
122
|
const headerArg = {
|
|
123
123
|
moduleName: 'shop',
|
|
124
124
|
hrederId: 'm_common_header',
|
|
125
125
|
title,
|
|
126
126
|
stype: 1,
|
|
127
127
|
onClickJdkey: function () {
|
|
128
128
|
console.log('==>m_common_header jdkey click.')
|
|
129
129
|
},
|
|
130
130
|
...headerParams
|
|
131
131
|
}
|
|
132
132
|
mchb.header(headerArg)
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
const initDownloadAppLayerConfigData = () => {
|
|
136
136
|
const getEle = document.getElementById('m_common_tip')
|
|
137
137
|
getEle &&
|
|
138
138
|
window.$ &&
|
|
139
139
|
window.$.downloadAppLayerConfigData &&
|
|
140
140
|
window.$.downloadAppLayerConfigData({
|
|
141
141
|
tipId: 'm_common_tip',
|
|
142
142
|
M_sourceFrom: 'jshop',
|
|
143
143
|
bottom: 74,
|
|
144
144
|
onClickTipX: () => {
|
|
145
145
|
Taro.eventCenter.trigger(
|
|
146
146
|
TaroEventType.DOWN_LOAD_APP_CLOSE_CHANGE,
|
|
147
147
|
true,
|
|
148
148
|
)
|
|
149
149
|
},
|
|
150
150
|
downloadAppPlugIn: {
|
|
151
151
|
M_sourceFrom: 'jshop',
|
|
152
152
|
openAppBtnId: 'download_openapp',
|
|
153
153
|
downAppURl: '//conecli.com/downloadApp/download.html?channel=jd-m',
|
|
154
154
|
inteneUrl: 'openapp.jdmobile://virtual?',
|
|
155
155
|
inteneUrlParams: {
|
|
156
156
|
category: 'jump',
|
|
157
157
|
des: 'jshopMain',
|
|
158
158
|
shopId: `${global.info.queryInfo.shopId || ''}`,
|
|
159
159
|
venderId: `${global.info.queryInfo.venderId || ''}`,
|
|
160
160
|
sourceType: global.info.queryInfo?.sourceType || 'M-H5',
|
|
161
161
|
sourceValue: global.info.queryInfo?.sourceValue || 'Mshop',
|
|
162
162
|
...openAppParams,
|
|
163
163
|
},
|
|
164
164
|
},
|
|
165
165
|
})
|
|
166
166
|
}
|
|
167
167
|
return !isWxMiniH5View && !isJdApp ? (
|
|
168
168
|
<View
|
|
169
169
|
className={mobileCommonHeaderStyle['d-mobile-header-layout']}
|
|
170
170
|
style={style}
|
|
171
171
|
ref={headerRef}
|
|
172
172
|
>
|
|
173
173
|
<View
|
|
174
174
|
id="m_common_tip"
|
|
175
175
|
className={mobileCommonHeaderStyle['d-mobile-common-tip']}
|
|
176
176
|
/>
|
|
177
177
|
{hasCommonHeader && (
|
|
178
178
|
<View
|
|
179
179
|
id="m_common_header"
|
|
180
180
|
className={mobileCommonHeaderStyle['d-mobile-common-header']}
|
|
181
181
|
/>
|
|
182
182
|
)}
|
|
183
183
|
</View>
|
|
184
184
|
) : null
|
|
185
185
|
title: '店铺',
|
|
186
186
|
openAppParams: {},
|