zlisen 4 years ago
parent
commit
9a7320c89b
3 changed files with 42 additions and 33 deletions
  1. 3
    3
      src/layout/index.jsx
  2. 38
    29
      src/pages/house/list/index.jsx
  3. 1
    1
      src/pages/landlord/index.jsx

+ 3
- 3
src/layout/index.jsx View File

2
 import Taro from '@tarojs/taro'
2
 import Taro from '@tarojs/taro'
3
 import { View, ScrollView } from '@tarojs/components'
3
 import { View, ScrollView } from '@tarojs/components'
4
 
4
 
5
-const Layout = ({ children,type }) => {
5
+const Layout = ({ children,type,otherHeight }) => {
6
 
6
 
7
   const navStyle =  Taro.getMenuButtonBoundingClientRect()
7
   const navStyle =  Taro.getMenuButtonBoundingClientRect()
8
 
8
 
9
-    return <ScrollView className='scrol' scrollY  style={type=='custom'?{height:`calc(100vh - 65px - ${navStyle.bottom}px - 10px)`}:undefined} >
9
+    return <ScrollView className='scrol' scrollY  style={type=='custom'?{height:`calc(100vh - 65px - ${navStyle.bottom}px - 10px - ${otherHeight||0}px)`}:undefined} >
10
         <View className='page-container' >
10
         <View className='page-container' >
11
             {children}
11
             {children}
12
         </View>
12
         </View>
13
         {/* <View style={{height:'10rpx'}}></View> */}
13
         {/* <View style={{height:'10rpx'}}></View> */}
14
     </ScrollView>
14
     </ScrollView>
15
 }
15
 }
16
-
16
+// - 8px
17
 
17
 
18
 export default Layout;
18
 export default Layout;

+ 38
- 29
src/pages/house/list/index.jsx View File

3
   useMemo,
3
   useMemo,
4
   useState,
4
   useState,
5
   forwardRef,
5
   forwardRef,
6
-  useImperativeHandle,
7
-  useCallback
6
+  useImperativeHandle
8
 } from "react";
7
 } from "react";
9
 import Taro, { useDidShow } from "@tarojs/taro";
8
 import Taro, { useDidShow } from "@tarojs/taro";
10
-import { useSelector } from 'react-redux'
9
+import { useSelector } from "react-redux";
11
 // import debounce from 'lodash.debounce'
10
 // import debounce from 'lodash.debounce'
12
 import "./index.scss";
11
 import "./index.scss";
13
-import { View, Text, Input, Image } from "@tarojs/components";
12
+import { View, Image } from "@tarojs/components";
14
 import ContainerLayout from "../../../compents/container/index";
13
 import ContainerLayout from "../../../compents/container/index";
15
 import radio from "../../../assets/radio.png";
14
 import radio from "../../../assets/radio.png";
16
 import request from "@/util/request";
15
 import request from "@/util/request";
17
 import RecycleList from "@/compents/RecycleList";
16
 import RecycleList from "@/compents/RecycleList";
18
 
17
 
19
-let house = (props, ref) => {
20
-  const user = useSelector(state => state.user)
21
-  const defaultShop = user.defaultShop
18
+const house = (props, ref) => {
19
+  const user = useSelector(state => state.user);
20
+  const defaultShop = user.defaultShop;
22
   const [list, setList] = useState([]);
21
   const [list, setList] = useState([]);
23
   const [radioHouse, setRadioHouse] = useState();
22
   const [radioHouse, setRadioHouse] = useState();
24
   const [width, setWidth] = useState();
23
   const [width, setWidth] = useState();
25
   const [height, setHeight] = useState();
24
   const [height, setHeight] = useState();
26
-  const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10, shopId: defaultShop });
25
+  const [queryParams, setQueryParams] = useState({
26
+    pageNum: 1,
27
+    pageSize: 10,
28
+    shopId: defaultShop
29
+  });
27
   const [total, setTotal] = useState(0);
30
   const [total, setTotal] = useState(0);
28
 
31
 
