Files
youfang-app/fangija-zsyf/views/intelligentHouse/mapDetail.html
T
xuhe@fangjia.com 130a45f501 aa
2018-04-12 11:38:28 +08:00

669 lines
24 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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/theme-orange.css">
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=0a7eM0lkIvpKGPiq1bMCfeH7"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js"></script>
<style>
.bar .button{top:0;}
.bar-tab{height:auto;z-index:11000;}
.bar-tab ~ .content{bottom:2.2rem;}
.list-block ul:before,.list-block ul:after{height:0;}
.bar-tab .list-block{width:100%;position:absolute;left:0;bottom:0;}
.bar-tab .show01 .item-title{color:#999;font-size:0.75rem;}
.bar-tab .show01 .item-title em{color:#F18D00;font-size:0.75rem;}
.selectContent{width:100%;background:#fff;top:inherit;bottom:0;}
.topic{border:none;padding:0;margin:0;}
.topic .topicTitle{border-bottom:none;font-size:inherit;width:100%;}
.topic .topicContent > p:first-child{margin-top:0;}
.mask{top:2.2rem;}
</style>
</head>
<body>
<div class="page-group">
<div class="page page-current">
<header class="bar bar-nav">
<button class="button button-link button-nav pull-left" onclick="back(),plus.nativeUI.closeWaiting();">
<span class="icon icon-left"></span>
</button>
<button class="button button-link button-nav pull-right" onclick="getAroundList()">
列表
</button>
<h1 class="title">智能选房</h1>
</header>
<nav class="bar bar-tab">
<div class="list-block media-list show01" id="districtShow01">
<ul>
<li>
<a onclick="getAroundList()" class="item-link item-content">
<div class="item-inner">
<div class="item-title-row">
<div class="item-title">匹配出满足需求的<em id="houseNum"></em>个小区</div>
</div>
</div>
</a>
</li>
</ul>
</div>
<div class="list-block media-list show02 dn" id="districtShow02">
</div>
<div class="selectContent dn">
<div class="topic" id="select_filter">
<div class="topicTitle">小区标签筛选</div>
<div class="topicContent" style="padding:0.2rem 0.75rem;">
<p class="buttons-row buttons-row01 buttons-row01a theme">
<a class="button">近地铁</a>
<a class="button">公交多</a>
<a class="button">买菜做饭</a>
<a class="button">商超便利</a>
</p>
<p class="buttons-row buttons-row01 buttons-row01a theme">
<a class="button">爱逛街</a>
<a class="button">在外面吃</a>
<a class="button">近医疗</a>
<a class="button">近幼儿园</a>
</p>
<p class="buttons-row buttons-row01 buttons-row01a theme">
<a class="button">近小学</a>
<a class="button">近中学</a>
</p>
</div>
<div class="content-block content-block01">
<div class="row">
<div class="col-50"><a href="#" class="button button-big button-fill theme reset_btn">重置</a></div>
<div class="col-50"><a href="#" class="button button-big button-fill theme confirm_btn">确定</a></div>
</div>
</div>
</div>
</div>
</nav>
<div class="mask dn"></div>
<div class="content">
<div class="districtMap01" id="map"></div>
<!--<img src="../../images/filter.png" class="filter_btn">
<div class="houseNum"><p>静安<br>55</p></div>
<div class="icon-house"></div>
<div class="icon-house" style="left:70%;"></div>-->
<img src="../../images/filter.png" class="filter_btn">
<input type="hidden" id="lat">
<input type="hidden" id="lng">
<input type="hidden" id="city">
<input type="hidden" id="address">
<input type="hidden" id="areaTag">
<input type="hidden" id="travelTime">
<input type="hidden" id="minAvgPrice">
<input type="hidden" id="maxAvgPrice">
<input type="hidden" id="tag">
</div>
</div>
</div>
<script type="text/javascript" src="http://g.alicdn.com/sj/lib/zepto/zepto.js" charset="utf-8"></script>
<script>
/* 关闭路由,以实现不同页面之间的相互跳转(仅开发环境需要) */
Zepto = $
$.config = {router: false}
</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="https://cdn.bootcss.com/light7/0.4.3/js/light7.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/mui.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../config.js"></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/city-app.js?version=${version!}' charset='utf-8'></script>
<script type='text/javascript' src='../../js/common.js' charset='utf-8'></script>
<script type='text/javascript' src='../../js/validate.js' charset='utf-8'></script>
<script type="text/javascript" src="../../js/log/log_stat.js" ></script>
<script>
document.addEventListener('plusready', onPlusReady, false);
var lat = 31.2221;
var lng = 121.359204;
var city = "上海";
var address="广顺小区";
var outTime="20分钟";
var budget=500;
var area="90-110㎡";
//var houseListJson=[]
/*var lat;
var lng;
var city;
var address;
var outTime;
var budget;
var area;*/
var houseListJson=[]
var mapConfig = {}
//扩展API加载完毕,现在可以正常调用扩展API
function onPlusReady(){
var self = plus.webview.currentWebview();
lat = self.lat;
lng = self.lng;
city = self.city;
address = self.address;
outTime = self.outTime;
budget = self.budget;
area = self.area;
mapConfig = {
isFirstLoad: true,
datas: {
// myIcon: "<div class='positionIcon'></div>",
myIcon: function (level) {
if(level != undefined && level > 1) {
var position = (level - 1) * -20;
return "<div class='icon-house' style='background-position-x: " + position + "px;'></div>"
} else {
return "<div class='icon-house'></div>"
}
},
markers: [],
center: new BMap.Point(lng, lat),
zoom: 12,
zoomThreshold:16,//超过次阀值,显示详细信息
mapData: null,
curCity: null,
minZoom: 10,
maxZoom: 20,
hasCity: false,
},
requestParams:{
fileId: null,
cityName: null,
region: null,
minTotalPrice: null,
maxTotalPrice: null,
minPrice: null,
maxPrice: null,
estateType: null,
minHouseYear: null,
maxHouseYear: null,
minArea: null,
maxArea: null
},
init: function (map) {
//启用滚轮放大缩小
if(map) {
this.mapObj = map;
} else {
this.mapObj = new BMap.Map("map", {minZoom:this.datas.minZoom,maxZoom:this.datas.maxZoom})
}
this.mapObj.enableScrollWheelZoom();
this.mapObj.centerAndZoom(this.datas.center, this.datas.zoom);
var that = this;
that.addMapControl();
mapConfig.loadCountMapData(true);
this.mapObj.addEventListener("zoomend", function() {
var map = that.mapObj
that.datas.zoom = map.getZoom()
var city = map.getCurrentCity().name.replace("市", '')
if(map.getZoom() >= that.datas.zoomThreshold) {
that.clearOverlays()
that.loadDetailMapData()
} else if(map.getZoom() < that.datas.zoomThreshold) {
that.clearOverlays()
that.loadCountMapData()
}
})
},
serializeParams: function () {
var params = this.requestParams;
params.lat = lat;
params.lng = lng;
params.houseList= houseListJson;
params.city= city;
return params;
},
addMapControl: function (reload) {
var scaleControl = new BMap.ScaleControl({
anchor : BMAP_ANCHOR_BOTTOM_LEFT
});
scaleControl.setUnit(BMAP_UNIT_METRIC);
this.mapObj.addControl(scaleControl);
var navControl = new BMap.NavigationControl({
anchor : BMAP_ANCHOR_TOP_LEFT,
type : BMAP_NAVIGATION_CONTROL_LARGE
});
this.mapObj.addControl(navControl);
},
loadDetailMapData: function (reload) {
var params = this.serializeParams()
var that = this
this.clearOverlays()
var houseList = $.parseJSON(params.houseList)
$.each(houseList, function (index, val) {
var icon = that.datas.myIcon(val.level)
var marker = new BMapLib.RichMarker(icon, new BMap.Point(val.lng, val.lat));
that._addClickListener(marker, val)
that.addPoint(marker)
})
},
loadCountMapData: function (reload) {
var params = this.serializeParams()
var that = this
this.clearOverlays()
var map = {};
var houseList = $.parseJSON(params.houseList)
$.each(houseList, function (index, val) {
if(map[val.district]!=undefined && map[val.district]!=null){
var value = map[val.district];
map[val.district]=value+1;
}else{
map[val.district]=1;
}
})
for(var i in map){
that._showCountWin(that.mapObj, i, i + "<br>"+map[i])
}
//下面列表数据变换
$("#districtShow01").show();
$("#districtShow02").hide();
},
setCenter: function (center) {
if(center) {
if(center instanceof BMap.Point) {
this.datas.center = center
this.mapObj.centerAndZoom(center, this.datas.zoom);
} else if(typeof center === 'string') {
if(cities[center]) {
this.datas.center = cities[center]
}
this.mapObj.centerAndZoom(center, this.datas.zoom);
}
}
},
_addClickListener: function (marker, data) {
var that = this
marker.addEventListener("click", function(e) {
var position = e.target._position
var mp = that.mapObj
//重新移动中心点
var pixel = mp.pointToPixel(position);
pixel.y = pixel.y-150;
var newCenterPoint = mp.pixelToPoint(pixel);
mp.centerAndZoom(newCenterPoint, that.datas.zoom);
$('.icon-house01').each(function (i) {
$(this).attr('class', "icon-house");
})
this._container.children[0].className = "icon-house01";
var html="";
html += '<ul><li>'+
"<a onclick=clicked('${basePath}/district/details?city="+data.city+"&region="+data.district+"&name="+data.name+"',true) class='external item-content'>"+
'<div class="item-inner">'+
'<div class="item-title-row"><div class="item-title">'+data.name+'</div><div class="item-after"><em>¥'+data.avgPrice+'元/㎡</em></div></div>'+
'<div class="item-title-row"><div class="item-title"><i class="icon icon-address03"></i><small>'+data.city+data.district+data.address+'</small></div>'+
'<div class="item-after"><span>距您'+data.distance+'m</span></div></div><div class="item-subtitle"><span class="tag">';
var count = 0;
for(var i in data.poiTags){
if(count<3){
html+='<small class="small">'+data.poiTags[i]+'</small>';
}
count++;
}
html+='</span></div></div></a></li>'
html+='</div></div></a></li></ul>';
$("#districtShow01").hide();
$("#districtShow02").show();
$("#districtShow02").html(html);
})
},
_showDetailWin: function(mp, point, popWinHtml) {
// var mp = this.map;
function ComplexCustomOverlay(point, text){
this._point = point;
this._text = text;
}
ComplexCustomOverlay.prototype = new BMap.Overlay();
ComplexCustomOverlay.prototype.initialize = function(map){
this._map = map;
var div = this._div = document.createElement("div");
$(div).attr("id", "popWin")
// $(div).attr("style", "position:absolute;background:#fff;box-shadow: 1px 1px 5px rgba(93,93,93,0.75);border-radius: 5px;z-index:"+BMap.Overlay.getZIndex(this._point.lat));
$(div).attr("style", "position:absolute;background:#fff;box-shadow: 1px 1px 5px rgba(93,93,93,0.75);border-radius: 5px;");
$(div).append(popWinHtml)
mp.getPanes().labelPane.appendChild(div);
return div;
}
ComplexCustomOverlay.prototype.draw = function(){
var map = this._map;
var pixel = map.pointToOverlayPixel(this._point);
this._div.style.left = pixel.x - 2 + "px";
this._div.style.top = pixel.y - $(this._div).height() + "px";
}
mp.addOverlay(new ComplexCustomOverlay(point, popWinHtml));
},
clearOverlays: function () {
this.datas.markers = []
this.mapObj.clearOverlays();
this.showDistrict(this.mapObj, address);
},
addPoint: function (point, level) {
if(point) {
if(point instanceof BMap.Point) {
var pointIcon = this.datas.myIcon()
var marker = new BMapLib.RichMarker(pointIcon, point);
this.addPoint(marker)
} else if(point instanceof BMapLib.RichMarker || point instanceof BMap.Marker) {
this.datas.markers.push(point);
this.mapObj.addOverlay(point);
}
}
},
showDistrict: function (mp, text) {
var that = this
// 编写自定义函数,创建标注
var marker = new BMap.Marker(this.datas.center);
var point = new BMap.Point(lng, lat);
function CountOverlay(city, text){
this._city = city;
this._point = point;
this._text = text;
}
CountOverlay.prototype = new BMap.Overlay();
CountOverlay.prototype.initialize = function(map){
//this._map = this.mapObj;
var div = this._div = document.createElement("div");
div.style.position = "absolute";
div.style.zIndex = BMap.Overlay.getZIndex(20000);
div.style.backgroundColor = "grey";
div.style.border = "1px solid grey";
div.style.color = "white";
div.style.height = "25px";
div.style.padding = "2px";
div.style.lineHeight = "18px";
div.style.whiteSpace = "nowrap";
div.style.MozUserSelect = "none";
div.style.fontSize = "12px";
div.style.cursor = "pointer";
var span = this._span = document.createElement("span");
span.style.lineHeight = "inherit";
span.style.minWidth = "25px";
span.style.textAlign = "center";
div.appendChild(span);
span.appendChild(document.createTextNode(this._text));
var arrow = this._arrow = document.createElement("div");
arrow.style.position = "absolute";
arrow.style.width = "11px";
arrow.style.height = "10px";
arrow.style.top = "24px";
arrow.style.left = "28px";
arrow.style.overflow = "hidden";
div.appendChild(arrow);
mp.getPanes().labelPane.appendChild(div);
return div;
}
CountOverlay.prototype.draw = function(){
//var map = this._map;
var pixel = mp.pointToOverlayPixel(this._point);
this._div.style.left = pixel.x - parseInt(this._arrow.style.left) - 13 + "px";
this._div.style.top = pixel.y - 60 + "px";
}
mp.addOverlay(new CountOverlay(city, text));
marker.disableMassClear();
mp.addOverlay(marker);
},
_showCountWin: function (mp, region, text) {
var localSearch = new BMap.LocalSearch(mp);
localSearch.setSearchCompleteCallback(function (searchResult) {
    var poi = searchResult.getPoi(0);
    var lng = poi.point.lng;
    var lat = poi.point.lat;
var point = new BMap.Point(lng,lat)
var that = this
function CountOverlay(region, text){
this._region = region;
this._point = point;
this._text = text;
}
CountOverlay.prototype = new BMap.Overlay();
CountOverlay.prototype.initialize = function(map){
this._map = map;
var div = this._div = document.createElement("div");
div.setAttribute("id", "regionCount")
//div.setAttribute("onclick", "showDetail("+lng+","+lat+","+mp+")")
//div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
div.style.zIndex = 1000;
div.style.width = "3.5rem";
div.style.height = "3.5rem";
div.style.border = "solid 2px #fff";
div.style.borderRadius = "100%";
div.style.background = "#f74949";
div.style.opacity = "0.9";
div.style.position = "absolute";
//div.style.left = "40%";
//div.style.top = "20%";
var p = this._p = document.createElement("p");
p.style.color = "#fff";
p.style.fontSize = "0.75rem"
p.style.textAlign = "center"
p.style.lineHeight = "1rem";
div.appendChild(p);
$(p).append($('<div>'+this._text+'</div>'));
div.addEventListener('click', function(e){
mp.centerAndZoom(city+region, map.getZoom() + 2);
})
div.addEventListener("touchstart",function(e){
mp.centerAndZoom(city+region, map.getZoom() + 2);
})
mp.getPanes().labelPane.appendChild(div);
return div;
}
CountOverlay.prototype.draw = function(){
var map = this._map;
var pixel = map.pointToOverlayPixel(this._point);
this._div.style.left = pixel.x - 41 + "px";
this._div.style.top = pixel.y - 60 + "px";
}
mp.addOverlay(new CountOverlay(city, text));
  });
   localSearch.search(region);
}
}
mapInit();
//setTimeout("mapInit()","1000");
}
function mapInit(){
/*lat = 31.2221;
lng = 121.359204;
city = "上海";
address="广顺小区";
outTime="20分钟";
budget=500;
area="90-110㎡";*/
axios.get("/rest/intelligentHouse/mapDetail", {
params: {
city: city,
lat:lat,
lng:lng,
address:address,
outTime:outTime,
budget:budget,
area:area
}
})
.then(function (response) {
houseListJson = response.data.data.houseListJson;
$("#city").val(response.data.data.city);
$("#address").val(response.data.data.address);
$("#areaTag").val(response.data.data.areaTag);
$("#lng").val(response.data.data.lng);
$("#lat").val(response.data.data.lat);
$("#travelTime").val(response.data.data.travelTime);
$("#minAvgPrice").val(response.data.data.minAvgPrice);
$("#maxAvgPrice").val(response.data.data.maxAvgPrice);
$("#houseNum").text(response.data.data.houseNum);
//mapInit();
mapConfig.init()
$('#map').on('click', ".positionBox .close", function (e) {
mapConfig.hidePopWin()
})
})
.catch(function (error) {
console.log(error);
});
}
//mapInit()
$(document).ready(function(){
});
/*var t1;
function mapInit(){
t1 = window.setTimeout(loadMap,1000);
}
function loadMap(){
if(lng && lat){
mapConfig.init();
window.clearTimeout(t1);
}
}*/
function getAroundList(){
var city = $("#city").val();
var address = $("#address").val();
var areaTag = $("#areaTag").val();
var lng = $("#lng").val();
var lat = $("#lat").val();
var travelTime = $("#travelTime").val();
var minAvgPrice = $("#minAvgPrice").val();
var maxAvgPrice = $("#maxAvgPrice").val();
var obj = $("#select_filter .topicContent .button");
var tag = "";
$.each(obj, function(key, val) {
if(obj[key].className.indexOf("active")!=-1){
tag += "_"+obj[key].text;
}
});
mui.openWindow({
url: 'aroundDetail.html',
id:'aroundDetail.html',
extras:{
city:city,
address:address,
areaTag:areaTag,
lng:lng,
lat:lat,
travelTime:travelTime,
minAvgPrice:minAvgPrice,
maxAvgPrice:maxAvgPrice,
tag:tag,
orderBy:0
}
});
/*var url = "${basePath}/intelligentHouse/aroundDetail?city="+city+"&areaTag="+areaTag+"&lng="+lng+"&lat="+lat+
"&travelTime="+travelTime+"&minAvgPrice="+minAvgPrice+"&maxAvgPrice="+maxAvgPrice+"&tag="+tag+"&orderBy=0"+"&address="+address;
clicked(url,true);*/
}
/* 点击图标出现小区信息 */
function turnMap(){
var city = $("#city").val();
var address = $("#address").val();
var areaTag = $("#areaTag").val();
var lng = $("#lng").val();
var lat = $("#lat").val();
var travelTime = $("#travelTime").val();
var minAvgPrice = $("#minAvgPrice").val();
var maxAvgPrice = $("#maxAvgPrice").val();
var obj = $("#select_filter .topicContent .button");
var tag = "";
$.each(obj, function(key, val) {
if(obj[key].className.indexOf("active")!=-1){
tag += "_"+obj[key].text;
}
});
axios.get("/rest/intelligentHouse/mapDetail2", {
params: {
city: city,
areaTag:areaTag,
lat:lat,
lng:lng,
address:address,
travelTime:travelTime,
minAvgPrice:minAvgPrice,
maxAvgPrice:maxAvgPrice,
tag:tag
}
})
.then(function (response) {
houseListJson = response.data.data.houseListJson;
$("#houseNum").text(response.data.data.houseNum);
mapConfig.init();
})
.catch(function (error) {
console.log(error);
});
/*window.location.href="../intelligentHouse/mapDetail2?city="+city+"&areaTag="+areaTag+"&lng="+lng+"&lat="+lat+
"&travelTime="+travelTime+"&minAvgPrice="+minAvgPrice+"&maxAvgPrice="+maxAvgPrice+"&tag="+tag+"&address="+address;*/
}
/* 小区标签筛选 */
$(".filter_btn").on("click", function () {
$(".selectContent").show();
$(".mask").show();
});
$(".reset_btn").on("click", function () {
$(".button").removeClass("active");
});
$(".confirm_btn,.mask").on("click", function () {
$(".selectContent").hide();
$(".mask").hide();
turnMap();
});
$("body").delegate(".button","click",function(){
if($(this).hasClass("active")){
$(this).removeClass("active");
}else{
$(this).addClass("active");
}
});
/* 地图 */
/*$(document).ready(function(){
// 百度地图API功能
var map0 = new BMap.Map("map");
var point0 = new BMap.Point(lng, lat);
map0.centerAndZoom(point0, 17);
map0.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
});*/
</script>
</body>
</html>