223 lines
7.3 KiB
JavaScript
223 lines
7.3 KiB
JavaScript
var cityPotentialRankingData = {cityPotentialRankingList:[]};
|
|
|
|
Vue.component('city_potential_ranking',{
|
|
template:'<div class="list-block media-list cityList">'+
|
|
'<ul>'+
|
|
'<li>'+
|
|
'<a class="item-content">'+
|
|
'<div class="item-inner">'+
|
|
'<div class="item-subtitle row">'+
|
|
'<div class="col-5"> </div>'+
|
|
'<div class="col-20">城市</div>'+
|
|
'<div class="col-25">近1年涨跌幅</div>'+
|
|
'<div class="col-25">潜力指数</div>'+
|
|
'<div class="col-20"></div>'+
|
|
'</div>'+
|
|
'</div>'+
|
|
'</a>'+
|
|
'</li>'+
|
|
'<li v-for="(cp,index) in cityPotentialRankingList">'+
|
|
'<a class="item-content">'+
|
|
'<div class="item-inner">'+
|
|
'<div class="item-subtitle row">'+
|
|
'<div class="col-5">{{index+1}}</div>'+
|
|
'<div class="col-20">{{cp.city}}</div>'+
|
|
'<div class="col-25">'+
|
|
'<em class="up">{{!cp.oneYearUpDownRange||cp.oneYearUpDownRange==""?"暂无":Math.abs(cp.oneYearUpDownRange*100).toFixed(2)+"%"}}<i class="icon" v-bind:class="[cp.oneYearUpDownRange>0?"icon-arrow-red":"",cp.oneYearUpDownRange<0?"icon-arrow-green":""]"></i></em>'+
|
|
'</div>'+
|
|
'<div class="col-25">'+
|
|
'<span class="star">'+
|
|
'<i v-for="n in cp.starNum" class="icon icon-star01"></i>'+
|
|
'<i v-for="n in cp.halfStarNum" class="icon icon-star02"></i>'+
|
|
'<i v-for="n in cp.noneStarNum" class="icon icon-star"></i>'+
|
|
'</span>'+
|
|
'</div>'+
|
|
'<div class="col-20">'+
|
|
'<i class="button collection collection02 confirm-ok" v-on:click="abolish(cp.city,$event,1)" v-if="cp.follow" >取消</i>'+
|
|
'<i class="button theme collection collection01 confirm-ok" v-on:click="follow(cp.city,$event,0)" v-else>关注</i>'+
|
|
'</div>'+
|
|
'</div>'+
|
|
'</div>'+
|
|
'</a>'+
|
|
'</li>'+
|
|
'</ul>'+
|
|
'</div>',
|
|
data:function(){
|
|
return cityPotentialRankingData;
|
|
},
|
|
methods:{
|
|
loadCityPotentialRanking:function(){
|
|
axios.get("/rest/quotations/potentialUpTopInfos").then(function(response){
|
|
list = response.data.data;
|
|
$(list).each(function(i){
|
|
var index = this.index;
|
|
var totalHalfStar = Math.round(Math.round(index/5)/2) //总半星
|
|
var starNum = Math.floor(totalHalfStar/2) //全星
|
|
var halfStarNum = totalHalfStar%2 //半星
|
|
var noneStarNum = 5-starNum-halfStarNum //空星
|
|
this.starNum = starNum;
|
|
this.halfStarNum = halfStarNum;
|
|
this.noneStarNum = noneStarNum;
|
|
})
|
|
cityPotentialRankingData.cityPotentialRankingList = response.data.data;
|
|
|
|
}).catch(function(error){
|
|
console.log(error)
|
|
})
|
|
},
|
|
follow:function(city,event,type){
|
|
if(localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == ""){
|
|
clicked('/views/user/passLogin.html',true,false,{},{},function(){
|
|
if(localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == ""){
|
|
|
|
}else{
|
|
$.confirm('您确定要关注'+city+"?", function () {
|
|
axios.get("/rest/quotations/collectCity",{params:{city:city, type:type}}).then(function(response){
|
|
|
|
var msg = response.data.message;
|
|
if(msg != "取消关注成功" && msg != "关注成功"){
|
|
$.toast(msg);
|
|
}else{
|
|
//$(event.target).parent().children().removeClass("dn");
|
|
//$(event.target).addClass("dn");
|
|
var rankList = cityPotentialRankingData.cityPotentialRankingList
|
|
|
|
if(rankList && rankList.length>0){
|
|
for(var i in rankList){
|
|
var dd = rankList[i];
|
|
if(dd.city == city){
|
|
if(type == 0){
|
|
dd.follow = true;
|
|
}else{
|
|
dd.follow = false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
plus.webview.getWebviewById('views/house/houseDetail.html').reload();
|
|
plus.webview.getWebviewById('views/house/houseManageList.html').reload();
|
|
plus.webview.getWebviewById('views/user/userInfo.html').reload();
|
|
reloadMyFocus()
|
|
reloadCityIncreaseRanking()
|
|
//cityDetaiVue.$data.citys.push(city);
|
|
}
|
|
}).catch(function(error){
|
|
console.log(error)
|
|
})
|
|
});
|
|
}
|
|
})
|
|
}else{
|
|
$.confirm('您确定要关注'+city+"?", function () {
|
|
axios.get("/rest/quotations/collectCity",{params:{city:city, type:type}}).then(function(response){
|
|
var msg = response.data.message;
|
|
if(msg != "取消关注成功" && msg != "关注成功"){
|
|
$.toast(msg);
|
|
}else{
|
|
//$(event.target).parent().children().removeClass("dn");
|
|
//$(event.target).addClass("dn");
|
|
|
|
|
|
var rankList = cityPotentialRankingData.cityPotentialRankingList
|
|
|
|
if(rankList && rankList.length>0){
|
|
for(var i in rankList){
|
|
var dd = rankList[i];
|
|
if(dd.city == city){
|
|
if(type == 0){
|
|
dd.follow = true;
|
|
}else{
|
|
dd.follow = false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
reloadMyFocus()
|
|
reloadCityIncreaseRanking()
|
|
if(type == 0){
|
|
var curDatas = cityDetaiVue.$data.citys
|
|
if(curDatas && curDatas.length>=0){
|
|
if(!IsInArray(curDatas, city)){
|
|
cityDetaiVue.$data.citys.push(city);
|
|
}
|
|
}
|
|
}
|
|
//plus.webview.getWebviewById('views/user/userInfo.html').reload();
|
|
}
|
|
}).catch(function(error){
|
|
console.log(error)
|
|
})
|
|
});
|
|
}
|
|
|
|
},
|
|
abolish:function(city,event,type){
|
|
$.confirm("您确定要取消关注?", function () {
|
|
axios.get("/rest/quotations/collectCity",{params:{city:city, type:type}}).then(function(response){
|
|
// $(event.target).parent().children().removeClass("dn");
|
|
// $(event.target).addClass("dn");
|
|
|
|
var rankList = cityPotentialRankingData.cityPotentialRankingList
|
|
|
|
if(rankList && rankList.length>0){
|
|
for(var i in rankList){
|
|
var dd = rankList[i];
|
|
if(dd.city == city){
|
|
if(type == 0){
|
|
dd.follow = true;
|
|
}else{
|
|
dd.follow = false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
reloadMyFocus()
|
|
reloadCityIncreaseRanking()
|
|
var da = cityDetaiVue.$data.citys
|
|
if(da && da.length>0){
|
|
var index = da.indexOf(city)
|
|
if(index>0){
|
|
da.splice(index, 1)
|
|
cityDetaiVue.$data.citys = da;
|
|
}
|
|
}
|
|
//plus.webview.getWebviewById('views/user/userInfo.html').reload();
|
|
}).catch(function(error){
|
|
console.log(error)
|
|
})
|
|
});
|
|
}
|
|
},
|
|
mounted:function(){
|
|
this.loadCityPotentialRanking();
|
|
}
|
|
})
|
|
|
|
function reloadCityPotentialRanking(){
|
|
axios.get("/rest/quotations/potentialUpTopInfos").then(function(response){
|
|
list = response.data.data;
|
|
$(list).each(function(i){
|
|
var index = this.index;
|
|
var totalHalfStar = Math.round(Math.round(index/5)/2) //总半星
|
|
var starNum = Math.floor(totalHalfStar/2) //全星
|
|
var halfStarNum = totalHalfStar%2 //半星
|
|
var noneStarNum = 5-starNum-halfStarNum //空星
|
|
this.starNum = starNum;
|
|
this.halfStarNum = halfStarNum;
|
|
this.noneStarNum = noneStarNum;
|
|
})
|
|
cityPotentialRankingData.cityPotentialRankingList = response.data.data;
|
|
|
|
|
|
|
|
|
|
}).catch(function(error){
|
|
console.log(error)
|
|
})
|
|
}
|