var uid = $("#3dnzNxplgTiHaddR",top.window.document).val();
|
var markers = [];
|
var companyId = '';
|
var mark_last;//记录上一次点击的mark
|
|
var Home = {
|
id: "VersionTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1,
|
businessType:null,//存储企业信息
|
};
|
|
/**
|
* 点击添加信息
|
*/
|
Home.openNetCarInfo = function (e) {
|
var id = e.getExtData()[0];
|
var index = layer.open({
|
type: 2,
|
title: '详细数据',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/home/openNetCarInfo?id=' + id,
|
});
|
this.layerIndex = index;
|
};
|
|
|
|
Home.onlineDriver = function (e) {
|
var id = e.getExtData()[0];
|
var index = layer.open({
|
type: 2,
|
title: '在线司机',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/home/showOnlineDriver',
|
});
|
this.layerIndex = index;
|
};
|
|
|
$(function () {
|
var first = $('.breadcrumb').children('li:first').children('a');
|
first.css({
|
'color': '#AB2626'
|
})
|
var className = first.attr('class');
|
$('.content').hide();
|
$('#' + className + 'Div').show();
|
|
|
$('.breadcrumb').find('a').on('click', function () {
|
$('.breadcrumb').children('li').each(function () {
|
$(this).children('a').removeAttr('style');
|
})
|
|
$(this).css({
|
'color': '#AB2626'
|
});
|
var className = $(this).attr('class');
|
$('.content').hide();
|
$('#' + className + "Div").show();
|
switch (className) {
|
case "statistics":
|
getData();
|
break;
|
case "map":
|
var companyId = $('#branchOffice1').val();
|
if(null != companyId && '' != companyId){
|
Home.webSocketClient(companyId);
|
}else{
|
Home.webSocketClient(null);
|
}
|
break;
|
case "order":
|
Home.getAllOrder();
|
break;
|
}
|
|
})
|
|
|
|
laydate.render({
|
elem: '#addDate', //指定元素
|
format: 'yyyy-MM-dd',//日期格式
|
value: new Date(),//默认值
|
zIndex: 99999999,//层叠顺序
|
trigger: 'click',
|
done: function(value, date, endDate){
|
getData();
|
console.log(value); //得到日期生成的值,如:2017-08-18
|
}
|
});
|
laydate.render({
|
elem: '#rangeDate', //指定元素
|
format: 'yyyy-MM-dd',//日期格式
|
range: true,
|
value: '',//默认值
|
zIndex: 99999999,//层叠顺序
|
trigger: 'click',
|
done: function(value, date, endDate){
|
getData();
|
console.log(value); //得到日期生成的值,如:2017-08-18
|
}
|
});
|
getData();
|
getCompanyByUid();
|
// setInterval(function () {
|
// Home.webSocketClient(null);
|
// }, 60000 * 5);
|
// setInterval(function () {
|
// Home.getAllOrder();
|
// }, 60000 * 5);
|
});
|
|
|
|
var map = new AMap.Map('container',{
|
resizeEnable: true,
|
zoom:10
|
});
|
|
|
var map_ = new AMap.Map('container_',{
|
resizeEnable: true,
|
mapStyle: 'amap://styles/1de318cbb8d12c02303a22c550b9ccc9',
|
zoom:10
|
});
|
|
var mouseTool = new AMap.MouseTool(map);
|
//监听draw事件可获取画好的覆盖物
|
var overlays = [];
|
var name = null;
|
var coordinate = '';//存储坐标
|
mouseTool.on('draw',function(e){
|
overlays.push(e.obj);
|
console.log(e.obj.getPath());
|
|
switch (name) {
|
case 'polyline':{//折线图
|
var polyline = e.obj.getPath();
|
getCoordinate(polyline);
|
break;
|
}
|
case 'polygon':{//多边形
|
var polygon = e.obj.getPath();
|
getCoordinate(polygon);
|
break;
|
}
|
case 'rectangle':{//矩形
|
var rectangle = e.obj.getPath();
|
getCoordinate(rectangle);
|
break;
|
}
|
case 'circle':{//圆行
|
var center = e.obj.getCenter();
|
var radius = e.obj.getRadius();
|
if(radius > 5000){
|
Feng.error("创建电子围栏失败,圆半径不能大于5000米");
|
return;
|
}
|
coordinate = center.lng + ',' + center.lat + ';' + radius;
|
break;
|
}
|
}
|
console.log(coordinate);
|
})
|
|
|
function getCompanyByUid() {
|
$.ajax({
|
url: Feng.ctxPath + "/home/getCompanyInfoByUserId",
|
type: 'POST',
|
success: function (res) {
|
var str = '<option value="">----请选择----</option>';
|
for(var i in res){
|
str += '<option value="' + res[i].id + '">' + res[i].name + '</option>'
|
}
|
$('#branchOffice').html(str);
|
$('#branchOffice1').html(str);
|
}
|
});
|
}
|
|
|
|
|
|
|
function getData() {
|
var branchOffice = $('#branchOffice').val();
|
var addDate = $('#addDate').val();
|
var date = $('#rangeDate').val();
|
var data = new FormData();
|
if(null != branchOffice && '' != branchOffice){
|
data.append("companyId", branchOffice);
|
}
|
if(null != addDate && '' != addDate){
|
data.append("addDate", addDate);
|
}
|
if(null != date && date != ''){
|
data.append("start", date.split(' - ')[0]);
|
data.append("end", date.split(' - ')[1]);
|
}
|
|
$.ajax({
|
url: Feng.ctxPath + "/home/getSumData",
|
type: 'POST',
|
contentType: false,
|
processData: false,
|
data: data,
|
success: function (res) {
|
var operationStatus = res.operationStatus;
|
var operationSum = res.operationSum;
|
var operationGrow = res.operationGrow;
|
var operationTrend = res.operationTrend;
|
|
$('#newPassengerInfo').text(operationStatus.passengerInfo == null ? 0 : operationStatus.passengerInfo);
|
$('#newNetcardriver').text(operationStatus.netcardriver == null ? 0 : operationStatus.netcardriver);
|
$('#orderDetail1').text(operationStatus.orderDetail1 == null ? 0 : operationStatus.orderDetail1);
|
$('#orderDetail2').text(operationStatus.orderDetail2 == null ? 0 : operationStatus.orderDetail2);
|
$('#orderDetail3').text(operationStatus.orderDetail3 == null ? 0 : operationStatus.orderDetail3);
|
$('#orderDetail4').text(operationStatus.orderDetail4 == null ? 0 : operationStatus.orderDetail4);
|
$('#orderDetail5').text(operationStatus.orderDetail5 == null ? 0 : operationStatus.orderDetail5);
|
|
$('#passengerInfoSum').text(operationSum.passengerInfoSum == null ? 0 : operationSum.passengerInfoSum);
|
$('#netcarDriverSum').text(operationSum.netcarDriverSum == null ? 0 : operationSum.netcarDriverSum);
|
$('#netCarSum').text(operationSum.netCarSum == null ? 0 : operationSum.netCarSum);
|
$('#orderDetailSum').text(operationSum.orderDetailSum == null ? 0 : operationSum.orderDetailSum);
|
$('#paiceSum').text(operationSum.paiceSum == null ? 0 : operationSum.paiceSum);
|
$('#paySum').text(operationSum.paySum == null ? 0 : operationSum.paySum);
|
|
$('#passengerInfoSum1').text(operationGrow.passengerInfoSum == null ? 0 : operationGrow.passengerInfoSum);
|
$('#netcarDriverSum1').text(operationGrow.netcarDriverSum == null ? 0 : operationGrow.netcarDriverSum);
|
$('#orderDetail11').text(operationGrow.orderDetail1 == null ? 0 : operationGrow.orderDetail1);
|
$('#orderDetail21').text(operationGrow.orderDetail2 == null ? 0 : operationGrow.orderDetail2);
|
$('#orderDetail31').text(operationGrow.orderDetail3 == null ? 0 : operationGrow.orderDetail3);
|
$('#orderDetail41').text(operationGrow.orderDetail4 == null ? 0 : operationGrow.orderDetail4);
|
$('#orderDetail51').text(operationGrow.orderDetail5 == null ? 0 : operationGrow.orderDetail5);
|
$('#paySum1').text(operationGrow.paySum == null ? 0 : operationGrow.paySum);
|
$('#paiceSum1').text(operationGrow.paiceSum == null ? 0 : operationGrow.paiceSum);
|
|
$('#orderDetailSum1').sparkline(operationTrend.orderDetailSum, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
$('#passengerInfoSum2').sparkline(operationTrend.passengerInfoSum, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
$('#orderDetail12').sparkline(operationTrend.orderDetail1, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
$('#orderDetail22').sparkline(operationTrend.orderDetail2, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
$('#orderDetail32').sparkline(operationTrend.orderDetail3, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
$('#orderDetail42').sparkline(operationTrend.orderDetail4, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
$('#orderDetail52').sparkline(operationTrend.orderDetail5, {
|
lineColor:'green',
|
width: '100%',
|
height: '33px'
|
});
|
}
|
});
|
}
|
|
|
Home.webSocketClient = function (companyId) {
|
$.ajax({
|
url: Feng.ctxPath + '/home/getDriverPosition',
|
type: 'POST',
|
data: {
|
companyId: companyId,
|
//暂定修改此处,不改方法
|
state:$("#driverState").val()
|
},
|
success: function (res) {
|
map.remove(markers);
|
markers = [];
|
var data = res.driver;
|
var order = res.order;
|
var d = '';
|
for(var i in data){
|
var driver = data[i].driver;
|
var driverId = driver.id
|
var state='<span style="font-size:12px;padding:3px 3px;float: right" class="label label-error">离</span>';
|
if("2"==driver.state){
|
state='<span style="font-size:12px;padding:3px 3px;float: right" class="label label-warning">听</span>';
|
}else if("3"==driver.state){
|
state='<span style="font-size:12px;padding:3px 3px;float: right" class="label label-primary">载</span>';
|
}
|
d += '<li style="font-size: 12px;" class="list-group-item" ondblclick="Home.dblclickDriver('+i+')" id="' + driverId + '">' + driver.name + '-' + driver.phone +state+ '</li>';
|
if('' != data[i].lon){
|
// 创建 AMap.Icon 实例:
|
var icon = new AMap.Icon({
|
size: new AMap.Size(40, 50), // 图标尺寸
|
image: '/static/car.png', // Icon的图像
|
// imageOffset: new AMap.Pixel(0, -60), // 图像相对展示区域的偏移量,适于雪碧图等
|
imageSize: new AMap.Size(40, 50), // 根据所设置的大小拉伸或压缩图片
|
});
|
|
var marker = new AMap.Marker({
|
position: new AMap.LngLat(data[i].lon, data[i].lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
offset: new AMap.Pixel(-10, -10),
|
icon: icon, // 添加 Icon 实例
|
});
|
marker.setExtData([driverId])
|
marker.on('click', function(){
|
Home.openNetCarInfo(this);
|
});
|
//console.log(marker);
|
markers.push(marker)
|
}
|
}
|
$('#netcardriver').html(d);
|
map.add(markers);
|
|
//订单数据
|
var privateCar=order.privateCar;
|
var zhuanche = order.zhuanche;
|
var kuacheng = order.kuacheng;
|
var chuzu = order.chuzu;
|
var kuahceng = order.kuahceng;
|
var o = '';
|
$('#order').html(o);
|
console.log(order);
|
var zc = '<div class="list-group"><a href="#" class="list-group-item active">专车未接订单</a>'
|
for(var i in privateCar){
|
zc += '<a href="#" class="list-group-item"><p class="list-group-item-text">起点:' + privateCar[i].start + '</p><p class="list-group-item-text">终点:' + privateCar[i].end + '</p>' +
|
'<p class="list-group-item-text">下单时间:' + privateCar[i].travelTime + '</p><p class="list-group-item-text">车型:' + privateCar[i].carModel + '</p>' +
|
'<p class="list-group-item-text">人数:' + privateCar[i].num + '</p></a>';
|
}
|
zc += '</div>';
|
o += zc;
|
|
var kc = '<div class="list-group"><a href="#" class="list-group-item active">跨城出行未接订单</a>'
|
for(var i in kuacheng){
|
kc += '<a href="#" class="list-group-item"><p class="list-group-item-text">起点:' + kuacheng[i].start + '</p><p class="list-group-item-text">终点:' + kuacheng[i].end + '</p>' +
|
'<p class="list-group-item-text">下单时间:' + kuacheng[i].travelTime + '</p><p class="list-group-item-text">车型:' + kuacheng[i].carModel + '</p>' +
|
'<p class="list-group-item-text">人数:' + kuacheng[i].num + '</p></a>';
|
}
|
kc += '</div>';
|
o += kc;
|
|
var cz = '<div class="list-group"><a href="#" class="list-group-item active">出租车未接订单</a>'
|
for(var i in chuzu){
|
cz += '<a href="#" class="list-group-item"><p class="list-group-item-text">起点:' + chuzu[i].start + '</p><p class="list-group-item-text">终点:' + chuzu[i].end + '</p>' +
|
'<p class="list-group-item-text">下单时间:' + chuzu[i].travelTime + '</p><p class="list-group-item-text">车型:' + chuzu[i].carModel + '</p>' +
|
'<p class="list-group-item-text">人数:' + chuzu[i].num + '</p></a>';
|
}
|
cz += '</div>';
|
o += cz;
|
|
var cx = '<div class="list-group"><a href="#" class="list-group-item active">城乡出行未接订单</a>'
|
for(var i in kuahceng){
|
cx += '<a href="#" class="list-group-item"><p class="list-group-item-text">起点:' + kuahceng[i].start + '</p><p class="list-group-item-text">终点:' + kuahceng[i].end + '</p>' +
|
'<p class="list-group-item-text">下单时间:' + kuahceng[i].travelTime + '</p><p class="list-group-item-text">车型:' + kuahceng[i].carModel + '</p>' +
|
'<p class="list-group-item-text">人数:' + kuahceng[i].num + '</p></a>';
|
}
|
cx += '</div>';
|
o += cx;
|
|
$('#order').html(o);
|
}
|
})
|
}
|
|
|
|
Home.getAllOrder = function () {
|
$.ajax({
|
url: Feng.ctxPath + '/home/getAllOrder',
|
type: 'POST',
|
data: {
|
companyId: companyId,
|
uid: uid
|
},
|
success: function (res) {
|
var style = [{
|
url: 'https://a.amap.com/jsapi_demos/static/images/mass0.png',
|
anchor: new AMap.Pixel(6, 6),
|
size: new AMap.Size(11, 11)
|
}, {
|
url: 'https://a.amap.com/jsapi_demos/static/images/mass1.png',
|
anchor: new AMap.Pixel(4, 4),
|
size: new AMap.Size(7, 7)
|
}, {
|
url: 'https://a.amap.com/jsapi_demos/static/images/mass2.png',
|
anchor: new AMap.Pixel(3, 3),
|
size: new AMap.Size(5, 5)
|
}];
|
|
var mass = new AMap.MassMarks(citys, {
|
opacity: 0.8,
|
zIndex: 111,
|
cursor: 'pointer',
|
style: style
|
});
|
|
var marker = new AMap.Marker({content: ' ', map: map_});
|
|
mass.on('mouseover', function (e) {
|
|
marker.setPosition(e.data.lnglat);
|
marker.setLabel({content: e.data.name})
|
});
|
|
var data = [];
|
for(var i in res){
|
var obj = {
|
lnglat: [res[i].lon, res[i].lat]
|
}
|
data.push(obj);
|
}
|
mass.setData(data);
|
mass.setMap(map_);
|
}
|
});
|
}
|
|
//双击司机li
|
/*Home.dblclickDriver=function (lon,lat) {
|
var markerPosition = [lon,lat];
|
map.panTo(markerPosition);
|
|
}*/
|
Home.dblclickDriver=function (i) {
|
var marker=markers[i];
|
var position=[marker.w.position.lng,marker.w.position.lat];
|
map.panTo(position);
|
var iconOld = new AMap.Icon({
|
size: new AMap.Size(40, 50), // 图标尺寸
|
image: '/static/car.png', // Icon的图像
|
imageSize: new AMap.Size(40, 50), // 根据所设置的大小拉伸或压缩图片
|
});
|
var iconNew = new AMap.Icon({
|
size: new AMap.Size(40, 50), // 图标尺寸
|
image: '/static/car_blue.jpg', // Icon的图像
|
imageSize: new AMap.Size(40, 50), // 根据所设置的大小拉伸或压缩图片
|
});
|
//标记当前这个的样式
|
marker.setIcon(iconNew);
|
//还原上一个的样式
|
if(typeof (mark_last) != "undefined"){
|
if(mark_last!=marker){
|
mark_last.setIcon(iconOld);
|
}
|
|
}
|
//记录为最后一个标记的
|
mark_last=marker;
|
}
|
|
|
function getData1() {
|
var companyId = null;
|
var branchOffice1 = $('#branchOffice1').val();
|
if('' != branchOffice1 && null != branchOffice1){
|
companyId = branchOffice1;
|
}
|
Home.webSocketClient(companyId);
|
}
|