Commit 22991f93 authored by GuanHua's avatar GuanHua

feat:企业商城搜索部分滚动置顶

parent 62482e2d
......@@ -19,7 +19,7 @@
top: 0;
left: 0;
z-index: 999;
border-bottom: 1px solid var(--mall_main_color);
// border-bottom: 1px solid var(--mall_main_color);
padding-top: 0;
transition: all .5s;
......
......@@ -19,11 +19,32 @@ const Header: React.FC<HeaderPropsType> = (props) => {
const [count, setCount] = useState<number>(0)
const { search } = history.location.query
let handleScroll = () => {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const floatSearch = document.getElementById("floatSearch")
if (scrollTop > 500) {
if (!hasClass(floatSearch.classList, 'show')) {
floatSearch.classList.add(styles.show)
}
} else {
if (hasClass(floatSearch.classList, 'show')) {
floatSearch.classList.remove(styles.show)
}
}
}
const hasClass = (list, className) => {
let result = false
list && list.forEach(item => {
if (item && item.indexOf(className) > -1) {
result = true
}
})
return result
}
useEffect(() => {
// setTimeout(() => {
// let floatSearch = document.getElementById("floatSearch")
// floatSearch.classList.add(styles.show)
// }, 4000);
window.addEventListener('scroll', handleScroll)
}, [])
useEffect(() => {
......
import React, { useEffect, useState } from 'react'
import React, { useEffect, useState, Fragment } from 'react'
import { PublicApi } from '@/services/api'
import { GetManageContentColumnAllResponse } from '@/services/PassApi'
import ImageBox from '@/components/ImageBox'
......@@ -123,10 +123,10 @@ const Information: React.FC<InformationPropsType> = (props) => {
<div className={styles.information_list_item_body}>
{
(leadLeftNews && leadLeftNews.length > 0) && leadLeftNews.map((item, index) => index <= 3 && (
<>
<Fragment key={`news_list_item_left_${item.id}`}>
{
index === 0 ? (
<a href={toDetailLink(item.id)} key={`information_recommand_${item.id}`}>
<a href={toDetailLink(item.id)} >
<div className={styles.information_recommand}>
<div className={styles.information_recommand_img}>
<ImageBox width={220} height={146} imgUrl={item.imageUrl} />
......@@ -139,7 +139,7 @@ const Information: React.FC<InformationPropsType> = (props) => {
</div>
</a>
) : (
<a href={toDetailLink(item.id)} key={`news_list_item_${item.id}`}>
<a href={toDetailLink(item.id)}>
<div className={styles.news_list_item}>
<div className={styles.news_list_item_title}>{item.title}</div>
<div className={styles.news_list_item_date}>{(moment(item.createTime).format('YYYY-MM-DD HH:mm:ss'))}</div>
......@@ -147,7 +147,7 @@ const Information: React.FC<InformationPropsType> = (props) => {
</a>
)
}
</>
</Fragment>
))
}
</div>
......@@ -156,10 +156,10 @@ const Information: React.FC<InformationPropsType> = (props) => {
<div className={styles.information_list_item_body}>
{
(leadRightNews && leadRightNews.length > 0) && leadRightNews.map((item, index) => index <= 3 && (
<>
<Fragment key={`information_recommand_right_${item.id}`}>
{
index === 0 ? (
<a href={toDetailLink(item.id)} key={`information_recommand_${index}`}>
<a href={toDetailLink(item.id)} >
<div className={styles.information_recommand}>
<div className={styles.information_recommand_img}>
<ImageBox width={220} height={146} imgUrl={item.imageUrl} />
......@@ -172,7 +172,7 @@ const Information: React.FC<InformationPropsType> = (props) => {
</div>
</a>
) : (
<a href={toDetailLink(item.id)} key={`news_list_item_${index}`}>
<a href={toDetailLink(item.id)}>
<div className={styles.news_list_item}>
<div className={styles.news_list_item_title}>{item.title}</div>
<div className={styles.news_list_item_date}>{(moment(item.createTime).format('YYYY-MM-DD HH:mm:ss'))}</div>
......@@ -180,7 +180,7 @@ const Information: React.FC<InformationPropsType> = (props) => {
</a>
)
}
</>
</Fragment>
))
}
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment