Files
youfang-app/fangija-zsyf/views/component/baseInfoComponent.js
T
2018-07-04 09:48:25 +08:00

329 lines
9.6 KiB
JavaScript

var dataParam = {
finishBuildingDate:"",
householdCount:"",
cubagePercent:"",
carSiteCount:"",
virescencePercent:"",
estateCharge:"",
moreArea:"",
developer:"",
lat:"",
lng:"",
estateCompany:""
};
Vue.component('base-info-component', {
template: `
<ul>
<li>
<a class="item-content">
<div class="item-inner" style="padding-top:0.75rem;padding-bottom:0.25rem;">
<div class="item-title-row">
<div class="item-title">基本信息</div>
</div>
</div>
</a>
</li>
<li>
<a class="item-content">
<div class="item-inner" style="padding-top:0;">
<div class="item-title-row" style="width:100%;">
<div class="item-title row">
<div class="col-50">
<p>
<label>竣工年代:</label>
<span v-if="finishBuildingDate">{{finishBuildingDate}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>容<small class="spacing01a">&nbsp;</small>积<small class="spacing01a">&nbsp;</small>率:</label>
<span v-if="cubagePercent">{{cubagePercent}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>绿<small class="spacing01a">&nbsp;</small>化<small class="spacing01a">&nbsp;</small>率:</label>
<span v-if="virescencePercent">{{virescencePercent}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>主力面积:</label>
<span v-if="moreArea">{{moreArea}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>开<small class="spacing01a">&nbsp;</small>发<small class="spacing01a">&nbsp;</small>商:</label>
<span class="span01" v-if="developer">{{developer}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>物业公司:</label>
<span class="span01" v-if="estateCompany">{{estateCompany}}</span>
<span v-else>暂无</span>
</p>
</div>
<div class="col-50">
<p>
<label>总<small class="spacing01a">&nbsp;</small>户<small class="spacing01a">&nbsp;</small>数:</label>
<span>{{householdCount}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>停<small class="spacing01a">&nbsp;</small>车<small class="spacing01a">&nbsp;</small>位:</label>
<span v-if="carSiteCount">{{carSiteCount}}</span>
<span v-else>暂无</span>
</p>
<p>
<label>物<small class="spacing01a">&nbsp;</small>业<small class="spacing01a">&nbsp;</small>费:</label>
<span v-if="estateCharge">{{estateCharge}}元/㎡/月</span>
<span v-else>暂无</span>
</p>
</div>
</div>
</div>
</div>
</a>
</li>
</ul>
`,
data: function(){
return dataParam;
},
methods: {
loadDistrictInfo:function(){
axios.get("/rest/districts/detail", {
params: {
rid:rid,
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
var sr = response.data.data.substitutionResult
var hs = response.data.data.houseSubstitution;
var house = response.data.data.houseInfo;
if(hs && sr){
addSubstitution(sr, hs, house);
addAdvertisement();
}
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) {
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 +="<i class='icon icon-star01'></i>"
}
if(mod==0.5){
html +="<i class='icon icon-star02'></i>"
}
if(nn >0){
if(mod==0.5){
nn = nn -1
}
for(var j=1;j<=nn;j++){
html +="<i class='icon icon-star'></i>"
}
}
return html;
}
function addSubstitution(sr, hs, house){
var s = "购买 "+sr.name;
if(sr.intentionArea==0){
s += "50平米以下"
}else if(sr.intentionArea==1){
s += "50-70平米"
}else if(sr.intentionArea==2){
s += "70-90平米"
}else if(sr.intentionArea==3){
s += "90-110平米"
}else if(sr.intentionArea==4){
s += "110-150平米"
}else if(sr.intentionArea==5){
s += "150-200平米"
}else if(sr.intentionArea==6){
s += "200-300平米"
}else if(sr.intentionArea==7){
s += "300平米以上"
}
s += "的房子,总价预计约为"
if(sr.intentionArea==0){
s += parseInt(sr.maxTotalPrice/10000)+"万以内"
}else if(sr.intentionArea==7){
s += parseInt(sr.minTotalPrice/10000)+"万以上"
}else{
s += parseInt(sr.minTotalPrice/10000)+"-"+parseInt(sr.maxTotalPrice/10000)+"万"
}
var soufu_min=((sr.minTotalPrice * hs.shoufu/100)/10000)
var soufu_max=((sr.maxTotalPrice * hs.shoufu/100)/10000)
var initPrice = 0;
if(hs.substitutionType==1){
initPrice = hs.curMoney + house.totalPrice/10000;
}else if(hs.substitutionType==0){
initPrice = hs.curMoney
}
if(initPrice < soufu_min){
s +=",资金缺口约为"+Math.abs(Math.round(((soufu_min-initPrice)-(soufu_max-initPrice))*100)/100)+"万";
}else if(initPrice > soufu_min && initPrice < soufu_max){
s += ",资金缺口约为"+Math.abs(Math.round((soufu_max-initPrice)*100)/100)+"万";
}else if(initPrice > soufu_max){
s += "。";
}
// <#if advertisement?? && advertisement.content?? && advertisement.content?length gt 0>
// <a <#if advertisement.link?? && advertisement.link?length gt 0>onclick="openUrl('${basePath}/message/openView?url=${basePath}/mad/adUrlLoad?adid=${advertisement.id!?c}')"</#if> ><#if advertisement.content??>${advertisement.content!}</#if><i class="icon icon-right icon-right01"></i></a></p>
// </#if>
$("#suggestDiv p").text(s);
$("#suggestDiv").show();
}
function addAdvertisement(){
axios.get("/rest/changeHouse/position", null).then(function (response) {
var vo = response.data.data
if(vo!=null){
$('#adBox').show();
//如果link有值,添加调整路径
if(vo.link!=null && vo.link.length>0 && vo.content!=null && vo.content.length>0){
$('#adBox').html(vo.content + "<i class='icon icon-right icon-right01'></i>");
$("#adBox").click(function(){
clicked('../../views/webview_embed.html', true,false,{},{url:vo.link})
})
}
}
}).catch(function (error) {
console.log(error);
});
}