This commit is contained in:
xuhe@fangjia.com
2018-03-15 18:23:06 +08:00
parent 44dfc14e01
commit 9660a92c79
2 changed files with 94 additions and 57 deletions
+1 -1
View File
@@ -693,7 +693,7 @@ input::-webkit-input-placeholder{
.topic .topicContent .topicContent_center div .icon.icon-menu04a{background:url(../images/icon-menu04a.png) no-repeat center center;background-size:100%;}
.topic .topicContent .topicContent_center div .icon.icon-menu05a{background:url(../images/icon-menu05a.png) no-repeat center center;background-size:100%;}
.topic .topicContent .topicContent_center.home div{width:25%;border-left:none;}
.topic .topicContent .topicContent_center.home div{width:33%;border-left:none;}
.topic .topicContent .topicContent_center.home div .icon{width:45px;height:45px;display:block;margin:0 auto;}
.topic .topicContent .topicContent_center.home div .icon.icon-home01{background:url(../images/icon-home01.png) no-repeat center center;background-size:100%;}
+93 -56
View File
@@ -94,10 +94,10 @@
<i class="icon icon-home03"></i>
<span>房价查询</span>
</div>
<div class="open-about02">
<!--<div class="open-about02">
<i class="icon icon-home04"></i>
<span>房租查询</span>
</div>
</div>-->
</div>
</div>
</div>
@@ -1553,8 +1553,17 @@ function getPosition(){
);
}
/* 获取#region字数,截取#region前4字,并添加... */
/*city="上海"
init();*/
city="上海"
init();
var baseInfo = new Vue({
el: '#baseInfo',
data: {
region : "",
topMonth:"",
momAvgPrice: "",
momRate: ""
}
})
function init(){
//显示附近地址
var nearAddressParam = address;
@@ -1579,19 +1588,16 @@ function init(){
}
})
.then(function (response) {
new Vue({
el: '#baseInfo',
data: {
region: response.data.data.region,
topMonth:response.data.data.topMonth,
momAvgPrice: response.data.data.momAvgPrice,
momRate: response.data.data.momRate
}
})
new Vue({
baseInfo.region = response.data.data.region;
baseInfo.topMonth = response.data.data.topMonth;
baseInfo.momAvgPrice = response.data.data.momAvgPrice;
baseInfo.momRate = response.data.data.momRate;
regionChange(response.data.data.region);
new Vue({
el: '#todayDate',
data: {
todayDate:response.data.data.todayDate
todayDate : response.data.data.todayDate
}
})
$("#region").picker({
@@ -1606,8 +1612,8 @@ function init(){
}
]
});
regionChange();
if(response.data.data.dtos.length==0){
$("#nearAddress").css("display",none);
$("#nearDistricts").css("display",none);
@@ -1625,16 +1631,17 @@ function init(){
html += '</div>';
$("#nearDistricts").html(html);
$("#nearbyDistrictList").css("width",(7.5*response.data.data.dtos.length)+"rem");
})
.catch(function (error) {
console.log(error);
});
initNews();
}
function initNews(){
//资讯列表
axios.get(BASE_PATH+"/rest/news/list", {
params: {
city: cityParam,
city: $("input_city").val(),
page:1
}
})
@@ -1653,8 +1660,7 @@ function init(){
console.log(error);
});
}
$("#region").click(function(e){
/*$("#region").click(function(e){
$(document).click(function(e){
alert($("#region").val());
var region_copy = $("#region_copy").val();
@@ -1664,9 +1670,9 @@ $("#region").click(function(e){
changeRegion();
}
})
})
})*/
$("#regionStatusButton").click(function(e){
/*$("#regionStatusButton").click(function(e){
var region_copy = $("#region_copy").val();
var value = $(".picker-selected").text();
alert($("#region").val());
@@ -1674,33 +1680,60 @@ $("#regionStatusButton").click(function(e){
alert($("#region").val());
changeRegion();
}
})
})*/
$("body").delegate("#regionStatusButton", "click", function () {
var region_copy = $("#region_copy").val();
var value = $(".picker-selected").text();
if(region_copy != value && value!="" && value!=null){
changeRegion();
}
});
$("body").delegate(".icon-light-red", "click", function () {
var id = $(this).attr("data-val");
doVote(id,0);
});
$("body").delegate(".icon-light-grey", "click", function () {
var id = $(this).attr("data-val");
doVote(id,1);
});
function doVote(id,flag){
axios.get(BASE_PATH+"/rest/news/vote", {
params: {
newsId: id,
type:flag
}
})
.then(function (response) {
$("#newsList").html('');
initNews();
})
.catch(function (error) {
console.log(error);
});
}
function changeRegion(){
axios.get(BASE_PATH+"/houseApi/home", {
params: {
city: $("#input_city").text(),
region:$("#region").val(),
lat:0,
lng:0
}
})
.then(function (response) {
new Vue({
el: '#baseInfo',
data: {
region: response.data.data.region,
topMonth:response.data.data.topMonth,
momAvgPrice: response.data.data.momAvgPrice,
momRate: response.data.data.momRate
}
})
$("#region_copy").val(response.data.data.region);
})
.catch(function (error) {
console.log(error);
});
params: {
city: $("#input_city").text(),
region:$("#region").val(),
lat:0,
lng:0
}
})
.then(function (response) {
baseInfo.region = response.data.data.region;
baseInfo.topMonth = response.data.data.topMonth;
baseInfo.momAvgPrice = response.data.data.momAvgPrice;
baseInfo.momRate = response.data.data.momRate;
regionChange(response.data.data.region);
$("#region_copy").val(response.data.data.region);
})
.catch(function (error) {
console.log(error);
});
}
/* 页面底部无限加载事件 */
$.init();
@@ -1788,16 +1821,21 @@ function addItems(number, lastIndex) {
'</div></div></li></ul></div></div></div>';
}
if(dataObj[i].type=="投票"){
var voteFavorCount = dataObj[i].voteFavorCount;
var voteNoFavorCount = dataObj[i].voteNoFavorCount;
var voteFavorCountRate = (voteFavorCount/(voteFavorCount+voteNoFavorCount)).toFixed(2);
var voteNoFavorCountRate = 1-voteFavorCountRate;
html += '<div class="card cardInfo cardInfo03"><div class="card-header">'+dataObj[i].title+
'</div><div class="card-content"><div class="card-content-inner row"><div class="vote01 col-50">'+
'<i class="icon icon-light-grey icon-light-red"></i><span>同意</span>'+
'<font style="width:62%;"></font><label>198票&nbsp;&nbsp;62%</label></div>'+
'<div class="vote02 col-50"><i class="icon icon-light-grey"></i><span>反对</span>'+
'<font style="width:38%;"></font><label>121票&nbsp;&nbsp;38%</label></div><em>V.S</em></div></div></div>';
'<i class="icon icon-light-red" data-val="'+dataObj[i].id+'"></i><span>同意</span>'+
'<font style="width:'+voteFavorCountRate*100+'%;"></font><label>'+voteFavorCount+'票&nbsp;&nbsp;'+voteFavorCountRate*100+'%</label></div>'+
'<div class="vote02 col-50"><i class="icon icon-light-grey" data-val="'+dataObj[i].id+'"></i><span>反对</span>'+
'<font style="width:'+voteNoFavorCountRate*100+'%;"></font><label>'+voteNoFavorCount+'票&nbsp;&nbsp;'+voteNoFavorCountRate*100+'%</label></div><em>V.S</em></div></div></div>';
}
}
}
}
if(dataObj.length<=(lastIndex + number)){
$(".infinite-scroll-preloader").hide();
}
@@ -1810,7 +1848,6 @@ function addItems(number, lastIndex) {
}
// 上次加载的序号
var lastIndex = 5;
// 注册'infinite'事件处理函数
@@ -1831,9 +1868,9 @@ $(document).on('infinite', '.infinite-scroll-bottom',function() {
}, 500);
});
function regionChange(){
var text = $("#region").val();
var length = $("#region").val().length;
function regionChange(region){
var text = region;
var length = region.length;
var textStr = "";
if(length > 4){
textStr = text.substr(0,4);