29
   useImperativeHandle(ref, () => ({
32
   useImperativeHandle(ref, () => ({
36
   const radioHouseState = useMemo(() => props.radioHouseState, [
39
   const radioHouseState = useMemo(() => props.radioHouseState, [
37
     props.radioHouseState
40
     props.radioHouseState
38
   ]);
41
   ]);
39
-  
40
 
42
 
41
   const getHouseList = () => {
43
   const getHouseList = () => {
42
-    if (!queryParams.shopId) return
43
-    
44
+    if (!queryParams.shopId) return;
45
+
44
     // console.log('---------->>>>', queryParams.shopId, queryParams.pageNum)
46
     // console.log('---------->>>>', queryParams.shopId, queryParams.pageNum)
47
+    Taro.showLoading({
48
+      title: "加载中 ...",
49
+      mask: true
50
+    });
45
 
51
 
46
     request({
52
     request({
47
       url: "/taHouse",
53
       url: "/taHouse",
60
         setList(records);
66
         setList(records);
61
       }
67
       }
62
       setTotal(page.total);
68
       setTotal(page.total);
69
+      Taro.hideLoading();
63
     });
70
     });
64
   };
71
   };
65
 
72
 
66
-  const handleScrollBottom = e => {
73
+  const handleScrollBottom = () => {
67
     setQueryParams({
74
     setQueryParams({
68
       ...queryParams,
75
       ...queryParams,
69
       pageNum: queryParams.pageNum + 1
76
       pageNum: queryParams.pageNum + 1
70
     });
77
     });
71
-  }
78
+  };
72
 
79
 
73
   const onShare = x => {
80
   const onShare = x => {
74
-    Taro.navigateTo({ url: `/pages/share/index?houseId=${x.houseId}&&title=${x.title}` });
81
+    Taro.navigateTo({
82
+      url: `/pages/share/index?houseId=${x.houseId}&&title=${x.title}`
83
+    });
75
   };
84
   };
76
 
85
 
77
   const handleDelete = x => {
86
   const handleDelete = x => {
78
     Taro.showModal({
87
     Taro.showModal({
79
-      title: '删除',
80
-      content: '确认删除当前房源?',
88
+      title: "删除",
89
+      content: "确认删除当前房源?",
81
       success: res => {
90
       success: res => {
82
         if (res.confirm) {
91
         if (res.confirm) {
83
           request({
92
           request({
84
             url: `/taHouse/${x.houseId}`,
93
             url: `/taHouse/${x.houseId}`,
85
-            method: 'DELETE'
86
-          }).then(res => {
87
-            setList(list.filter(t => t.houseId != x.houseId))
94
+            method: "DELETE"
95
+          }).then(() => {
96
+            setList(list.filter(t => t.houseId != x.houseId));
88
           });
97
           });
89
         }
98
         }
90
       }
99
       }
91
-    })
92
-  }
100
+    });
101
+  };
93
 
102
 
94
   useEffect(() => {
103
   useEffect(() => {
95
     wx.setNavigationBarTitle({
104
     wx.setNavigationBarTitle({
116
               if (item.height) {
125
               if (item.height) {
117
                 found = true;
126
                 found = true;
118
 
127
 
119
-                let h = Taro.getSystemInfoSync().safeArea.height - item.height - 50
128
+                let h =
129
+                  Taro.getSystemInfoSync().safeArea.height - item.height - 50;
120
 
130
 
121
                 // 如果显示了下拉框,要去掉下拉框的高度
131
                 // 如果显示了下拉框,要去掉下拉框的高度
122
                 if (user.shopList && user.shopList.length > 1) {
132
                 if (user.shopList && user.shopList.length > 1) {
123
-                  h -= 64
133
+                  h -= 64;
124
                 }
134
                 }
125
 
135
 
126
                 setHeight(h);
136
                 setHeight(h);
153
   }, [queryParams]);
163
   }, [queryParams]);
154
 
164
 
155
   useEffect(() => {
165
   useEffect(() => {
156
-      setQueryParams({ ...queryParams, shopId: defaultShop, pageNum: 1 })
157
-  }, [defaultShop])
166
+    setQueryParams({ ...queryParams, shopId: defaultShop, pageNum: 1 });
167
+  }, [defaultShop]);
158
 
168
 
159
   // useDidShow(() => {
169
   // useDidShow(() => {
160
   //   setQueryParams({ ...queryParams })
170
   //   setQueryParams({ ...queryParams })
161
   // })
171
   // })
162
- 
172
+
163
   return (
173
   return (
164
     <View className="houselist">
174
     <View className="houselist">
165
       {(!list || !list.length) && <View className="nodata"> 暂无数据</View>}
175
       {(!list || !list.length) && <View className="nodata"> 暂无数据</View>}
220
                 </View>
230
                 </View>
221
               </View>
231
               </View>
222
             </ContainerLayout>
232
             </ContainerLayout>
223
-          </View>        
233
+          </View>
224
         )}
234
         )}
225
       />
235
       />
226
     </View>
236
     </View>
227
   );
237
   );
228
 };
238
 };
229
 
239
 
230
-house = forwardRef(house);
231
-export default house;
240
+export default forwardRef(house);

+ 1
- 1
src/pages/landlord/index.jsx View File

121
         )
121
         )
122
       }
122
       }
123
 
123
 
124
-      <Layout type='custom'>
124
+      <Layout type='custom' otherHeight={shopList.length > 1 ? 8+58.42 : 0}>
125
         {pageState == '1' && <HouseLIst ref={childRef} radioHouseState={radioHouseState} onChange={(e) => setRadioHouseData(e)}></HouseLIst>}
125
         {pageState == '1' && <HouseLIst ref={childRef} radioHouseState={radioHouseState} onChange={(e) => setRadioHouseData(e)}></HouseLIst>}
126
       </Layout>
126
       </Layout>
127
       {!isOpened && <Tab className='addhousetab' value={['+添加房源']} onClick={(e) => setIsOpened(true)}></Tab>}
127
       {!isOpened && <Tab className='addhousetab' value={['+添加房源']} onClick={(e) => setIsOpened(true)}></Tab>}