var dataParam = { finishBuildingDate:"", householdCount:"", cubagePercent:"", carSiteCount:"", virescencePercent:"", estateCharge:"", moreArea:"", developer:"", lat:"", lng:"", estateCompany:"" }; Vue.component('base-info-component', { template: ` `, data: function(){ return dataParam; }, methods: { loadDistrictInfo:function(){ axios.get("/rest/districts/detail", { params: { city: city, region:region, name: name } }).then(function (response) { var vo = response.data.data.detail var cityPrice = response.data.data.cityPrice var collected = response.data.data.collected if(cityPrice){ baseInfo.cityPrice = cityPrice } if(collected){ $(".collection02").show(); $(".collection01").hide(); }else{ $(".collection02").hide(); $(".collection01").show(); } $(".loadingBg").hide(); if(vo){ if(vo.avgPrice){ lat = vo.lat2; lng = vo.lng2; address = vo.address; baseInfo.city = vo.city baseInfo.region = vo.region baseInfo.address = vo.address; baseInfo.name = vo.name tags = vo.poiTags; if(vo.poiTags){ if(vo.poiTags.length>=3){ baseInfo.tags = vo.poiTags.slice(0,3); }else{ baseInfo.tags = vo.poiTags; } } baseInfo.avgPrice = vo.avgPrice; baseInfo.oneMonthUpDownRange = vo.oneMonthUpDownRange; if(vo.rank){ baseInfo.priceRate = vo.rank.substring(0, vo.rank.indexOf("/")); } baseInfo.cityPrice = cityPrice; var finishDate = "" if(vo.finishBuildingDate){ if(vo.finishBuildingDate.indexOf("~")!=-1){ finishDate = vo.finishBuildingDate.replace("年",""); }else{ finishDate = vo.finishBuildingDate.substring(0,4)+"年" } } dataParam.finishBuildingDate = finishDate; dataParam.householdCount = vo.householdCount; dataParam.cubagePercent = vo.cubagePercent; dataParam.carSiteCount = vo.carSiteCount; dataParam.virescencePercent = vo.virescencePercent; dataParam.estateCharge = vo.estateCharge; dataParam.moreArea = vo.moreArea; dataParam.developer = vo.developer; dataParam.estateCompany = vo.estateCompany; var starScore = response.data.data.starScore var starHtml = $("#distLevelDiv .star") if(starHtml.length>0){ if(starScore && starScore > 0){ var html = getStarContent(starScore); $("#distLevelDiv .star").html(html); var regionIndex = response.data.data.regionIndex var districtPoiCount = response.data.data.districtPoiCount var schoolIndex = response.data.data.schoolIndex var arroundIndex = response.data.data.arroundIndex var indexs = [] indexs.push(vo.index); indexs.push(regionIndex); indexs.push(schoolIndex); indexs.push(arroundIndex); /* 小区评级 */ loadDistrictLevel(indexs); }else{ $("#distLevelDiv").hide() } }else{ var ht = $("#arroundLevelDiv") if(ht.length>0){ var score = response.data.data.arroundIndexStar if(score > 0){ var html = getStarContent(score); $("#arroundLevelDiv .star").html("生活便利 "+html); }else{ $("#arroundLevelDiv").hide(); } } } }else{ $("#noDataDiv").show() baseInfo.name = "小区详情" } } }).catch(function (error) { alert(error) console.log(error); }); } },mounted:function(){ this.loadDistrictInfo(); } }) function getStarContent(starScore){ var mod = starScore - parseInt(starScore); var num = parseInt(starScore); var nn = 5 - num; var html = "" for(var i=1;i<=num;i++){ html +="" } if(mod==0.5){ html +="" } if(nn >0){ if(mod==0.5){ nn = nn -1 } for(var j=1;j<=nn;j++){ html +="" } } return html; }