From 91836c5eef4089e76726e2b09fe24bd3f24dc9f0 Mon Sep 17 00:00:00 2001 From: raoyanhui Date: Fri, 4 May 2018 00:12:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=87=BA=E5=94=AE=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fangija-zsyf/js/saleAnalysis/saleAnalysis.js | 106 +++++++++++++++---- 1 file changed, 88 insertions(+), 18 deletions(-) diff --git a/fangija-zsyf/js/saleAnalysis/saleAnalysis.js b/fangija-zsyf/js/saleAnalysis/saleAnalysis.js index d2c0a6f..8cc15a7 100644 --- a/fangija-zsyf/js/saleAnalysis/saleAnalysis.js +++ b/fangija-zsyf/js/saleAnalysis/saleAnalysis.js @@ -3,6 +3,8 @@ var houseId; var disName; var disRegion; var disCity; +var _evalDate; +var totalPricePart; var houseInfo = new Vue({ el: '#houseInfo', @@ -30,7 +32,7 @@ var houseInfo = new Vue({ } }) -/* 增长率及收益 */ +/* 增长率及收益-打开 */ $(document).on('click','.open-modal01', function () { $.closeModal('.my-popover01'); $('.modal01').show(); @@ -41,32 +43,100 @@ $(document).on('click','.open-modal01', function () { $(document).on('click','.modal01 .cancel_btn', function () { $('.modal01').hide(); $('.modal01-overlay').hide(); - window.location.reload(); + //清空对于的输入框 + $("#input_time").val(''); + $("#input_price").val(''); }); /* 增长率及收益-关闭 */ $(document).on('click','.modal01 .close', function () { $('.modal01').hide(); $('.modal01-overlay').hide(); - window.location.reload(); + //清空对于的输入框 + $("#input_time").val(''); + $("#input_price").val(''); }); /* 增长率及收益-确定 */ $(document).on('click','.modal01 .confirm_btn', function () { var a = $("#input_time").val(); var b = $("#input_price").val(); + //_evalDate 已经是由date转换成long类型了 + var evalDate = _evalDate; + var d = new Date($("#input_time").val()).getTime(); + var _houseId = houseId; if(a == ""){ - $.toast("请选择购入时间"); + $.toast("购入时间不能为空"); return false; - }else if(b == ""){ - $.toast("请输入购入价格"); + } + else if(b == ""){ + $.toast("购入价格不能为空"); return false; - }else{ - $(".rateBox01").hide(); - $(".rateBox02").show(); - $('.modal').hide(); - $('.modal01').hide(); - $('.modal01-overlay').hide(); + } + else if(b <= 0){ + $.toast("购入价格大于0"); + return false; + } + else if(d > evalDate){ + $.toast("购入时间不能大于估价时间"); + return false; + } + var days = evalDate - d; + var year = parseInt(days / (1000 * 60 * 60 * 24) / 365) + 1; + var basePrice = totalPricePart; + var up = Number(basePrice) * Math.pow(2, year); + var down = Number(basePrice) * Math.pow(2, -year); + if(Number($("#input_price").val()) > up || Number($("#input_price").val()) < down){ + $('.modal01').hide(); + $.modal({ + title: '购入价格与实际情况偏差较大,是否继续?', + buttons: [ + { + text: '否,修改', + onClick: function() { + $("#input_price").focus(); + $('.modal').remove(); + $('.modal01').show(); + } + }, + { + text: '继续', + onClick: function() { + axios.post(BASE_PATH + "/rest/saleAnalysis/updateEvaluation", + { + houseId: houseId, + purchaseDate: $("#input_time").val(), + purchasePrice: $("#input_price").val() + }).then(function (response) { + var status = response.data.status; + if(status){ + window.location.reload(); + }else{ + $.toast(response.data.message); + } + }).catch(function (error) { + console.log(error); + }); + } + } + ] + }) + } else{ + axios.post(BASE_PATH + "/rest/saleAnalysis/updateEvaluation", + { + houseId: houseId, + purchaseDate: $("#input_time").val(), + purchasePrice: $("#input_price").val() + }).then(function (response) { + var status = response.data.status; + if(status){ + window.location.reload(); + }else{ + $.toast(response.data.message); + } + }).catch(function (error) { + console.log(error); + }); } }); @@ -89,11 +159,6 @@ $(document).on('click','.alert-text-title02', function () { $.alert('交易活跃度是根据房产的价值、周边配套、供需关系等情况来衡量,能否在市场中快速交易变现的评级。', '交易活跃度'); }); -/* button状态切换 */ -$(".content-block .button").on("click", function () { - $(this).parent().children().removeClass("active"); - $(this).addClass("active"); -}); /** * 请求构造Chart数据 @@ -351,6 +416,11 @@ function getAnalysisDetail(){ houseInfo.agencyLevel = resultsMap.agencyLevel; houseInfo.maxCityAgency = resultsMap.maxCityAgency; $('#agencyLevelPercent').css("width", resultsMap.agencyLevel+"%"); + + //全局变量赋值 + _evalDate = _houseInfo.evalDate + ""; + totalPricePart = resultsMap.totalPricePart1; + //调用构造数据方法 addItemsGuaPai(resultsMap); addItemsChengJiao(resultsMap); @@ -520,7 +590,7 @@ function formatTime_(_time){ //提到onPlusReady houseId = "192988147737427968"; -disName = "佳源上海小城商住楼"; +disName = "兰凤小区"; disRegion = "崇明"; disCity = "上海"; getAnalysisDetail();