Your Name 3 years ago
parent
commit
599a3361f6
2 changed files with 18 additions and 3 deletions
  1. 4
    2
      src/pages/index/buildingList/index.jsx
  2. 14
    1
      src/utils/request.js

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

@@ -13,7 +13,9 @@ import FilterForHouseType from './components/FilterForHouseType/index'
13 13
 import FilterForMore from './components/FilterForMore/index'
14 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 20
   const city = useSelector(state => state.city)
19 21
   const [PageList, setPageList] = useState([])
@@ -87,7 +89,7 @@ export default withLayout(() => {
87 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 93
       setPageList(pageNumber === 1 ? res.records || [] : PageList.concat(res.records || []))
92 94
       setHasNextPage(res.current < res.pages)
93 95
       setPull(false)

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

@@ -89,12 +89,25 @@ export function optionBuilder(options) {
89 89
   const showMessage = Object.prototype.hasOwnProperty.call(payload, 'showToast') ? payload.showToast : showToast
90 90
   const consultant = Taro.getStorageSync('consultantId') || ''
91 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 106
   return [
94 107
     {
95 108
       url,
96 109
       method,
97
-      data: payload,
110
+      data,
98 111
       header: {
99 112
         'content-type': 'application/json',
100 113
         'authorization': `Bearer ${Taro.getStorageSync('token')}`,