Your Name 3 anni fa
parent
commit
599a3361f6
2 ha cambiato i file con 18 aggiunte e 3 eliminazioni
  1. 4
    2
      src/pages/index/buildingList/index.jsx
  2. 14
    1
      src/utils/request.js

+ 4
- 2
src/pages/index/buildingList/index.jsx Vedi File

13
 import FilterForMore from './components/FilterForMore/index'
13
 import FilterForMore from './components/FilterForMore/index'
14
 import FilterForHouseSort from './components/FilterForHouseSort/index'
14
 import FilterForHouseSort from './components/FilterForHouseSort/index'
15
 
15
 
16
-export default withLayout(() => {
16
+export default withLayout((props) => {
17
+  const { router } = props
18
+  const { isRecentOpening } = router.params
17
 
19
 
18
   const city = useSelector(state => state.city)
20
   const city = useSelector(state => state.city)
19
   const [PageList, setPageList] = useState([])
21
   const [PageList, setPageList] = useState([])
87
         Data[key] = FilterData[key]
89
         Data[key] = FilterData[key]
88
       }
90
       }
89
     }
91
     }
90
-    fetch({ url: API_ITEMS_LIST, method: 'get', payload: { cityId: city.curCity.id, pageNumber, pageSize, ...Data } }).then((res) => {
92
+    fetch({ url: API_ITEMS_LIST, method: 'get', payload: { cityId: city.curCity.id, pageNumber, pageSize, isRecentOpening, ...Data } }).then((res) => {
91
       setPageList(pageNumber === 1 ? res.records || [] : PageList.concat(res.records || []))
93
       setPageList(pageNumber === 1 ? res.records || [] : PageList.concat(res.records || []))
92
       setHasNextPage(res.current < res.pages)
94
       setHasNextPage(res.current < res.pages)
93
       setPull(false)
95
       setPull(false)

+ 14
- 1
src/utils/request.js Vedi File

89
   const showMessage = Object.prototype.hasOwnProperty.call(payload, 'showToast') ? payload.showToast : showToast
89
   const showMessage = Object.prototype.hasOwnProperty.call(payload, 'showToast') ? payload.showToast : showToast
90
   const consultant = Taro.getStorageSync('consultantId') || ''
90
   const consultant = Taro.getStorageSync('consultantId') || ''
91
   const recommender = Taro.getStorageSync('recommender') || ''
91
   const recommender = Taro.getStorageSync('recommender') || ''
92
+
93
+  // 去掉 null 跟 undefined 字段
94
+  const data = Object.keys(payload).reduce((acc, key) => {
95
+    const val = payload[key]
96
+    if (val === null || val === undefined) {
97
+      return acc;
98
+    }
99
+
100
+    return {
101
+      ...acc,
102
+      [key]: val,
103
+    }
104
+  }, {})
92
   
105
   
93
   return [
106
   return [
94
     {
107
     {
95
       url,
108
       url,
96
       method,
109
       method,
97
-      data: payload,
110
+      data,
98
       header: {
111
       header: {
99
         'content-type': 'application/json',
112
         'content-type': 'application/json',
100
         'authorization': `Bearer ${Taro.getStorageSync('token')}`,
113
         'authorization': `Bearer ${Taro.getStorageSync('token')}`,