aa
This commit is contained in:
@@ -1,35 +1,57 @@
|
||||
var xhr;
|
||||
var searchDistVue = new Vue({
|
||||
el: '#searchList',
|
||||
data: {
|
||||
searchDistricts: []
|
||||
}
|
||||
})
|
||||
$("#districtName").bind("input propertychange keyup" , function () {
|
||||
var keyword = $(this).val()
|
||||
if(xhr){
|
||||
xhr.abort()
|
||||
}
|
||||
if(keyword == ""){
|
||||
$('#districtList').empty()
|
||||
// $('.searchList #searchList').empty()
|
||||
return
|
||||
}
|
||||
xhr = $.ajax({
|
||||
url:'../auto/district',
|
||||
data:{keywords : keyword, cityName:$("#input_city").text(),max:20},
|
||||
dataType:'json',
|
||||
success:function (data){
|
||||
$('#searchHistoryDiv').hide();
|
||||
if(data.length == 0){
|
||||
$("#notFound").show()
|
||||
$('#districtList').empty();
|
||||
}else{
|
||||
$("#notFound").hide()
|
||||
var html = $('<ul>')
|
||||
$(data).each(function () {
|
||||
var li = $('<li>').attr("data-region", this.district).attr("data-name", this.name).attr("data-addr", this.address).attr("data-cityAddress", this.city)
|
||||
li.append('<a class="item-link item-content close-popup"><div class="item-inner"><div class="item-title-row"><div class="item-title">' + this.name + '<br><small>' + this.city + this.district + this.address + '</small></div></div></div></a>')
|
||||
html.append(li)
|
||||
})
|
||||
$('#districtList').empty().html(html)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
axios.get(BASE_PATH+"/rest/districts/search", {
|
||||
params: {
|
||||
keywords : keyword,
|
||||
cityName:$("#input_city").text(),
|
||||
max:20
|
||||
}
|
||||
}).then(function (response) {
|
||||
|
||||
var datas = response.data.data
|
||||
|
||||
$('.hotList').hide();
|
||||
$('.historyList').hide();
|
||||
if(datas == null || datas.length == 0){
|
||||
$("#notFound").show()
|
||||
searchDistVue.$data.searchDistricts = []
|
||||
//$('.searchList #searchList').empty();
|
||||
}else{
|
||||
|
||||
console.log(keyword +" "+datas.length);
|
||||
$("#notFound").hide()
|
||||
var dists = [];
|
||||
for(var i in datas){
|
||||
var o = datas[i]
|
||||
var map={city:o.city, region:o.district, name:o.name,address:o.address};
|
||||
dists.push(map);
|
||||
}
|
||||
|
||||
//searchDistVue.$set("searchDistricts") = dists;
|
||||
searchDistVue.$data.searchDistricts=dists
|
||||
$('.searchList').show();
|
||||
}
|
||||
}).catch(function (error) {
|
||||
alert(error)
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
function saveHistory(district) {
|
||||
var history = recover()
|
||||
@@ -66,24 +88,66 @@ $("body").delegate(".open-about02", "click", function () {
|
||||
$.toast("请选择城市")
|
||||
return false;
|
||||
}
|
||||
$('#searchHistoryDiv').show();
|
||||
$('.historyList').show();
|
||||
$("#notFound").hide();
|
||||
$('.hotList').show();
|
||||
$('.searchList').hide();
|
||||
addHotDistricts($("#input_city").val());
|
||||
addHistory();
|
||||
$.popup(".popup-about02")
|
||||
$("input").blur()
|
||||
});
|
||||
});
|
||||
|
||||
//添加热门小区
|
||||
function addHotDistricts(cityParam){
|
||||
axios.get(BASE_PATH+"/rest/districts/hotDistricts", {
|
||||
params: {
|
||||
city: cityParam,
|
||||
top:6
|
||||
}
|
||||
}).then(function (response) {
|
||||
|
||||
var datas = response.data.data
|
||||
if(datas.length>0){
|
||||
var dists = [];
|
||||
for(var i in datas){
|
||||
|
||||
var o = datas[i]
|
||||
var map={city:o.city, region:o.region, name:o.name};
|
||||
dists.push(map);
|
||||
}
|
||||
|
||||
new Vue({
|
||||
el: '#hotList',
|
||||
data: {
|
||||
hotDists: dists
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}).catch(function (error) {
|
||||
alert(error)
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
function addHistory(){
|
||||
var history = recover()
|
||||
if(history.length>0){
|
||||
var ul = '<ul>'
|
||||
var histories = [];
|
||||
$(history).each(function(){
|
||||
ul += '<li data-region="'+this.district+'" data-cityAddress="'+this.city+'" data-name="'+this.name+'" data-addr="'+this.address+'"><a class="item-link item-content close-popup"><div class="item-inner"><div class="item-title-row"><div class="item-title"><font>'+this.name+'</font><br><small>'+this.city+this.district+this.address+'</small></div></div></div></a></li>';
|
||||
var map={city:this.city, region:this.district, name:this.name};
|
||||
histories.push(map)
|
||||
})
|
||||
new Vue({
|
||||
el: '#districtList',
|
||||
data: {
|
||||
histories: histories
|
||||
}
|
||||
})
|
||||
ul += '</ul>'
|
||||
$('#districtList').empty().html(ul)
|
||||
|
||||
}else{
|
||||
$("#districtList").empty();
|
||||
$(".historyList #districtList").empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user