|
@@ -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)
|