var colorList = ['#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae', '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3']; var labelFont = 'bold 12px Sans-serif'; var dates; var data; var volumes; var curOption; /* 关注&已关注切换 */ $(".collection01").on("click", function () { doAddCollect() }); function doAddCollect(){ if (localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == "") { clicked('../user/codeSms.html',true,false,{},{},function(){ doAddCollect(); }) return; } else { addCollect(); } } function addCollect(){ axios.post("/rest/districts/addCollect",{city:city,region:region,name:name,lat:lat,lng:lng,address:address, poiTags:tags}).then(function (response) { var msg = response.data.message if(msg){ $.toast(msg); }else{ $(".collection01").hide(); $(".collection02").show(); $.toast("随时掌握小区动态"); } }) .catch(function (error) { console.log(error); }); } $(".collection02").on("click", function () { removeCollect(); }); function doRemoveCollect(){ if (localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == "") { clicked('../user/codeSms.html',true,false,{},{},function(){ doRemoveCollect(); }) return; } else { removeCollect(); } } function removeCollect(){ axios.post("/rest/districts/removeCollect",{city:city,region:region,name:name}).then(function (response) { var msg = response.data.message if(msg){ $.toast(msg); }else{ $(".collection02").hide(); $(".collection01").show(); $.toast("取消关注"); } }) .catch(function (error) { console.log(error); }); } /* button状态切换 */ $("#trendTabDiv .button").on("click", function () { $(this).parent().children().removeClass("active"); $(this).addClass("active"); }); /* 图表切换 */ $("#tabAvgDiv").on("click", function () { $("#tabChart1").css("z-index","1"); $("#tabChart2").css("z-index","-1"); }); $("#tabRentDiv").on("click", function () { $("#tabChart2").css("z-index","1"); $("#tabChart1").css("z-index","-1"); }); var t1 = window.setTimeout(loadMap,1000); function loadMap(){ if(lng && lat){ loadMapPoi(); window.clearTimeout(t1); } } //小区详情 function loadDistrictInfo(){ axios.get("/rest/districts/detail", { params: { city: city, region:region, name: name } }).then(function (response) { var vo = response.data.data.detail var cityPrice = response.data.data.cityPrice var collected = response.data.data.collected if(cityPrice){ baseInfo.cityPrice = cityPrice } if(collected){ $(".collection02").show(); $(".collection01").hide(); }else{ $(".collection02").hide(); $(".collection01").show(); } if(vo){ if(vo.avgPrice){ lat = vo.lat2; lng = vo.lng2; //loadMapPoi(); baseInfo.city = vo.city baseInfo.region = vo.region baseInfo.address = vo.address; baseInfo.name = vo.name baseInfo.avgPrice = vo.avgPrice; baseInfo.oneMonthUpDownRange = vo.oneMonthUpDownRange; if(vo.rank){ baseInfo.priceRate = vo.rank.substring(0, vo.rank.indexOf("/")); } //baseInfo.cityPrice = vo.cityPrice; var finishDate = "" if(vo.finishBuildingDate){ if(vo.finishBuildingDate.indexOf("~")!=-1){ finishDate = vo.finishBuildingDate.replace("年",""); }else{ finishDate = vo.finishBuildingDate.substring(0,4)+"年" } } baseInfo.finishBuildingDate = finishDate; baseInfo.householdCount = vo.householdCount; baseInfo.cubagePercent = vo.cubagePercent; baseInfo.carSiteCount = vo.carSiteCount; baseInfo.virescencePercent = vo.virescencePercent; baseInfo.estateCharge = vo.estateCharge; baseInfo.moreArea = vo.moreArea; baseInfo.developer = vo.developer; baseInfo.estateCompany = vo.estateCompany; address = vo.address; tags = vo.poiTags; if(vo.poiTags){ if(vo.poiTags.length>=3){ baseInfo.tags = vo.poiTags.slice(0,3); }else{ baseInfo.tags = vo.poiTags; } } var starScore = response.data.data.starScore if(starScore && starScore > 0){ var regionIndex = response.data.data.regionIndex var districtPoiCount = response.data.data.districtPoiCount var schoolIndex = response.data.data.schoolIndex var arroundIndex = response.data.data.arroundIndex var indexs = [] indexs.push(vo.index); indexs.push(regionIndex); indexs.push(schoolIndex); indexs.push(arroundIndex); /* 小区评级 */ loadDistrictLevel(indexs); }else{ $("#distLevelDiv").hide() } }else{ $("#noDataDiv").show() baseInfo.name = "小区详情" } } }).catch(function (error) { alert(error) console.log(error); }); } //附近小区 /*function loadNearDistrict(lat, lng){ axios.get("/rest/districts/nearDistrict", { params: { lat: lat, lng:lng } }).then(function (response) { var datas = response.data.data if(datas){ var ret = [] for(var v in datas){ var o = datas[v] if(o.city == city && o.district == region && o.name == name){ continue; }else{ if(ret.length <= 5){ ret.push(o); } } } baseInfo.nearDists = ret; $("#nearDistDiv .cardNearbyWin").css("width",(7.5*ret.length)+"rem"); }else{ $("#nearDistDiv").hide() } }).catch(function (error) { alert(error) console.log(error); }); }*/ function loadKLineData(city, region, name){ var type = $("#trendDiv1 a.active").attr("t-v"); axios.get("/rest/trend/kData", { params: { city: city, region:region, name:name, type: type } }).then(function (response) { var datas = response.data.data if(datas){ var trends = []; var counts = []; var times = [] var haveCount = false; for(var d in datas){ times.push(d); var prices = new Array(); for(var m in datas[d]){ prices.push(datas[d][m]); } trends.push(prices); if(haveCount==false && datas[d][4]){ haveCount = true; } counts.push(datas[d][4]); } // if(haveCount){ option01.xAxis[0].data = times option01.xAxis[1].data = times //option01.series[0].data = counts option01.series[0].data = trends curOption = option01; myChart01.setOption(option01,true); // }else{ // option02.xAxis[0].data = times // option02.xAxis[1].data = times // option02.series[0].data = trends // curOption = option02; // myChart01.setOption(option02,true); // } } }).catch(function (error) { alert(error) console.log(error); }); } $("#trendDiv1 a").click(function(){ //showTrends(); var v = $(this).attr("t-v"); showTrends(v) }); function showTrends(v){ if(v == "36"){ if (localStorage.getItem("user_token") == null || localStorage.getItem("user_token") == "") { clicked('../user/codeSms.html',true,false,{},{},function(){ showTrends(v); }) return; } else { $("#trendDiv1 a").removeClass("active") $("a[t-v='36']").addClass("active") //curOption.dataZoom[0].start = 0 loadKLineData(city, region, name) } }else{ $("#trendDiv1 a").removeClass("active") //myChart01.setOption(curOption,true); if(v == 12){ $("a[t-v='12']").addClass("active") }else{ $("a[t-v='6']").addClass("active") } loadKLineData(city, region, name) } } var option01 = { animation: false, color: colorList, title: { text: null, left: 'center' }, legend: { show: false, top: 30, data: ['均价', '成交量'] }, tooltip: { triggerOn: 'none', transitionDuration: 0, confine: true, bordeRadius: 4, borderWidth: 1, borderColor: '#333', backgroundColor: 'rgba(255,255,255,0.9)', textStyle: { fontSize: 12, color: '#333' }, formatter: function (params) { var res = params[0].seriesName + ' ' + params[0].name; res += '
月初 : ' + params[0].value[1]; res += '
月末 : ' + params[0].value[2]; res += '
最低 : ' + params[0].value[3]; res += '
最高 : ' + params[0].value[4]; res += '
'+params[0].seriesName + ' : ' +params[0].value; return res; }, position: function (pos, params, el, elRect, size) { var obj = { top: 60 }; obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5; return obj; } }, axisPointer: { link: [{ xAxisIndex: [0, 1] }] }, dataZoom: [{ type: 'slider', xAxisIndex: [0, 1], realtime: false, start: 50, end: 100, top: 65, height: 20, handleIcon: 'M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z', handleSize: '120%' }, { type: 'inside', xAxisIndex: [0, 1], start: 40, end: 70, top: 30, height: 20 }], xAxis: [{ type: 'category', data: dates, boundaryGap : false, axisLine: { lineStyle: { color: '#666' } }, axisLabel: { formatter: function (value) { return echarts.format.formatTime('MM-dd', value); } }, min: 'dataMin', max: 'dataMax', axisPointer: { show: true } }, { type: 'category', gridIndex: 1, data: dates, scale: false, boundaryGap : false, splitLine: {show: false}, axisLabel: {show: false}, axisTick: {show: false}, axisLine: {lineStyle: { color: '#fff' } }, splitNumber: 20, min: 'dataMin', max: 'dataMax', axisPointer: { //type: 'shadow', label: {show: false}, triggerTooltip: true, handle: { show: true, margin: -20, color: '#F18D00' } } }], yAxis: [{ name: '均价(元/㎡)', nameRotate: 90, nameLocation: 'center', nameGap: 5, position: 'right', nameTextStyle: { color: '#999' }, scale: true, splitNumber: 2, axisLine: { lineStyle: { color: '#999' } }, splitLine: { show: true }, axisTick: { show: false }, axisLabel: { inside: true, formatter: '{value}\n' } }, { name: '成交量(套)', nameRotate: 90, nameLocation: 'center', nameGap: 5, position: 'right', nameTextStyle: { color: '#999' }, scale: true, gridIndex: 1, splitNumber: 2, axisLabel: {show: false}, axisLine: {show: false}, axisTick: {show: false}, splitLine: {show: false} }], grid: [{ left: 20, right: 20, top: 110, height: 120 }, { left: 20, right: 20, height: 40, top: 260 }], graphic: [{ type: 'group', left: 'center', top: 70, width: 300, bounding: 'raw' }], series: [/*{ name: '成交量', type: 'bar', xAxisIndex: 1, yAxisIndex: 1, itemStyle: { normal: { color: '#87cefa' }, emphasis: { color: 'black' } }, data: volumes }, */{ type: 'candlestick', name: '均价', data: data, itemStyle: { normal: { color: '#EB5F34', color0: '#88D053', borderColor: '#EB5F34', borderColor0: '#88D053' }, emphasis: { color: 'black', color0: '#333', borderColor: 'black', borderColor0: '#333' } } }] }; /*var option02 = { animation: false, color: colorList, title: { text: null, left: 'center' }, legend: { show: false, top: 30, data: ['均价'] }, tooltip: { triggerOn: 'none', transitionDuration: 0, confine: true, bordeRadius: 4, borderWidth: 1, borderColor: '#333', backgroundColor: 'rgba(255,255,255,0.9)', textStyle: { fontSize: 12, color: '#333' }, formatter: function (params) { var res = params[0].seriesName + ' ' + params[0].name; res += '
月初 : ' + params[0].value[1] res += '
月末 : ' + params[0].value[2]; res += '
最低 : ' + params[0].value[3]; res += '
最高 : ' + params[0].value[4]; return res; }, position: function (pos, params, el, elRect, size) { var obj = { top: 60 }; obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5; return obj; } }, axisPointer: { link: [{ xAxisIndex: [0, 1] }] }, dataZoom: [{ type: 'slider', xAxisIndex: [0, 1], realtime: false, start: 50, end: 100, top: 65, height: 20, handleIcon: 'M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z', handleSize: '120%' }, { type: 'inside', xAxisIndex: [0, 1], start: 40, end: 70, top: 30, height: 20 }], xAxis: [{ type: 'category', data: dates, boundaryGap : false, axisLine: { lineStyle: { color: '#999' } }, axisLabel: { formatter: function (value) { return echarts.format.formatTime('yy-MM', value); } }, min: 'dataMin', max: 'dataMax', axisPointer: { show: true } }, { type: 'category', gridIndex: 1, data: dates, scale: true, boundaryGap : false, splitLine: {show: false}, axisLabel: {show: false}, axisTick: {show: false}, axisLine: { lineStyle: { color: '#fff' } }, splitNumber: 20, min: 'dataMin', max: 'dataMax', axisPointer: { type: 'shadow', label: {show: false}, triggerTooltip: true, handle: { show: true, margin: 30, color: '#B80C00' } } }], yAxis: [{ name: '均价(元/㎡)', nameRotate: 90, nameLocation: 'center', nameGap: 5, position: 'right', nameTextStyle: { color: '#999' }, scale: true, splitNumber: 2, axisLine: { lineStyle: { color: '#999' } }, splitLine: { show: true }, axisTick: { show: false }, axisLabel: { inside: true, formatter: '{value}\n' } }, { name: '成交量(套)', nameRotate: 90, nameLocation: 'center', nameGap: 5, position: 'right', nameTextStyle: { color: '#999' }, scale: true, gridIndex: 1, splitNumber: 2, axisLabel: {show: false}, axisLine: {show: false}, axisTick: {show: false}, splitLine: {show: false} }], grid: [{ left: 20, right: 20, top: 110, height: 120 }, { left: 20, right: 20, height: 40, top: 260 }], graphic: [{ type: 'group', left: 'center', top: 70, width: 300, bounding: 'raw' }], series: [ { type: 'candlestick', name: '均价', data: data, itemStyle: { normal: { color: '#ff4500', color0: '#22ac38', borderColor: '#ff4500', borderColor0: '#22ac38' }, emphasis: { color: 'black', color0: '#444', borderColor: 'black', borderColor0: '#444' } } }] }; */ $("#trendDiv2 a").click(function(){ $("#trendDiv2 a").removeClass("active") $(this).addClass("active") //var v = $(this).attr("t-v"); loadRentTrends(city, region, name); }); /* 小区租金走势 */ function loadRentTrends(city, region, name){ var type = $("#trendDiv2 a.active").attr("t-v") axios.get("/rest/trend/distRentTrends", { params: { city: city, region:region, name:name, type:type } }).then(function (response) { var re = response.data.data var categories = new Array(); var series = new Array(); var m = re.times; var pm = re.distMap var rooms = re.rooms; if(m && rooms.length>0){ for(var i=0;i