zlisen 4 vuotta sitten
vanhempi
commit
9a7320c89b
3 muutettua tiedostoa jossa 42 lisäystä ja 33 poistoa
  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 Näytä tiedosto

@@ -2,17 +2,17 @@ import React from 'react';
2 2
 import Taro from '@tarojs/taro'
3 3
 import { View, ScrollView } from '@tarojs/components'
4 4
 
5
-const Layout = ({ children,type }) => {
5
+const Layout = ({ children,type,otherHeight }) => {
6 6
 
7 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 10
         <View className='page-container' >
11 11
             {children}
12 12
         </View>
13 13
         {/* <View style={{height:'10rpx'}}></View> */}
14 14
     </ScrollView>
15 15
 }
16
-
16
+// - 8px
17 17
 
18 18
 export default Layout;

+ 38
- 29
src/pages/house/list/index.jsx Näytä tiedosto

@@ -3,27 +3,30 @@ import React, {
3 3
   useMemo,
4 4
   useState,
5 5
   forwardRef,
6
-  useImperativeHandle,
7
-  useCallback
6
+  useImperativeHandle
8 7
 } from "react";
9 8
 import Taro, { useDidShow } from "@tarojs/taro";
10
-import { useSelector } from 'react-redux'
9
+import { useSelector } from "react-redux";
11 10
 // import debounce from 'lodash.debounce'
12 11
 import "./index.scss";
13
-import { View, Text, Input, Image } from "@tarojs/components";
12
+import { View, Image } from "@tarojs/components";
14 13
 import ContainerLayout from "../../../compents/container/index";
15 14
 import radio from "../../../assets/radio.png";
16 15
 import request from "@/util/request";
17 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 21
   const [list, setList] = useState([]);
23 22
   const [radioHouse, setRadioHouse] = useState();
24 23
   const [width, setWidth] = useState();
25 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 30
   const [total, setTotal] = useState(0);
28 31
 
29 32
   useImperativeHandle(ref, () => ({
@@ -36,12 +39,15 @@ let house = (props, ref) => {
36 39
   const radioHouseState = useMemo(() => props.radioHouseState, [
37 40
     props.radioHouseState
38 41
   ]);
39
-  
40 42
 
41 43
   const getHouseList = () => {
42
-    if (!queryParams.shopId) return
43
-    
44
+    if (!queryParams.shopId) return;
45
+
44 46
     // console.log('---------->>>>', queryParams.shopId, queryParams.pageNum)
47
+    Taro.showLoading({
48
+      title: "加载中 ...",
49
+      mask: true
50
+    });
45 51
 
46 52
     request({
47 53
       url: "/taHouse",
@@ -60,36 +66,39 @@ let house = (props, ref) => {
60 66
         setList(records);
61 67
       }
62 68
       setTotal(page.total);
69
+      Taro.hideLoading();
63 70
     });
64 71
   };
65 72
 
66
-  const handleScrollBottom = e => {
73
+  const handleScrollBottom = () => {
67 74
     setQueryParams({
68 75
       ...queryParams,
69 76
       pageNum: queryParams.pageNum + 1
70 77
     });
71
-  }
78
+  };
72 79
 
73 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 86
   const handleDelete = x => {
78 87
     Taro.showModal({
79
-      title: '删除',
80
-      content: '确认删除当前房源?',
88
+      title: "删除",
89
+      content: "确认删除当前房源?",
81 90
       success: res => {
82 91
         if (res.confirm) {
83 92
           request({
84 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 103
   useEffect(() => {
95 104
     wx.setNavigationBarTitle({
@@ -116,11 +125,12 @@ let house = (props, ref) => {
116 125
               if (item.height) {
117 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 132
                 if (user.shopList && user.shopList.length > 1) {
123
-                  h -= 64
133
+                  h -= 64;
124 134
                 }
125 135
 
126 136
                 setHeight(h);
@@ -153,13 +163,13 @@ let house = (props, ref) => {
153 163
   }, [queryParams]);
154 164
 
155 165
   useEffect(() => {
156
-      setQueryParams({ ...queryParams, shopId: defaultShop, pageNum: 1 })
157
-  }, [defaultShop])
166
+    setQueryParams({ ...queryParams, shopId: defaultShop, pageNum: 1 });
167
+  }, [defaultShop]);
158 168
 
159 169
   // useDidShow(() => {
160 170
   //   setQueryParams({ ...queryParams })
161 171
   // })
162
- 
172
+
163 173
   return (
164 174
     <View className="houselist">
165 175
       {(!list || !list.length) && <View className="nodata"> 暂无数据</View>}
@@ -220,12 +230,11 @@ let house = (props, ref) => {
220 230
                 </View>
221 231
               </View>
222 232
             </ContainerLayout>
223
-          </View>        
233
+          </View>
224 234
         )}
225 235
       />
226 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 Näytä tiedosto

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