首页定位国外城市处理

This commit is contained in:
xuhe@fangjia.com
2018-05-09 17:20:50 +08:00
parent 9c94fd1592
commit ba0f452bdc
+66 -36
View File
@@ -1248,48 +1248,60 @@ function getPosition(){
plus.geolocation.getCurrentPosition(function(p){
if(p.address.city==undefined){
city = "上海";
$("#input_city").text(city);
initData();
}else{
address = p.address.street;
province = p.address.province;
city = p.address.city;
region = p.address.district;
lng = p.coords.longitude;//获取到当前位置的经度
lat = p.coords.latitude;//获取到当前位置的纬度;
oriLng = p.coords.longitude;
oriLat = p.coords.latitude;
//alert("4"+oriLng);
if(city){
city = formatBaiduCity(city);
}
if(region.endWith("区")){
region = region.substring(0, region.length-1);
}
oriRegion = region;
oriCity = city;
$("#input_city").text(city);
axios.get("/rest/index/isChinaCity", {
params: {
city: city
}
})
.then(function (response) {
if(response.data.data.status==1){
address = p.address.street;
province = p.address.province;
region = p.address.district;
lng = p.coords.longitude;//获取到当前位置的经度
lat = p.coords.latitude;//获取到当前位置的纬度;
oriLng = p.coords.longitude;
oriLat = p.coords.latitude;
if(region.endWith("区")){
region = region.substring(0, region.length-1);
}
oriRegion = region;
oriCity = city;
}else{
city = "上海";
$("#input_city").text(city);
initRegionSelect(city);
localStorage.setItem("init_city", city);
//addLocation(lat,lng);
initBaseInfo(city,"","",0,0);
$("#ShangHaiDiv").show();
$("#otherCityDiv").hide();
}
initData();
})
.catch(function (error) {
setTimeout(function(){
mui.init();
mui.openWindow({
url: 'error.html',
id:'error.html',
extras:{
//扩展参数
}
});
},10000)
console.log(error);
});
}
localStorage.setItem("init_city", city);
//addLocation(lat,lng);
$(".nowCity").text(city);
/*city="北京";
region="";
$("#input_city").text("北京");
getDistrictList($("#input_city").text(),0,0,"",6,0,0,"");*/
initBaseInfo(city,region,address,lat,lng);
if(city!="上海"){
//$(".content").removeClass("pull-to-refresh-content");
$.destroyPullToRefresh(".content")
initRegionSelect(city);
$("#ShangHaiDiv").hide();
$("#otherCityDiv").show();
}else{
$.initPullToRefresh(".content")
$("#ShangHaiDiv").show();
$("#otherCityDiv").hide();
}
}, function(e){
city = "上海";
$("#input_city").text(city);
@@ -1308,6 +1320,24 @@ function getPosition(){
);
}
function initData(){
$("#input_city").text(city);
localStorage.setItem("init_city", city);
//addLocation(lat,lng);
$(".nowCity").text(city);
initBaseInfo(city,region,address,lat,lng);
if(city!="上海"){
$.destroyPullToRefresh(".content")
initRegionSelect(city);
$("#ShangHaiDiv").hide();
$("#otherCityDiv").show();
}else{
$.initPullToRefresh(".content")
$("#ShangHaiDiv").show();
$("#otherCityDiv").hide();
}
}
/* 获取#region字数,截取#region前4字,并添加... */
var baseInfo = new Vue({
@@ -1326,7 +1356,7 @@ var baseInfo = new Vue({
function initBaseInfo(city,region,address,lat,lng){
//显示附近地址
if(address!=""){
if(address!="" || address!=undefined){
var nearAddressParam = address;
var length = address.length;
var textStr = "";