新增单独的城市

This commit is contained in:
2018-04-13 13:30:31 +08:00
parent 21aed7b09f
commit a60fcf202c
6 changed files with 681 additions and 9 deletions
@@ -356,7 +356,6 @@ var option01 = {
res += '<br/> 月末 : ' + params[0].value[2];
res += '<br/> 最低 : ' + params[0].value[3];
res += '<br/> 最高 : ' + params[0].value[4];
res += '<br/> '+params[0].seriesName + ' : ' +params[0].value;
return res;
},
position: function (pos, params, el, elRect, size) {
+480
View File
@@ -0,0 +1,480 @@
var ret = []
function loadMyCollectCity(){
axios.get("/rest/quotations/userCollectCitys",{}).then(function (response) {
var curDatas = response.data.data
if(curDatas){
if(IsInArray(curDatas, city)){
cityInfoVue.$data.collecd = true;
}else{
cityInfoVue.$data.collecd = false;
}
}
}).catch(function (error) {
alert(error)
console.log(error);
});
}
function loadCityPriceInfo(city){
axios.get("/rest/quotations/cityPriceInfo", {
params: {
city: city
}
}).then(function (response) {
var data1 = response.data.data
if(data1){
var cityObj = new Object();
cityObj.city = data1.city
cityObj.cityTopMonthAvgPrice = data1.cityTopMonthAvgPrice
cityObj.downChance = data1.downChance
cityObj.follow = data1.follow
cityObj.index = data1.index
cityObj.oneMonthUpDownRange = (data1.oneMonthUpDownRange*100).toFixed(2)
cityObj.oneYearUpDownRange = data1.oneYearUpDownRange
cityObj.rangeLevel = data1.rangeLevel
cityObj.time = year + month
cityInfoVue.$data.myCityMap = cityObj;
}
}).catch(function (error) {
alert(error)
console.log(error);
});
}
function loadUpOrDown(city){
axios.get("/rest/quotations/hosueQuatations", {
params: {
city: city
}
}).then(function (response) {
var data2 = response.data.data
if(data2){
loadUpOrDownChart(data2.downRate, data2.upRate);
}
}).catch(function (error) {
alert(error)
console.log(error);
});
}
function loadCityPricesAndCounts(city){
axios.get("/rest/quotations/loadCityPriceTrends", {
params: {
city: city,
type:2
}
}).then(function (response) {
var data3 = response.data.data
if(data3){
loadTrends(data3.times, data3.cityPriceMap , data3.countMap);
}
}).catch(function (error) {
alert(error)
console.log(error);
});
}
function loadHotDistrict(city){
axios.get("/rest/districts/hotDistricts", {
params: {
city: city,
top:5
}
}).then(function (response) {
var data4 = response.data.data
if(data4){
var nears = []
for(var n in data4){
var v = data4[n]
var nearObj = new Object();
nearObj.city = v.city
nearObj.region = v.region
nearObj.name = v.name;
nearObj.sname = nameConver(v.name)
nearObj.avgPrice = v.avgPrice
nears.push(nearObj);
}
cityInfoVue.$data.nears = nears;
}
}).catch(function (error) {
alert(error)
console.log(error);
});
}
/*点击走势TAB页*/
function clickTrend(city, type){
if(type == 5){
if (localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == "") {
clicked('../user/codeSms.html',true,false,{},{},function(){
clickTrend(city, type);
})
return;
} else {
startingLoadCharts(city, type);
}
}else{
startingLoadCharts(city, type);
}
}
function startingLoadCharts(city, type){
axios.get("/rest/quotations/loadCityPriceTrends", {
params: {
city: city,
type:type
}
}).then(function (response) {
var datas = response.data.data
var prices = []
var counts = []
var times = datas.times
for(var i in times){
var time = times[i]
time = parseInt(time.replace("-",""))
var pm = datas.cityPriceMap;
var cm = datas.countMap;
if(pm){
if(pm[time]){
prices.push(pm[time])
}else{
prices.push(null)
}
}
if(cm){
if(cm[time]){
counts.push(cm[time]);
}else{
counts.push(null);
}
}
}
$("#trendDiv a").removeClass("active");
$("a[v='"+type+"']").addClass("active")
showChart("price_chart", times, prices, counts)
}).catch(function (error) {
alert(error)
console.log(error);
});
}
function loadUpOrDownChart(downRate, upRate){
if(upRate){
var cityObj1 = new Object();
cityObj1.name= ""
cityObj1.value = upRate
var cityObj2 = new Object();
cityObj2.name= ""
cityObj2.value = 100 - upRate
dataUp = [cityObj1, cityObj2]
addUpChart(dataUp)
}else{
$("#up_chart").parent().parent().hide()
}
if(downRate){
var cityObj3 = new Object();
cityObj3.name= ""
cityObj3.value = downRate
var cityObj4 = new Object();
cityObj4.name= ""
cityObj4.value = 100 - downRate
dataDown = [cityObj3, cityObj4]
addDownChart(dataDown)
}else{
$("#down_chart").parent().parent().hide()
}
}
function loadTrends(times, cityPriceMap, countMap){
var prices = []
var counts = []
for(var i in times){
var time = times[i]
time = parseInt(time.replace("-",""))
var pm = cityPriceMap;
var cm = countMap;
if(pm){
prices.push(pm[time])
}
if(cm){
counts.push(cm[time]);
}
}
showChart("price_chart", times, prices, counts)
}
/*跳转区域列表*/
function showRegionInfo(city){
clicked('../house/regions.html',true,false,{},{city:city});
}
/*跳转小区详情*/
function showDistrictDetail(city, region, name){
clicked('../district/detail.html',true,false,{},{city:city,region:region,name:name});
}
function showChart(idDom, categories, prices, counts){
if(!prices){
prices = []
}
if(!counts){
counts = []
}
if(prices.length==0 && counts.length == 0){
$("#trendChartDiv").hide();
}else{
/* 城市均价及挂牌走势 */
var chart = Highcharts.chart(idDom, {
colors: ['#ff7f50','#87cefa'],
title: {
text: '城市楼市均价及挂牌走势',
y: -30
},
xAxis: [{
categories:categories,
crosshair: true
}],
yAxis: [{
title: {
text: '元/㎡',
align: 'high',
offset: 4,
rotation: 0,
y: -20
},
allowDecimals: false,
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
}, { // Secondary yAxis
title: {
text: '套',
align: 'high',
offset: 25,
rotation: 0,
y: -20
},
allowDecimals: false,
opposite: true
}],
tooltip: {
shared: true
},
credits: {
enabled: false
},
plotOptions: {
line: {
connectNulls: true //该设置会连接空值点
},
series: {
events: {
legendItemClick: function(e) {
return false;
}
},
marker: {
radius: 3, //曲线点半径,默认是4
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
}
}
},
series: [{
name: '均价',
type: 'line',
zIndex: 1,
tooltip: {
valueSuffix: ' 元/㎡'
},
data: prices
},{
name: '挂牌量',
type: 'column',
yAxis: 1,
tooltip: {
valueSuffix: ' 套'
},
data: counts
}]
});
}
}
function nameConver(textName){
var length = textName.length;
var textStr = textName;
if(length > 5){
textStr = textName.substr(0,5)+ "...";
}
return textStr;
}
function IsInArray(arr, val){
  var testStr=','+arr.join(",")+",";
  return testStr.indexOf(","+val+",")!=-1;
}
function addUpChart(dataUp, num){
/* 小区上涨 */
//var dataUp = [];
optionUp = {
title: {
text: dataUp[0].value + '%',
subtext: '小区上涨',
x: 'center',
y: 'center',
itemGap: -8,
textStyle: {
fontFamily: 'Arial, Verdana, sans-serif',
fontSize: 30,
color: '#333',
fontWeight: 'normal'
},
subtextStyle: {
fontFamily: '华文细黑',
fontSize: 12,
color: '#666'
}
},
color: ['#EB5F34', '#e7e7e7'],
series: [
{
name: '小区上涨',
type: 'pie',
radius: ['90%', '100%'],
itemStyle: {
normal: {
label: {
show: true
},
labelLine: {
show: false
}
}
},
data: dataUp
}
]
};
var myChartUp = echarts.init(document.getElementById('up_chart'));
myChartUp.setOption(optionUp,true);
}
function addDownChart(dataDown){
/* 小区下跌 */
optionDown = {
title: {
text: dataDown[0].value + '%',
subtext: '小区下跌',
x: 'center',
y: 'center',
itemGap: -8,
textStyle: {
fontFamily: 'Arial, Verdana, sans-serif',
fontSize: 30,
color: '#333',
fontWeight: 'normal'
},
subtextStyle: {
fontFamily: '华文细黑',
fontSize: 12,
color: '#666'
}
},
color: ['#88D053', '#e7e7e7'],
series: [
{
name: '小区下跌',
type: 'pie',
radius: ['90%', '100%'],
itemStyle: {
normal: {
label: {
show: true
},
labelLine: {
show: false
}
}
},
data: dataDown
}
]
};
var myChartUp = echarts.init(document.getElementById('down_chart'));
myChartUp.setOption(optionDown,true);
}
function collectCity(city){
if (localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == "") {
clicked('../user/codeSms.html',true,false,{},{},function(){
collectCity(city)
})
return;
} else {
docollectCity(city)
}
}
function docollectCity(city){
axios.get("/rest/quotations/collectCity",{
params:{
city : city
}
}).then(function (response) {
var msg = response.data.message;
if(msg){
if(msg == "取消关注成功"){
cityInfoVue.$data.collecd = false;
}else if(msg == "关注成功"){
cityInfoVue.$data.collecd = true;
}else{
$.toast(msg);
}
}
})
.catch(function (error) {
console.log(error);
});
}
+1 -2
View File
@@ -329,7 +329,6 @@ function loadChart(){
loadTrends();
window.clearInterval(t1);
}
}
@@ -531,7 +530,7 @@ function showRegionInfo(city){
function collectCity(city, index){
if (localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == "") {
clicked('../user/codeSms.html',true,false,{},{},function(){
docollectCity(city)
collectCity(city)
})
return;
} else {
+5 -2
View File
@@ -1616,7 +1616,8 @@
],
"refer": [
"views/user/passLogin.html",
"views/district/detail.html"
"views/district/detail.html",
"views/setting/setting.html"
],
"priority": 0
},
@@ -1667,7 +1668,9 @@
"resources": [],
"refer": [
"views/house/regions.html",
"views/district/detail.html"
"views/district/detail.html",
"views/user/codeSms.html",
"views/house/cityDetail.html"
],
"priority": 0
}
+184
View File
@@ -0,0 +1,184 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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="../../css/main.css">
<link rel="stylesheet" href="../../css/city.css">
<link rel="stylesheet" href="../../css/theme-orange.css">
<style>
.cardInfo02 .item-title{white-space:normal;text-align:justify;display:block;}
.cardInfo02 .item-subtitle{margin-top:0.2rem;}
.cardCity01 .card-footer span:nth-child(2){text-align:center;}
.cardNearbyBox01 .cardNearby .card-content-inner{padding-bottom:0.25rem;}
</style>
</head>
<body>
<div class="page-group">
<div class="page page-current">
<header class="bar bar-nav barBorder ">
<button class="button button-link button-nav pull-left" onclick="back(),plus.nativeUI.closeWaiting();">
<span class="icon icon-left"></span>
</button>
</header>
<div class="content" id="cityInfo">
<div class="card cardPrice cardPrice01 cardCity01" v-bind:hrefid="myCityMap.hrefId">
<div class="card-header">
<label>{{myCityMap.city}}</label>
<a v-if="collecd" class="button collection collection02 " @click="collectCity(myCityMap.city)">取消</a>
<a v-else class="button theme collection collection01" @click="collectCity(myCityMap.city)">关注</a>
</div>
<div class="card-header">
<span>当前参考均价</span>
</div>
<div class="card-content">
<div class="card-content-inner">{{myCityMap.cityTopMonthAvgPrice}}<span>元/㎡</span></div>
</div>
<div class="card-footer">
<span v-if="myCityMap.oneMonthUpDownRange >= 0">
<em><strong>{{myCityMap.oneMonthUpDownRange}}</strong>%<i class="icon icon-arrow-red"></i></em>
<label>近30天涨跌幅</label>
</span>
<span v-else>
<em><strong>{{myCityMap.oneMonthUpDownRange}}</strong>%<i class="icon icon-arrow-green"></i></em>
<label>近30天涨跌幅</label>
</span>
<span>
<em><strong>{{myCityMap.rangeLevel}}</strong></em>
<label>城市涨跌排名</label>
</span>
<span v-if="myCityMap.index < 50">
<em><strong>{{myCityMap.downChance}}</strong>%<i class="icon icon-arrow-green"></i></em>
<label>下跌概率</label>
</span>
<span v-else>
<em><strong>{{myCityMap.downChance}}</strong>%<i class="icon icon-arrow-red"></i></em>
<label>上涨概率</label>
</span>
</div>
</div>
<div class="topic">
<div class="topicTitle topicTitle02">{{myCityMap.time}}楼市行情<span><a @click="showRegionInfo(myCityMap.city)">区县涨跌详情<i class="icon icon-right"></i></a></span></div>
<div class="topicContent" style="padding-top:0;">
<div class="chartBox row">
<span class="col-50">
<div class="chart" id="up_chart"></div>
</span>
<span class="col-50">
<div class="chart" id="down_chart"></div>
</span>
</div>
</div>
</div>
<div class="topic" id="trendChartDiv">
<div class="topicTitle" style="position:relative;">城市均价及挂牌走势
<div class="content-block">
<div class="buttons-row theme" id="trendDiv">
<a class="tab-link button active" v="2" v-bind:city="myCityMap.city" @click="clickTrend(myCityMap.city, 2)">半年</a>
<a class="tab-link button" v="3" v-bind:city="myCityMap.city" @click="clickTrend(myCityMap.city, 3)">一年</a>
<a class="tab-link button" v="5" v-bind:city="myCityMap.city" @click="clickTrend(myCityMap.city, 5)">三年</a>
</div>
</div>
</div>
<div class="topicContent" style="padding:0;">
<div class="chart" id="price_chart"></div>
</div>
</div>
<div class="topic">
<div class="topicTitle">热门小区</div>
<div class="topicContent" style="padding:0;">
<div class="cardNearbyBox cardNearbyBox01">
<div class="cardNearbyWin" style="width: 38rem;">
<div class="card cardNearby" v-for="nearDist in nears" @click="showDistrictDetail(nearDist.city, nearDist.region, nearDist.name)">
<div class="card-header">{{nearDist.sname}}</div>
<div class="card-content">
<div class="card-content-inner">{{nearDist.avgPrice}}元/㎡</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="../../js/zepto.js" charset="utf-8"></script>
<script>
/* 关闭路由,以实现不同页面之间的相互跳转(仅开发环境需要) */
Zepto = $
$.config = {router: false}
</script>
<script type="text/javascript" src="../../js/vue.js"></script>
<script type="text/javascript" src="../../js/light7.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/cn.js" charset="utf-8"></script>
<script type="text/javascript" src="../../config.js"></script>
<script type='text/javascript' src='../../js/common.js' charset='utf-8'></script>
<script type="text/javascript" src="../../js/axios.min.js"></script>
<script type="text/javascript" src="../../js/axiosPlugin.js"></script>
<script type="text/javascript" src="../../js/log/log_stat.js" ></script>
<script type="text/javascript" src="../../js/echarts.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/highcharts-4.2.3.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/quotations/cityDetail.js" ></script>
<script>
var date = new Date();
var year = date.getFullYear()+'年';
var month = date.getMonth()+1+'月';
var city = "天津"
var cityInfoVue = new Vue({
el: '#cityInfo',
data: {
city:"",
month:month,
collecd:false,
nears:[],
myCityMap : []
}
});
document.addEventListener('plusready', onPlusReady, false);
function onPlusReady() {
var self = plus.webview.currentWebview();
var city = self.city
cityInfoVue.$data.city = city;
loadMyCollectCity();
loadCityPriceInfo(city)
loadUpOrDown(city);
loadHotDistrict(city)
loadCityPricesAndCounts(city)
}
</script>
</body>
</html>
+11 -4
View File
@@ -19,6 +19,9 @@
.cardInfo02 .item-subtitle{margin-top:0.2rem;}
.cardCity01 .card-footer span:nth-child(2){text-align:center;}
.cardNearbyBox01 .cardNearby .card-content-inner{padding-bottom:0.25rem;}
.tabs .topic{margin-bottom:0;}
.buttons-tab{overflow-x:auto;border-bottom:solid 1px #e7e7e7;}
.buttons-tab:after{height:0;}
</style>
</head>
@@ -148,15 +151,15 @@
<div class="topic">
<div class="topicTitle">房产热点城市</div>
<div class="topicContent cityImgBox row">
<div class="col-33">
<img src="../../images/cityImg01.png">
<div class="col-33" >
<img src="../../images/cityImg01.png" onclick="hotCity('北京')">
<p>北京</p>
</div>
<div class="col-33">
<div class="col-33" onclick="hotCity('上海')">
<img src="../../images/cityImg02.png">
<p>上海</p>
</div>
<div class="col-33">
<div class="col-33" onclick="hotCity('深圳')">
<img src="../../images/cityImg03.png">
<p>深圳</p>
</div>
@@ -1476,6 +1479,10 @@ function addFocus(city){
})
}
function hotCity(city){
clicked('../house/cityDetail.html',true,false,{},{city:city});
}
</script>