xujing 5 years ago
parent
commit
e507362d31
2 changed files with 36 additions and 23 deletions
  1. 34
    21
      src/pages/project/list/filter/index.js
  2. 2
    2
      src/pages/project/list/filter/index.scss

+ 34
- 21
src/pages/project/list/filter/index.js View File

15
     visible: false,
15
     visible: false,
16
     tabIndex: null,
16
     tabIndex: null,
17
     priceTypeIndex: 0,
17
     priceTypeIndex: 0,
18
-    selectedIndex: new Array(3).fill([0]),
18
+    selectedIndex: new Array(4).fill([0]),
19
     tabs: [
19
     tabs: [
20
-      // {
21
-      //   name: '户型',
22
-      //   id: 'huxing',
23
-      //   list: ['不限', '一室', '两室', '三室', '四室', '五室以上']
24
-      // },
20
+      {
21
+        name: '户型',
22
+        id: 'huxing',
23
+        list: ['不限', '一室', '两室', '三室', '四室', '五室以上']
24
+      },
25
       {
25
       {
26
         name: '价格',
26
         name: '价格',
27
         id: 'price',
27
         id: 'price',
28
         list: ['不限', '10000元/㎡以下', '10000-20000元/㎡', '20000-30000元/㎡', '30000-50000元/㎡', '50000-70000元/㎡', '70000-100000元/㎡', '100000元/㎡以上']
28
         list: ['不限', '10000元/㎡以下', '10000-20000元/㎡', '20000-30000元/㎡', '30000-50000元/㎡', '50000-70000元/㎡', '70000-100000元/㎡', '100000元/㎡以上']
29
+        // list: [
30
+        //   {
31
+        //     name: '总价',
32
+        //     id: 'totalPrice',
33
+        //     list: ['不限', '100万以下', '100-150万', '150-200万', '200-500万', '500-1000万', '1000万以上']
34
+        //   },
35
+        //   {
36
+        //     name: '单价',
37
+        //     id: 'unitPrice ',
38
+        //     list: ['不限', '10000/㎡以下', '10000-20000元/㎡', '20000-30000元/㎡', '30000-50000元/㎡', '50000-70000元/㎡', '70000-100000元/㎡', '100000元/㎡以上']
39
+        //   }
40
+        // ]
29
       },
41
       },
30
       {
42
       {
31
         name: '面积',
43
         name: '面积',
47
     queryItemTypeList().then(res => {
59
     queryItemTypeList().then(res => {
48
       let houseTypeList = res.records
60
       let houseTypeList = res.records
49
       houseTypeList.unshift('不限')
61
       houseTypeList.unshift('不限')
50
-      tabs[2].list = houseTypeList
62
+      tabs[3].list = houseTypeList
51
       this.setState({ tabs })
63
       this.setState({ tabs })
52
     })
64
     })
53
   }
65
   }
107
 
119
 
108
   handleFilter() {
120
   handleFilter() {
109
 
121
 
122
+    console.log("111")
110
     const { tabs, keywords, selectedIndex } = this.state
123
     const { tabs, keywords, selectedIndex } = this.state
111
     console.log(this.state)
124
     console.log(this.state)
112
     let values = selectedIndex.map((selectedList, tabIndex) => {
125
     let values = selectedIndex.map((selectedList, tabIndex) => {
118
       }
131
       }
119
 
132
 
120
       // 类型
133
       // 类型
121
-      // if (tabIndex === 0) {
122
-      //   let val = selectedList.map(index => curTabList[index])
123
-      //   return val.join(',')
124
-      // }
134
+      if (tabIndex === 0) {
135
+        let val = selectedList.map(index => curTabList[index])
136
+        return val.join(',')
137
+      }
125
 
138
 
126
       // 价格 面积
139
       // 价格 面积
127
-      if (tabIndex === 0 || tabIndex === 1) {
140
+      if (tabIndex === 1 || tabIndex === 2) {
128
         let val = selectedList.map(index => {
141
         let val = selectedList.map(index => {
129
           let value = curTabList[index]
142
           let value = curTabList[index]
130
           let regVal = value.match(/\d*([-\d]*)?/)
143
           let regVal = value.match(/\d*([-\d]*)?/)
147
       }
160
       }
148
 
161
 
149
       // 类型
162
       // 类型
150
-      if (tabIndex === 2) {
163
+      if (tabIndex === 3) {
151
         let val = selectedList.map(index => curTabList[index].buildingTypeId)
164
         let val = selectedList.map(index => curTabList[index].buildingTypeId)
152
         return val.join(',')
165
         return val.join(',')
153
       }
166
       }
155
     console.log(values)
168
     console.log(values)
156
     let params = {
169
     let params = {
157
       name: keywords,
170
       name: keywords,
158
-      // houseType: values[0],
159
-      price: values[0],
160
-      area: values[1],
161
-      buildingType: values[2],
171
+      houseType: values[0],
172
+      price: values[1],
173
+      area: values[2],
174
+      buildingType: values[3],
162
     }
175
     }
163
     console.log(params)
176
     console.log(params)
164
     this.props.onFilter(params, () => {
177
     this.props.onFilter(params, () => {
205
         {
218
         {
206
           tabs[tabIndex].list.map((item, index) => (
219
           tabs[tabIndex].list.map((item, index) => (
207
             <View
220
             <View
208
-              key={index+'tab'}
221
+              key={index + 'tab'}
209
               className={`row ${selectedIndex[tabIndex].includes(index) ? 'active' : ''}`}
222
               className={`row ${selectedIndex[tabIndex].includes(index) ? 'active' : ''}`}
210
               onClick={this.handleFilterItemClick.bind(this, index)}>
223
               onClick={this.handleFilterItemClick.bind(this, index)}>
211
               {item.name || item.buildingTypeName || item}
224
               {item.name || item.buildingTypeName || item}
223
 
236
 
224
   renderPrice() {
237
   renderPrice() {
225
     const { priceTypeIndex, tabs, tabIndex, selectedIndex } = this.state
238
     const { priceTypeIndex, tabs, tabIndex, selectedIndex } = this.state
226
-    const priceArr = tabs[0].list
239
+    const priceArr = tabs[1].list
227
     const list = priceArr[priceTypeIndex].list
240
     const list = priceArr[priceTypeIndex].list
228
     return (
241
     return (
229
       <View className="price">
242
       <View className="price">
242
           {
255
           {
243
             list.map((text, index) => (
256
             list.map((text, index) => (
244
               <View
257
               <View
245
-                key={index+'list'}
258
+                key={index + 'list'}
246
                 className={`price-item ${selectedIndex[tabIndex].includes(index) ? 'selected' : ''}`}
259
                 className={`price-item ${selectedIndex[tabIndex].includes(index) ? 'selected' : ''}`}
247
                 onClick={this.handleFilterItemClick.bind(this, index)}>
260
                 onClick={this.handleFilterItemClick.bind(this, index)}>
248
                 {text}
261
                 {text}
285
         <View className="search-box">
298
         <View className="search-box">
286
           <View className="search">
299
           <View className="search">
287
             <Text className="search-icon icon-sousuo iconfont"></Text>
300
             <Text className="search-icon icon-sousuo iconfont"></Text>
288
-            <Input className="search-input" type="text" confirm-type="搜索" onConfirm={this.handleFilter} value={keywords} onInput={this.onInputText.bind(this)} placeholder="请输入你想查询的楼盘"></Input>
301
+            <Input className="search-input" type="text" focus confirm-type="搜索" onConfirm={this.handleFilter} value={keywords} onInput={this.onInputText.bind(this)} placeholder="请输入你想查询的楼盘"></Input>
289
           </View>
302
           </View>
290
           <View className="location" onClick={this.handleLocationClick}>
303
           <View className="location" onClick={this.handleLocationClick}>
291
             <Text className="location-icon iconfont icon-daohangdizhi"></Text>
304
             <Text className="location-icon iconfont icon-daohangdizhi"></Text>

+ 2
- 2
src/pages/project/list/filter/index.scss View File

80
     background: #F9F9F9;
80
     background: #F9F9F9;
81
 
81
 
82
     &-item {
82
     &-item {
83
-      width: 33.33%;
84
-      // width: 25%;
83
+      // width: 33.33%;
84
+      width: 25%;
85
       height: 100px;
85
       height: 100px;
86
       display: flex;
86
       display: flex;
87
       justify-content: center;
87
       justify-content: center;