From 9660a92c798b996073b47c2f27d1fdff1f02934a Mon Sep 17 00:00:00 2001 From: "xuhe@fangjia.com" Date: Thu, 15 Mar 2018 18:23:06 +0800 Subject: [PATCH] aa --- fangija-zsyf/css/main.css | 2 +- fangija-zsyf/yfindex.html | 149 ++++++++++++++++++++++++-------------- 2 files changed, 94 insertions(+), 57 deletions(-) diff --git a/fangija-zsyf/css/main.css b/fangija-zsyf/css/main.css index 8067a11..fd42d82 100644 --- a/fangija-zsyf/css/main.css +++ b/fangija-zsyf/css/main.css @@ -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%;} diff --git a/fangija-zsyf/yfindex.html b/fangija-zsyf/yfindex.html index 9d6ed82..aa60b81 100644 --- a/fangija-zsyf/yfindex.html +++ b/fangija-zsyf/yfindex.html @@ -94,10 +94,10 @@ 房价查询 -
+
@@ -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 += ''; $("#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) { ''; } 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 += '
'+dataObj[i].title+ '
'+ - '同意'+ - '
'+ - '
反对'+ - '
V.S
'; + '同意'+ + ''+ + '
反对'+ + '
V.S'; } } } } + 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);