搜索页面bug&个人中心学习记录bug&防抖

v2
一杯沧海 1 year ago
parent 68d99f86b1
commit c332fdca11
  1. 9
      src/components/learningRecord/learningRecord.tsx
  2. 2
      src/pages/my/my.tsx
  3. 2
      src/pages/preview/search/search/components/list.tsx
  4. 4
      src/pages/preview/search/search/index.config.ts
  5. 6
      src/pages/preview/search/search/index.module.scss
  6. 19
      src/pages/preview/search/search/index.tsx
  7. 12
      src/utils/debounce.ts

@ -8,6 +8,7 @@ import styles from './learningRecord.module.scss'
import Spin from "@/components/spinner";
import {Profile} from "@/store";
import Taro from "@tarojs/taro";
import debounce from "@/utils/debounce";
const tabList: TabList<any>[] = [
{
@ -64,11 +65,15 @@ const LearningRecord: FC<Props> = ({userId, style, className}) => {
Taro.navigateTo({url: '/pages/login/login'})
return
}
getStatistics(tab?.value! as StatisticsParam)
// getStatistics(tab?.value! as StatisticsParam)
debounce(()=>{
// console.log(this,'this')
getStatistics(tab?.value! as StatisticsParam)
})
}
useEffect(() => {
userId && getStatistics(tabList[0].value)
userId && setTimeout(() => {getStatistics(tabList[0].value)},500)
}, [userId])
return (<View className={[styles.box, className].filter(Boolean).join(' ')} style={{display: 'block', ...style}}>

@ -21,7 +21,6 @@ interface List {
src: string,
type?: number
}
function jump(token: string | null, type?: number) {
if (!token) {
Taro.navigateTo({url: '/pages/login/login'})
@ -169,6 +168,7 @@ const My: FC = () => {
</PageContainer>
</View>
</View>
)
}

@ -97,7 +97,7 @@ const SearchList: FC<Props> = ({name,clear}) => {
className='scrollview'
scrollY
scrollWithAnimation
style={{height:`${globalData.windowHeight-60}px`,backgroundColor:`#f5f5f5`}}
style={{height:`${globalData.windowHeight-140}px`,backgroundColor:`#f5f5f5`}}
onScrollToLower={onScrollToLower}
>
{ loading && <AtLoadMore status={'loading'}/>}

@ -1,5 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '搜索',
navigationBarBackgroundColor:'#F2F8F6',
onReachBottomDistance: 50
navigationStyle: 'custom'
})

@ -1,6 +1,10 @@
page{
background-color:#F2F8F6;
padding-left: 30rpx;
.navBox{
position: fixed;
width:750rpx;
}
.searchBox{
width: 690rpx;
height: 68rpx;

@ -8,6 +8,7 @@ import SearchList from './components/list'
const Search:FC = () => {
const globalData = Taro.getApp().globalData
const [value, setValue] = useState('')
const [recentSearch, setRecentSearch] = useState<string[]>([])
const [hotSearch,setHotSearch] = useState<any[]>([])
@ -55,10 +56,25 @@ const Search:FC = () => {
Taro.setStorageSync('recentSearch', [...new Set(recentSearch)])
}
function navBack(){
Taro.navigateBack()
}
return (
<View className="flex flex-column">
<View className={styles.navBox} style={{height:`${globalData.statusBarHeight+globalData.textBarHeight}px`}}>
<View style={{height:`${globalData.statusBarHeight}px`}}></View>
<View style={{height:`${globalData.textBarHeight}px`,display:'flex',alignItems:'center'}}>
<View className="flex justify-end" style={{width:'40px'}}>
<AtIcon value='chevron-left' size='25' color='#333' onClick={navBack}></AtIcon>
</View>
<View className="font-28 font-weight flex-1" style={{display:'flex',justifyContent:'center',paddingRight:'40px',boxSizing:'border-box'}}></View>
</View>
</View>
<View style={{paddingLeft: '30rpx'}}>
<View style={{height:`${globalData.statusBarHeight+globalData.textBarHeight}px`}}></View>
<View className={styles.searchBox}>
<AtIcon value='search' size='20' color='#ccc'></AtIcon>
{ show ?
@ -106,9 +122,10 @@ const Search:FC = () => {
</>
}
<PageContainer onClickOverlay={()=>{ setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0)'} >
<PageContainer onBeforeLeave={() => {setShow(false)}} onClickOverlay={()=>{ setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0)'} >
<SearchList name={value} clear={show} />
</PageContainer>
</View>
</View>
)

@ -0,0 +1,12 @@
let timeout:any = null
function debounce(func, wait = 500) {
console.log(arguments[0],'arguments')
timeout && clearTimeout(timeout)
timeout = setTimeout(() => {
console.log('执行')
typeof func === 'function' && func()
}, wait)
}
export default debounce
Loading…
Cancel
Save