新增输入校验与已租房源展示

This commit is contained in:
沈健
2021-04-09 09:39:58 +08:00
parent 4851f116e6
commit 260af640f8
3 changed files with 589 additions and 61 deletions
@@ -19,8 +19,6 @@
overflow: hidden;
overflow-y: scroll;
background: #f8f8f8;
/** 特别注意,否则中文不生效 **/
font-family: SimSun;
}
.main {
margin: 4px 8px 4px 8px;
@@ -125,29 +123,8 @@
<th>成交日期</th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="td01">上海</td>
<td class="td02">浦东区</td>
<td>永泰花苑</td>
<td>***</td>
<td>82</td>
<td>2</td>
<td>0</td>
<td>普通装修</td>
<td>2020-07-29</td>
</tr>
<tr class="bg">
<td class="td01">上海</td>
<td class="td02">浦东区</td>
<td>永泰花苑</td>
<td>***</td>
<td>82</td>
<td>2</td>
<td>0</td>
<td>普通装修</td>
<td>2020-07-29</td>
</tr>
<tbody id="trades">
<td colspan="6">暂无数据</td>
</tbody>
</table>
</div>
@@ -170,7 +147,7 @@
</tr>
</thead>
<tbody id="referenceHouses">
<td colspan="6" style="text-align:center">暂无数据</td>
<td colspan="6">暂无数据</td>
</tbody>
</table>
</div>
@@ -191,7 +168,7 @@
</thead>
<tbody id="sameDistricts">
<tr class="">
<td colspan="6" style="text-align:center">暂无数据</td>
<td colspan="6">暂无数据</td>
</tr>
</tbody>
</table>
@@ -202,12 +179,12 @@
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<!-- 暂时注释 -->
<#-- <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>-->
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
<script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script>
<script type="text/javascript" src="../static/js/trend-charts.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<script src="../static/js/purify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js"></script>
<#-- <script src="../static/js/purify.min.js"></script>-->
<#-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js"></script>-->
<#-- <script src="../static/js/jspdf.umd.js"></script>-->
<#-- <script src="../static/js/SourceHanSans-normal.js"></script>-->
<#-- <script src="../static/js/simsun-normal.js"></script>-->
@@ -235,31 +212,30 @@
<#-- });-->
<#-- </script>-->
<script type="text/javascript">
debugger
window.jsPDF = window.jspdf.jsPDF
var jspdf = new jsPDF();
// window.jsPDF = window.jspdf.jsPDF
// var jspdf = new jsPDF();
// jspdf.addFileToVFS('SourceHanSans-Normal.ttf',normalChinese);
// jspdf.addFont('SourceHanSans-Normal.ttf', 'SourceHanSans-Normal', 'normal');
// jspdf.setFont('SourceHanSans-Light');
//console.log(jspdf.getFontList());
$("#download").bind('click', function(){
//window.location.href = "download"
jspdf.html(document.body, {
callback: function (doc) {
doc.save("租金报告.pdf");
},
x: 0,
y: 0,
fontFaces: [{
family: 'SimSun',
weight: 'bold',
//style: style,
src: [{
format: "truetype",
url: "../static/fonts/SimSun.ttf"
}]
}]
});
window.location.href = "download"
// jspdf.html(document.body, {
// callback: function (doc) {
// doc.save("租金报告.pdf");
// },
// x: 0,
// y: 0,
// fontFaces: [{
// family: 'SimSun',
// weight: 'bold',
// //style: style,
// src: [{
// format: "truetype",
// url: "../static/fonts/SimSun.ttf"
// }]
// }]
// });
});
function init() {
@@ -301,7 +277,11 @@
// data: [3800, 3900, 4000, 4100, 4200, 4200, 4200, 4200]
// }];
if (result.trends.distMap[params.room] == undefined) {
console.error("返回历史租金房间数有误,不存在" + params.room + "居室数据")
console.log("返回历史租金,不存在" + params.room + "居室数据")
$('#districtRentTrendsChart').empty();
$('#districtRentTrendsChart').removeClass("charts");
$('#districtRentTrendsChart').addClass("p table");
$('#districtRentTrendsChart').append('<table style="width: 300px"><tr colspan="6">暂无数据<td></tr></table>');
} else {
var arr = [];
result.trends.times.forEach(function (d) {
@@ -326,12 +306,34 @@
$('span[name="fitment"]').text(result.fitment)
$('span[name="buildYear"]').text(result.buildYear)
// 已租房源
var trades = result.trades;
if (trades && trades.length > 0) {
$('#trades').empty();
trades.forEach(function(d){
var fitment = d.fitment != undefined ? d.fitment : '';
var hall = d.hall != undefined ? d.hall : '';
$('#trades').append('<tr class="bg"> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + d.totalPrice + '</td> \
<td>' + d.area + '</td> \
<td>' + d.room + '</td> \
<td>' + hall + '</td> \
<td>' + fitment + '</td> \
<td>' + formatDate(d.tradeDate) + '</td> \
</tr>');
})
}
// 样本参考
var referenceHouses = result.houses;
if (referenceHouses && referenceHouses.length > 0) {
$('#referenceHouses').empty();
referenceHouses.forEach(function(d){
var fitment = d.fitment != undefined ? d.fitment : '-';
var fitment = d.fitment != undefined ? d.fitment : '';
var date = (d.pDate + '').substring(0, 4) + "-" + (d.pDate + '').substring(4, 6) + "-" + (d.pDate + '').substring(6, 8)
$('#referenceHouses').append('<tr class="bg"> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
@@ -341,7 +343,7 @@
<td>' + d.room + '</td> \
<td>' + d.hall + '</td> \
<td>' + fitment + '</td> \
<td>' + d.pDate + '</td> \
<td>' + date + '</td> \
</tr>');
})
@@ -371,6 +373,15 @@
}
})
};
var formatDate = function (dateStr) {
var date = new Date(dateStr);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
return y + '-' + m + '-' + d;
};
function createChartNow(renderId, data, showTradeCount) {
if(data == null || data == 'undefined' || typeof(data) == undefined) {
return;
@@ -468,7 +479,7 @@
});
};
$(function () {
//init();
init();
});
</script>
</body>
@@ -0,0 +1,475 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
<#compress>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="referrer" content="no-referrer"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>租金报告中心</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<link rel="shortcut icon" href="/favicon.ico"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.css"/>
<link rel="stylesheet" href="../static/style/wx.css"/>
<style type="text/css">
body {
overflow: hidden;
overflow-y: scroll;
background: #f8f8f8;
/** 特别注意,否则中文不生效 **/
font-family: SimSun;
}
.main {
margin: 4px 8px 4px 8px;
background: #f8f8f8;
}
.title {
position: relative;
color: #1E90FF;
}
.title1 {
font-size: 14px;
color: #1E90FF;
}
.p {
font-size: 12px;
}
.table {
width: 100%;
overflow-y: hidden;
overflow-x: scroll
}
.inline {
width: 550px;
border-spacing: 0;
text-align: left;
}
.table .inline th {
color: #999;
font-weight: normal;
line-height: 30px;
text-align: left;
}
.download {
float: right;
color: #3d4145;
border: solid 1px #333;
order-radius: 3px;
font-size: 12px;
line-height: 1rem;
width: 43px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="main">
<div class="title">
估值报告<span class="download" id="download">下载</span>
</div>
<div>
<div class="title1">1 评估申明</div>
<div class="p">建设银行遵循中立、客观、公正的原则,通过周密细致的测算,评估求得分析对象的房地产市场参考。</div>
</div>
<div>
<div class="title1">2 评估时间</div>
<div class="p">
<span name="cal_date"></span><br/>
评估结果<br/>
楼盘名称:<span name="name"></span><br/>
楼盘地址:<span name="address"></span><br/>
租金估值(RMB):<span name="totalPrice"></span>元/月<br/>
大写(人民币):<span name="totalPriceUpper"></span><br/>
</div>
</div>
<div>
<div class="title1">3 报告有效期</div>
<div class="p">本报告在市场无较大波动的情况下,该评估价格在报告出具起三个月内有效。</div>
</div>
<div>
<div class="title1">4 房产状况</div>
<div class="p">
详细地址:<span name="address"></span><br/>
楼盘名称:<span name="name"></span><br/>
室号:<span name="room"></span><br/>
朝向:<span name="direction"></span><br/>
建筑面积:<span name="size"></span>平米<br/>
所在楼层:<span name="floor"></span> 层 <span name="height"></span>总层数<br/>
电梯配套:<span name="hasLift"></span><br/>
装修情况:<span name="fitment"></span><br/>
建筑年代:<span name="buildYear"></span><br/>
</div>
</div>
<div>
<div class="title1">5 历史租金</div>
<div class="charts" id="districtRentTrendsChart"></div>
</div>
<div>
<div class="title1">6 已租房源</div>
<div class="p table">
<table class="inline">
<thead>
<tr class="bg">
<th class="th01">城市</th>
<th>区域</th>
<th>小区名</th>
<th>成交价</th>
<th>面积</th>
<th>室</th>
<th>厅</th>
<th>装修</th>
<th>成交日期</th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="td01">上海</td>
<td class="td02">浦东区</td>
<td>永泰花苑</td>
<td>***</td>
<td>82</td>
<td>2</td>
<td>0</td>
<td>普通装修</td>
<td>2020-07-29</td>
</tr>
<tr class="bg">
<td class="td01">上海</td>
<td class="td02">浦东区</td>
<td>永泰花苑</td>
<td>***</td>
<td>82</td>
<td>2</td>
<td>0</td>
<td>普通装修</td>
<td>2020-07-29</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="title1">7 样本参考</div>
<div class="p table">
<table class="inline">
<thead>
<tr class="bg">
<th class="th01">城市</th>
<th>区域</th>
<th>小区名</th>
<th>租金</th>
<th>面积</th>
<th>室</th>
<th>厅</th>
<th>装修</th>
<th>成交日期</th>
</tr>
</thead>
<tbody id="referenceHouses">
<td colspan="6" style="text-align:center">暂无数据</td>
</tbody>
</table>
</div>
</div>
<div>
<div class="title1">8 周边同类小区租金</div>
<div class="p table">
<table class="inline" style="width: 300px">
<thead>
<tr class="bg">
<th class="th01">城市</th>
<th>区域</th>
<th>小区名</th>
<th>平米租金</th>
<th>室</th>
<th>厅</th>
</tr>
</thead>
<tbody id="sameDistricts">
<tr class="">
<td colspan="6" style="text-align:center">暂无数据</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<!-- 暂时注释 -->
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
<script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script>
<script type="text/javascript" src="../static/js/trend-charts.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<#-- <script src="../static/js/purify.min.js"></script>-->
<#-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js"></script>-->
<#-- <script src="../static/js/jspdf.umd.js"></script>-->
<#-- <script src="../static/js/SourceHanSans-normal.js"></script>-->
<#-- <script src="../static/js/simsun-normal.js"></script>-->
<#-- <script type="text/javascript">-->
<#-- $("#download").bind('click', function(){-->
<#-- window.location.href = "download"-->
<#-- // 打印所有可用的字体-->
<#-- // jspdf.html(document.body, {-->
<#-- // callback: function (doc) {-->
<#-- // doc.save("租金报告.pdf");-->
<#-- // },-->
<#-- // x: 10,-->
<#-- // y: 10-->
<#-- // });-->
<#-- // jspdf.html("test测试", {-->
<#-- // callback: function (doc) {-->
<#-- // doc.save("租金报告.pdf");-->
<#-- // },-->
<#-- // x: 10,-->
<#-- // y: 10-->
<#-- // });-->
<#-- });-->
<#-- $(function () {-->
<#-- $('span[name="name"]').text('场中小区');-->
<#-- });-->
<#-- </script>-->
<script type="text/javascript">
// window.jsPDF = window.jspdf.jsPDF
// var jspdf = new jsPDF();
// jspdf.addFileToVFS('SourceHanSans-Normal.ttf',normalChinese);
// jspdf.addFont('SourceHanSans-Normal.ttf', 'SourceHanSans-Normal', 'normal');
// jspdf.setFont('SourceHanSans-Light');
//console.log(jspdf.getFontList());
$("#download").bind('click', function(){
window.location.href = "download"
// jspdf.html(document.body, {
// callback: function (doc) {
// doc.save("租金报告.pdf");
// },
// x: 0,
// y: 0,
// fontFaces: [{
// family: 'SimSun',
// weight: 'bold',
// //style: style,
// src: [{
// format: "truetype",
// url: "../static/fonts/SimSun.ttf"
// }]
// }]
// });
});
function init() {
// 后台传参过来用
let params = {
'city': sessionStorage.city,
'district': sessionStorage.district,
'name': sessionStorage.name,
'address': sessionStorage.address,
'size': sessionStorage.size,
'floor': sessionStorage.floor,
'height': sessionStorage.height,
'room': sessionStorage.room,
'hall': sessionStorage.hall,
'toilet': sessionStorage.toilet,
'direction': sessionStorage.direction,
'fitment': sessionStorage.fitment
};
$.ajax({
// 注意需要加..
url: '../property/rentReport',
data: params,
dataType:"json",
type:"post",
success:function(data){
if(data.code == 200){
let result = data.result;
// 评估时间
$('span[name="cal_date"]').text(result.cal_date)
$('span[name="name"]').text(result.name);
$('span[name="address"]').text(result.address);
$('span[name="totalPrice"]').text(result.totalPrice)
$('span[name="totalPriceUpper"]').text(result.totalPriceUpper)
// 历史租金
var charts = {}
// charts.series = [{
// name: '1居室',
// data: [3800, 3900, 4000, 4100, 4200, 4200, 4200, 4200]
// }];
if (result.trends.distMap[params.room] == undefined) {
console.error("返回历史租金房间数有误,不存在" + params.room + "居室数据")
} else {
var arr = [];
result.trends.times.forEach(function (d) {
var price = result.trends.distMap[params.room][d];
if (price != undefined) {
arr.push(price);
} else {
arr.push('');
}
})
charts.series = [{'name': params.room + '居室', 'data': arr}]; // 纵坐标
charts.xData = result.trends.times; // 横坐标值
createChartNow('districtRentTrendsChart', charts, true);
}
// 房产状况
$('span[name="room"]').text(result.room)
$('span[name="direction"]').text(result.direction)
$('span[name="size"]').text(result.size)
$('span[name="floor"]').text(result.floor)
$('span[name="height"]').text(result.height)
$('span[name="hasLift"]').text(result.hasLift)
$('span[name="fitment"]').text(result.fitment)
$('span[name="buildYear"]').text(result.buildYear)
// 样本参考
var referenceHouses = result.houses;
if (referenceHouses && referenceHouses.length > 0) {
$('#referenceHouses').empty();
referenceHouses.forEach(function(d){
var fitment = d.fitment != undefined ? d.fitment : '-';
$('#referenceHouses').append('<tr class="bg"> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + d.totalPrice + '</td> \
<td>' + d.area + '</td> \
<td>' + d.room + '</td> \
<td>' + d.hall + '</td> \
<td>' + fitment + '</td> \
<td>' + d.pDate + '</td> \
</tr>');
})
}
// 同类小区租金
var sameDistricts = result.districts;
if (sameDistricts && sameDistricts.length > 0) {
$('#sameDistricts').empty()
sameDistricts.forEach(function(d){
$('#sameDistricts').append('<tr class=""> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + d.roomPrice + '</td> \
<td>' + d.room + '</td> \
<td>1</td> \
</tr>');
})
}
}else{
$.toast(data.msg);
}
},
error: function () {
}
})
};
function createChartNow(renderId, data, showTradeCount) {
if(data == null || data == 'undefined' || typeof(data) == undefined) {
return;
}
if(data.series == 'undefined' || data.series.length == 0) {
return;
}
var yaxis = [{
title: {
enable: false,
text: ''
},
offset : -5,
labels: {
formatter: function() {
return this.value + "元";
}
}
}];
if(showTradeCount) {
yaxis.push({
title: {
enable: false,
text: ''
},
labels: {
formatter: function() {
return this.value +'套';
},
style: {
color: '#4572A7'
}
},
opposite: true
});
}
var config = {yaxis : yaxis};
createHighChartNow(renderId, data, config);
};
function createHighChartNow(renderId, data, config) {
var chart = new Highcharts.Chart({
credits:{
enabled:true,
text: '',
href: "",
position: {
align: 'center',
verticalAlign: 'top',
x: 0,
y: 25
},
itemStyle: {
cursor: 'pointer'
}
},
chart: {
renderTo: renderId,
type: 'spline'
},
title: {
text: data.title,
floating: false,
align: 'center',
x : 0,
y : 10
},
legend: {
align: 'center',
verticalAlign: 'bottom'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
day: '%m月%d',
week: '%m月%d',
month: '%Y.%m',
year: '%Y-%m'
},
categories: data.xData
},
yAxis: config.yaxis,
series: data.series,
tooltip: {
formatter: function() {
if(this.series.name.indexOf('成交量') > -1) {
return Highcharts.dateFormat('%Y年%m月', this.x) +" 成交: <span style='color:#F50;font-weight: bold;'>"+ this.y +'</span>套';
}else {
return Highcharts.dateFormat('%Y-%m-%d', this.x) +'<br/>'+ this.series.name+ ": <span style='color:#F50;font-weight: bold;'>"+ this.y +'</span>元/平米';
}
}
}
});
};
$(function () {
init();
});
</script>
</body>
</html>
</#compress>
@@ -30,8 +30,6 @@
<div class="item-content">
<div class="item-inner">
<input id="cityName" value="上海" name="city" type="hidden">
<!-- 区域 -->
<input value="" name="district" type="hidden">
<input value="2000" name="radius" type="hidden">
<div class="item-title label">城市:<font>上海</font></div>
</div>
@@ -45,6 +43,8 @@
<input type="text" placeholder="请输入小区名或地址" id="districtSearch" name="name" class="search_input" required>
<input type="hidden" name="address" />
</div>
<!-- 区域 -->
<input value="" name="district" type="hidden" required>
<div class="item-media"><span>(必填项)</span></div>
</div>
</div>
@@ -68,9 +68,9 @@
<div class="item-inner">
<div class="content-block">
<div class="item-title label di">户型:</div>
<input name="room" type="hidden" id="room">
<input name="hall" type="hidden" id="hall">
<input name="toilet" type="hidden" id="toilet">
<input name="room" type="hidden" id="room" placeholder="请选择室" value="1">
<input name="hall" type="hidden" id="hall" placeholder="请选择厅">
<input name="toilet" type="hidden" id="toilet" placeholder="请选择卫">
<p class="di">
<a href="#" class="create-actions01-now">1</a>室&nbsp;&nbsp;&nbsp;&nbsp;<a
href="#" class="create-actions02-now">0</a>厅&nbsp;&nbsp;&nbsp;&nbsp;<a
@@ -147,6 +147,7 @@
<div class="content-block">
<p><a id="evaluateBtn" class="button button-big button-fill">查看租金结果</a></p>
</div>
</div>
</form>
</div>
</div>
@@ -212,12 +213,51 @@
}
$("#evaluateBtn").on('click', function(){
var inputs = $("input")
for (var i = 0; i < inputs.length; i++) {
var input = $(inputs[i])
var fieldName = input.attr("placeholder").substring(3)
var fieldVal = $.trim(input.val())
if (input.attr("required") && fieldVal == "") {
if (input.attr("name").indexOf("district") != -1) {
$.toast("请选择输入地址时提示的小区")
} else {
$.toast(fieldName + "不能为空");
}
return
}
if (input.attr("type") == 'number' && fieldVal != "") {
if (input.attr("name").indexOf("size") != -1) {
if (!/^[0-9]+(.[0-9]+)?$/.test(fieldVal)) {
$.toast(fieldName + "非法");
return
}
} else {
if (!/^[0-9]+$/.test(fieldVal)) {
$.toast(fieldName + "必须是正整数");
return
}
}
var min = input.attr("min")
var max = input.attr("max")
if (max && min && (parseFloat(min) > parseFloat(fieldVal) || parseFloat(max) < parseFloat(fieldVal))) {
$.toast(fieldName + "的取值范围是:" + min + "到" + max);
return
}
}
}
if(parseFloat($("#houseHight").val()) < parseFloat($("#houseFloor").val())){
$.toast("楼层不能大于楼高");
return
}
storeSession()
if($("#houseHight").val() && parseFloat($("#houseHight").val())>=60){
$.toast("请输入合理的楼层数");
return
}
$("#evaluateBtn").prop("disabled", true)
$.ajax({
// 注意需要加..
url: '../property/evaluateRent',
@@ -228,11 +268,13 @@
if(data.code == 200){
window.location.href = "report?address=" + data.result.address + "&totalPrice=" + data.result.totalPrice
}else{
$.toast(data.msg);
$.toast("估价失败,请重新评估");
$("#evaluateBtn").prop("disabled", false)
}
},
error: function () {
//$.toast("服务器异常,请重新评估");
$("#evaluateBtn").prop("disabled", false)
}
})
})