xcx 4 anni fa
parent
commit
51be3dd9e4

+ 25
- 13
src/pages/city/index.js Vedi File

@@ -19,13 +19,11 @@ export default class Index extends Component {
19 19
     keywords: ''
20 20
   }
21 21
 
22
-  componentWillMount() {
23
-
22
+  componentWillMount () {
24 23
     this.initData()
25
-    console.log(this.props,"this.props.citylist")
26 24
   }
27 25
 
28
-  initData() {
26
+  initData () {
29 27
     queryCityList().then(cityList => {
30 28
       const list = cityList.reduce((prev, cur) => {
31 29
         if (prev[cur.initial]) {
@@ -33,22 +31,36 @@ export default class Index extends Component {
33 31
         } else {
34 32
           prev[cur.initial] = [cur]
35 33
         }
36
-  
34
+
37 35
         return prev
38 36
       }, {})
39
-  
37
+
40 38
       this.setState({
41 39
         list
42 40
       })
43 41
     })
44 42
   }
45
- 
46
-  handleSelected(item) {
47
-    this.props.dispatchCitySelected(item).then(res => {
48
-      Taro.navigateBack({
49
-        delta: 1
43
+
44
+  handleSelected (item) {
45
+    if (this.$router.params.from === 'buildinglist' && item.id !== this.props.curCity.id) {
46
+      let pages = Taro.getCurrentPages()
47
+      let prevPage = pages[pages.length - 2]
48
+      prevPage.setData({
49
+        CityChanged: true
50
+      }, () => {
51
+        this.props.dispatchCitySelected({...item, CityChanged: true}).then(res => {
52
+          Taro.navigateBack({
53
+            delta: 1
54
+          })
55
+        })
50 56
       })
51
-    })
57
+    } else {
58
+      this.props.dispatchCitySelected(item).then(res => {
59
+        Taro.navigateBack({
60
+          delta: 1
61
+        })
62
+      })
63
+    }
52 64
   }
53 65
 
54 66
   handleSearch = (keywords) => {
@@ -62,7 +74,7 @@ export default class Index extends Component {
62 74
     })
63 75
   }
64 76
 
65
-  render() {
77
+  render () {
66 78
     const { curCity } = this.props
67 79
     const { searchList, list, keywords } = this.state
68 80
     const keys = Object.keys(list)

+ 3
- 3
src/pages/dichan/index.js Vedi File

@@ -53,9 +53,9 @@ export default class Index extends Component {
53 53
     const { filterOpt } = this.state
54 54
     const currentPage = page || this.state.pageIndex
55 55
     const payload = Object.assign({ pageSize, pageNumber: currentPage, }, filterOpt)
56
-    if (curCity.id) {
57
-      payload.cityId = curCity.id
58
-    }
56
+    // if (curCity.id) {
57
+    //   payload.cityId = curCity.id
58
+    // }
59 59
     return getItemList(payload)
60 60
   }
61 61
   render () {

+ 1
- 1
src/pages/project/list/filter/index.js Vedi File

@@ -111,7 +111,7 @@ export default class Index extends Component {
111 111
 
112 112
   handleLocationClick() {
113 113
     Taro.navigateTo({
114
-      url: `/pages/city/index`
114
+      url: `/pages/city/index?from=buildinglist`
115 115
     })
116 116
   }
117 117
 

+ 2
- 1
src/pages/project/list/index.js Vedi File

@@ -17,6 +17,7 @@ export default class Index extends Component {
17 17
   }
18 18
 
19 19
   state = {
20
+    CityChanged: false,
20 21
     list: [],
21 22
     hasMore: true,
22 23
     isEmpty: false,
@@ -56,7 +57,7 @@ export default class Index extends Component {
56 57
     const { filterOpt } = this.state
57 58
     const currentPage = page || this.state.pageIndex
58 59
     const payload = Object.assign({ pageSize, pageNumber: currentPage, }, filterOpt)
59
-    if (curCity.id) {
60
+    if (curCity.id && curCity.CityChanged !== undefined && curCity.CityChanged) {
60 61
       payload.cityId = curCity.id
61 62
     }
62 63
     return getItemList(payload)