张延森 4 лет назад
Родитель
Сommit
f0b4181e7d
3 измененных файлов: 19 добавлений и 12 удалений
  1. 1
    1
      src/compents/InifiniteList/index.jsx
  2. 5
    9
      src/compents/tab/index.jsx
  3. 13
    2
      src/pages/account/index.jsx

+ 1
- 1
src/compents/InifiniteList/index.jsx Просмотреть файл

@@ -24,7 +24,7 @@ export default props => {
24 24
   )
25 25
 
26 26
   return (
27
-    <div className="inifinite-list-wrapper" style={{maxHeight: props.height}} onScroll={handleScroll}>
27
+    <div className="inifinite-list-wrapper" style={{height: props.height}} onScroll={handleScroll}>
28 28
       {
29 29
         !props.length ? NoData :
30 30
         <ReactList

+ 5
- 9
src/compents/tab/index.jsx Просмотреть файл

@@ -1,4 +1,4 @@
1
-import React, { useEffect, useState } from 'react'
1
+import React, { useEffect, useRef, useState } from 'react'
2 2
 import Taro from "@tarojs/taro";
3 3
 import { Button, View } from '@tarojs/components'
4 4
 
@@ -14,20 +14,16 @@ import './index.scss'
14 14
 // }
15 15
 
16 16
 
17
-const tab = (props) => {
17
+const tab = React.forwardRef((props, ref) => {
18 18
     // formType="submit"
19
-
20 19
     const { value, pageState, formType, color, ...prop } = props
21 20
 
22 21
     const [state, setState] = useState(1)
23
-    // console.log(props)
24
-    useEffect(() => {
25
-
26
-    }, [])
22
+   
27 23
     //  &-on{
28 24
     //     color: #fed12f; style={{ backgroundColor:'#274291' ,color}}
29 25
     // }${props.className}
30
-    return <View className='tab'>
26
+    return <View className='tab' ref={ref}>
31 27
         {value.length == 1 && <View className={`tab tab1 ${props.className}`} onClick={() => props.onClick('2')}>{value[0]}
32 28
         </View>}
33 29
         {value.length == 2 && <View className={`tab tab2 ${props.className}`} style={{ display: 'flex', }}>
@@ -37,6 +33,6 @@ const tab = (props) => {
37 33
             :<Button className='tab-btn' formType={formType} plain={true} style={{ width: '50%' }} style={pageState == '3' ? { color: '#274291', width: '50%',border:'none' } : { width: '50%',border:'none' }} onClick={props.onClick[1]}>{value[1]}</Button>}
38 34
         </View>}
39 35
     </View>
40
-};
36
+})
41 37
 
42 38
 export default tab

+ 13
- 2
src/pages/account/index.jsx Просмотреть файл

@@ -12,9 +12,11 @@ import InifiniteList from "@/compents/InifiniteList";
12 12
 import IsLogin from "../../layout/IsLogin";
13 13
 
14 14
 const account = props => {
15
+  const tabRef = useRef()
15 16
   const { id } = getQueryValue();
16 17
   const [list, setList] = useState([]);
17 18
   const [page, setPage] = useState({ total: 0, pageNum: 0 });
19
+  const [listHeight, setListHeight] = useState('600')
18 20
 
19 21
   useDidShow(() => {
20 22
     console.log("useDidShow");
@@ -28,7 +30,8 @@ const account = props => {
28 30
       method: "get"
29 31
     }).then(res => {
30 32
       const { records, ...page } = res.data.data;
31
-      setList(list.concat(records || []));
33
+      const newList = records || []
34
+      setList(page.current === 1 ? newList : list.concat(newList))
32 35
       setPage({
33 36
         ...page,
34 37
         pageNum: page.current
@@ -61,6 +64,13 @@ const account = props => {
61 64
     getShopKepperList({ pageNum: page.pageNum + 1 });
62 65
   };
63 66
 
67
+  useEffect(() => {
68
+    if (tabRef.current) {
69
+      const h = `calc(100vh - 10px - ${tabRef.current.offsetHeight}px)`
70
+      setListHeight(h)
71
+    }
72
+  }, [tabRef.current])
73
+
64 74
   const renderItem = (index, key) => (
65 75
     <View className="account-view" key={key}>
66 76
       {/* <Text className='account-view-title'>房源编号:<Text style={{fontSize:"1rem"}}>{item.keeperId}</Text></Text> */}
@@ -99,7 +109,7 @@ const account = props => {
99 109
             <InifiniteList
100 110
               length={list.length}
101 111
               total={page.total}
102
-              height={600}
112
+              height={listHeight}
103 113
               itemRenderer={renderItem}
104 114
               loadMore={loadMore}
105 115
             />
@@ -107,6 +117,7 @@ const account = props => {
107 117
         </Layout>
108 118
         {/* onClick={(e)=>(e) */}
109 119
         <Tab
120
+          ref={tabRef}
110 121
           value={["+新增民宿老板账号"]}
111 122
           color="#ffffff"
112 123
           onClick={() => {