张延森 4 年前
父节点
当前提交
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
   )
24
   )
25
 
25
 
26
   return (
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
         !props.length ? NoData :
29
         !props.length ? NoData :
30
         <ReactList
30
         <ReactList

+ 5
- 9
src/compents/tab/index.jsx 查看文件

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

+ 13
- 2
src/pages/account/index.jsx 查看文件

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