Skip to content

Commit 1bd3397

Browse files
authored
Merge pull request #536 from lllllxt/dev
修复无法搜索部分地点: 如 汉堡王(北大街店)
2 parents 08d60c5 + 1f5c409 commit 1bd3397

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib/components/amap-search-box.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export default {
100100
keyword: this.default || '',
101101
tips: [],
102102
selectedTip: -1,
103-
loaded: false
103+
loaded: false,
104+
adcode: null
104105
};
105106
},
106107
mounted() {
@@ -137,6 +138,13 @@ export default {
137138
search() {
138139
this.tips = [];
139140
if (!this._placeSearch) return;
141+
let city = null;
142+
if (this.searchOption.citylimit && this.searchOption.city) {
143+
city = this.searchOption.city;
144+
} else {
145+
city = this.adcode;
146+
}
147+
this._placeSearch.setCity(city || this.searchOption.city);
140148
this._placeSearch.search(this.keyword, (status, result) => {
141149
if (result && result.poiList && result.poiList.count) {
142150
let {poiList: {pois}} = result;
@@ -152,16 +160,19 @@ export default {
152160
});
153161
},
154162
changeTip(tip) {
163+
this.adcode = tip.adcode;
155164
this.keyword = tip.name;
156165
this.search();
157166
},
158167
selectTip(type) {
159168
if (type === 'up' && this.selectedTip > 0) {
160169
this.selectedTip -= 1;
161170
this.keyword = this.tips[this.selectedTip].name;
171+
this.adcode = this.tips[this.selectedTip].adcode;
162172
} else if (type === 'down' && this.selectedTip + 1 < this.tips.length) {
163173
this.selectedTip += 1;
164174
this.keyword = this.tips[this.selectedTip].name;
175+
this.adcode = this.tips[this.selectedTip].adcode;
165176
}
166177
}
167178
}

0 commit comments

Comments
 (0)