5
5
leave-active-class =" animated slideOutRight"
6
6
>
7
7
<div class =" m-box-model m-pos-f p-location" >
8
- <SearchBar
9
- v-model =" keyword"
10
- :back =" goBack"
11
- />
8
+ <SearchBar v-model =" keyword" :back =" goBack" />
12
9
13
10
<main >
14
11
<div v-if =" showHot" >
44
41
</ul >
45
42
</div >
46
43
</div >
47
- <div
48
- v-else
49
- class =" m-box-model"
50
- >
44
+ <div v-else class =" m-box-model" >
51
45
<div
52
46
v-for =" (city, index) in cities"
53
47
:key =" `search-${city}-${index}`"
63
57
</template >
64
58
65
59
<script >
66
- import SearchBar from ' @/components/common/SearchBar.vue'
67
- import _ from ' lodash'
60
+ import { parseSearchTree } from ' @/util/location'
68
61
import * as api from ' @/api/bootstrappers.js'
62
+ import SearchBar from ' @/components/common/SearchBar.vue'
69
63
70
64
export default {
71
65
name: ' Location' ,
72
66
components: { SearchBar },
73
67
props: {
74
- show: {
75
- type: Boolean ,
76
- default: true ,
77
- },
78
- isComponent: {
79
- type: Boolean ,
80
- default: false ,
81
- },
68
+ show: { type: Boolean , default: true },
69
+ isComponent: { type: Boolean , default: false },
82
70
},
83
71
data () {
84
72
return {
@@ -142,6 +130,7 @@ export default {
142
130
},
143
131
methods: {
144
132
goBack () {
133
+ this .keyword = ' '
145
134
this .isComponent
146
135
? this .$emit (' close' , this .currentPos )
147
136
: this .$router .go (- 1 )
@@ -165,12 +154,12 @@ export default {
165
154
})
166
155
: []
167
156
},
168
- searchCityByName: _ . debounce ( function () {
157
+ searchCityByName () {
169
158
api .searchCityByName (this .keyword ).then (({ data = [] }) => {
170
159
this .originCities = data
171
160
this .cities = this .formatCities (data)
172
161
})
173
- }, 450 ),
162
+ },
174
163
getCurrentPosition () {
175
164
this .loading = true
176
165
this .hotPos = null
@@ -204,7 +193,7 @@ export default {
204
193
const city = this .cities [index].split (' ,' ).pop ()
205
194
api .getGeo (city .replace (/ [\s \uFEFF\xA0 ] + / g , ' ' )).then (data => {
206
195
this .loading = false
207
- data .label = this .originCities [index].tree . name
196
+ data .label = parseSearchTree ( this .originCities [index].tree )
208
197
this .currentPos = data
209
198
this .$nextTick (this .goBack )
210
199
})
0 commit comments