parksingledetail.js 17.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
/**
 * Created by mac on 17/12/13.
 */
//获取 上一个搜索页面传来的参数

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)return decodeURI(r[2]);
    return null;
}
// var searchUrl = window.location.href;
// var searchData = searchUrl.split("="); //截取 url中的“=”,获得“=”后面的参数
//停车场名称
var plName = decodeURI(GetQueryString('plName')); //decodeURI解码
//停车场类型
var plType = decodeURI(GetQueryString('type'));
//停车场编码
var plNo = decodeURI(GetQueryString('plNo'));
//停车场总车位数
var totalBerthsNum = decodeURI(GetQueryString('totalBerthsNum'));

$("#searchText span").text(plName);


var vehicleChart = echarts.init(document.getElementById('vehicleChart'));
var vehicleoption = {
    color: ['rgba(38,190,150,.8)', 'rgba(67,158,218,.8)'],
    tooltip: {
        trigger: 'axis'
    },

    grid: {
        top: '5%',
        left: '3%',
        right: '4%',
        bottom: '5%',
        containLabel: true
    },

    xAxis: {
        type: 'category',
        boundaryGap: true,
        data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日'],
        // data: xAxisData,
        axisLabel: {
            show: true,
            textStyle: {
                color: 'rgba(136,137,144,.8)',
            }
        },
        axisTick: {
            show: false,
        },
        axisLine: {
            show: false
        },

    },
    yAxis: {
        type: 'value',
        axisLabel: {
            show: true,
            textStyle: {
                color: 'rgba(136,137,144,.8)',
            }
        },
        axisTick: {
            show: false,
        },
        axisLine: {
            show: false
        },
    },
    series: [
        {
            name: '近7天收费趋势',
            type: 'line',
            data: [],
            symbol:'image://../../assets/pages/img/symbol.png',
            symbolOffset:[0,0],
            symbolSize:16,
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: '#8ec6ad',
                    }, {
                        offset: 1,
                        color: 'rgba(142,198,173,.1)'

                    }])
                }
            },
            // data: seriesInCount,

        },

    ]
};

vehicleChart.setOption(vehicleoption, true);
window.onresize = function () {
    vehicleChart.resize();
}


var fun = {
    init: function () {
        fun.incomeTrendCharts(7);
        fun.todayParkCarNumStatic([plNo]);
        fun.todayInCome([plNo]);
        fun.todayOccupyRate([plNo]);
        fun.createTableData();
        fun.parkLotDetailInfo([plNo]);
    },
    //近几天收入趋势折线图 num为第几天
    incomeTrendCharts: function (num) {
        var startDate = new Date();
        var endDate = new Date();
        startDate.setSeconds(0);
        startDate.setHours(0);
        startDate.setMinutes(0);
        startDate.setDate(startDate.getDate() - num);
        endDate.setDate(endDate.getDate() - 1);
        var req = {
            sysCode: sysComm.sysCode,
            plNos: [plNo],
            startDate: startDate.getTime(),
            endDate: endDate.getTime()
        }
        var inComeAjax = {
            method: "post",
            url: dataUrl.util.queryIncomeOfDay(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (res) {
                if (res.code == '8888') {
                    var data = res.data;
                    fun.handelIncomeTrendData(data);
                }
            }
        };
        sysAjax(inComeAjax);

    },
    handelIncomeTrendData: function (data) {
        var dateArray = [];
        var incomeArray = [];
        $.each(data, function (index, item) {
            dateArray.push(item.dayStr);
            incomeArray.push(fun.moneyFormatter(item.inCome));
        })
        vehicleoption.xAxis.data = dateArray;
        console.log(incomeArray)
        vehicleoption.series[0].data = incomeArray;
        vehicleChart.setOption(vehicleoption, true);
    },
    //今日停车次数统计
    todayParkCarNumStatic: function (plNos) {
        var beginTime = DateUtil.dataFormat(new Date().getTime(), "yyyy-MM-dd") + " 00:00:00";
        var endTime = DateUtil.dataFormat(new Date().getTime(), "yyyy-MM-dd") + " 23:59:59";
        var req = {
            sysCode: sysComm.sysCode,
            parkIdList: plNos,
            beginTime: beginTime,
            endTime: endTime,
        };
        var inComeAjax = {
            method: "post",
            url: dataUrl.util.queryParingCount(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (res) {
                if (res.code == '8888') {
                    var data = res.data;
                    fun.handelParkCarNumStaticData(data);
                }
            }
        };
        sysAjax(inComeAjax);
    },
    //处理停车次数统计
    handelParkCarNumStaticData: function (data) {

        var allCount = data[0].escapeCount + data[0].freeParkingCount + data[0].temporaryParkingCount + data[0].dayOrMonthCardParkCount;
        //进场车数量
        $('#inParkNum').html(allCount);
        //出场车数量
        $('#outParkNum').html(0);
        if (plType == 1) {
            //免费开闸 或者 逃逸的数量

            $('#freeCarNum').html(data[0].freeParkingCount);
            $("#freeCarNum").attr('data-value',data[0].freeParkingCount);
            $("#freeCarNum").counterUp({
                delay: 10,
                time: 1000
            });
        } else {
            //免费开闸 或者 逃逸的数量
            $('#freeCarNum').html(data[0].freeParkingCount);
            $("#freeCarNum").attr('data-value',data[0].freeParkingCount);
            $("#freeCarNum").counterUp({
                delay: 10,
                time: 1000
            });
        }


    },
    //今日收入-按路侧、封闭进行区分
	todayInCome:function(plNos) {
	    var req = {
	        sysCode: sysComm.sysCode,
	        parkIdList: plNos,
	    };
	    var inComeAjax = {
	        method: "post",
	        url: dataUrl.util.getTodayIncome(),
	        data: JSON.stringify(req),
	        contentType: 'application/json; charset=utf-8',
	        dataType: 'json',
	        success: function (res) {
	            if (res.code == '8888') {
	                var result = res.data;
					var html = '';
					html+=getMoneyYuan(result.payedTotalAmount)+getMoneySmallNumber(result.payedTotalAmount);
					$("#todayIncom").html(html);
                    $("#todayIncom").attr('data-value',html);
                    $("#todayIncom").counterUp({
                        delay: 10,
                        time: 1000
                    });
				}	
	
	        }
	    }
	    sysAjax(inComeAjax);
	},
	//今日占用率
	todayOccupyRate:function(plNos) {
	    var req = {
	        sysCode: sysComm.sysCode,
	        plNos: plNos,
	    }
	    var opt = {
	        method: 'post',
	        url: dataUrl.util.getRealtimeoccupationRate(),
	        data: JSON.stringify(req),
	        success: function (res) {
	            if (res.code == '8888') {
	                //获取数据成功
	                var data = res.data;
	                var freeBerth = data.freeBerthNum;
	                $("#freeBerth").html(freeBerth);
                    $("#freeBerth").attr('data-value',freeBerth);
                    $("#freeBerth").counterUp({
                        delay: 10,
                        time: 1000
                    });
	
	            }
	        }
	    }
	    sysAjax(opt);
	},
	//生成表格数据
    createTableData: function() {
        $('#recordtable').bootstrapTable('destroy').bootstrapTable({
            striped: true, //表格显示条纹
            //pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            showColumns: false,
            pageSize: 10, //每页显示的记录数
            pageList: [10, 15, 20], //记录数可选列表
            sidePagination: 'server', //表示服务端分页
            queryParamsType: 'limit',
            method: 'POST', //请求方法
            
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: tableLoadRequest, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                {
                    field: 'createTime',
                    title: '日期',
                    width: '30%',
                    align: 'left',
                    formatter:fun.datetimeFormatter
                },
                {
                    field: 'parkName',
                    title: '停车场',
                    width: '30%',
                    align: 'left'
                },
                
                {
                    field: 'orderTotalFee',
                    title: '金额(元)',
                    width: '20%',
                    align: 'left',
                    formatter: fun.moneyFormatter
                },
                {
                    field: 'payType',
                    title: '支付方式',
                    width: '20%',
                    align: 'left',
                    formatter: fun.payTypeFormatter
                }
                
            ]
        });

    },
    //停车场车位详情
    parkLotDetailInfo:function(plNos){
        var req = {
            sysCode: sysComm.sysCode,
            plNos: plNos,
        }
        var opt = {
            method: 'post',
            url: dataUrl.util.queryParkLotCarDetailInfo(),
            data: JSON.stringify(req),
            success: function (res) {
                if (res.code == '8888') {
                    //获取数据成功
                    var data = res.data;
                    fun.handelParkLotDetailInfo(data);
                }
            }
        }
        sysAjax(opt);

    },
    //处理车位详情信息
    handelParkLotDetailInfo:function(datas){
    	var rate = 0;
    	//今日进出车量
        $('#inParkNum').text(datas[0].inCarNum);
        $('#outParkNum').text(datas[0].outCarNum);
        
        //场内车辆
        $('#allCarNum').text(datas[0].allCarNum+'/'+totalBerthsNum);
        rate = ((datas[0].allCarNum)/totalBerthsNum*100).toFixed(2)+'%';
        $(".per-pross-first").eq(0).css("width",rate);
        $(".per-pross-icon").eq(0).css("left",rate);
        //场内授权车辆
        $('#vipCarNum').text(datas[0].vipCarNum+'/'+totalBerthsNum);
        rate = ((datas[0].vipCarNum)/totalBerthsNum*100).toFixed(2)+'%';
        $(".per-pross-first").eq(1).css("width",rate);
        $(".per-pross-icon").eq(1).css("left",rate);
        //场内临时车辆
        $('#tmpCar').text(datas[0].tmpCar+'/'+totalBerthsNum);
        rate = ((datas[0].tmpCar)/totalBerthsNum*100).toFixed(2)+'%';
        $(".per-pross-first").eq(2).css("width",rate);
        $(".per-pross-icon").eq(2).css("left",rate);


    },
    //金额处理
    moneyFormatter:function (value) {
        // console.log(typeof value)
        if(value==0 || value==undefined  || value==null){
            return 0;
        }else{
            return (value/100).toFixed(2);
        }
    },
    //时间处理
    datetimeFormatter: function(value, row, index) {
        if(value == null) {
            return "";
        } else {
            return DateUtils.long2String(value, 1);
        }
    },

	    
}
tableLoadRequest();
//支付方式
function payTypeFormatter(value){
    if(value == null) {
        return "";
    }
    switch (value){
        case 1:
            return '支付宝';
            break;
        case 2:
            return '微信';
            break;
        case 3:
            return '银联';
            break;
        case 4:
            return '微信公众号';
            break;
        case 5:
            return '账户余额';
            break;
        case 6:
            return '现金';
            break;
        case 7:
            return 'IC卡';
            break;
        default:
            break;
    }
};
//金额处理
function moneyFormatter(value) {
    // console.log(typeof value)
    if(value==0 || value==undefined  || value==null){
        return 0;
    }else{
        return (value/100).toFixed(2);
    }
};
//时间处理
 function datetimeFormatter(value) {
    if(value == null) {
        return "";
    } else {
        return DateUtils.long2String(value, 1);
    }
};
function tableLoadRequest(params) {
	var count = 20;
    var req={
    	sysCode:sysComm.sysCode,
    	count:count,
    	parkIds:[plNo]
    };
   
    var opt = {
        method: 'post',
        url: dataUrl.util.queryRecentOutParkOrder(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function(res) {
            console.log(res);
            if(res.code == '8888') {

                var data = res.data;
                $('#breakNewsList').empty();
                $.each(data,function (i,item) {
                    console.log(item.createTime);
                    $('#breakNewsList').append('<li><div>'+datetimeFormatter(item.createTime)+'</div><div>'+item.parkName+'</div><div>'+moneyFormatter(item.orderTotalFee)+'</div><div>'+payTypeFormatter(item.payType)+'</div></li>')
                })
                // data.rows = res.data;
                // data.total = count;
                // params.success(data);
                
            }
        }
    };
    sysAjax(opt);
}

fun.init();
//金额处理 取整元
function getMoneyYuan(value){
	return parseInt(value / 100);
}
//金额处理-取角、分 .34
function getMoneySmallNumber(value){
	var money = (value / 100).toFixed(2);
	return money.slice(money.length-3,money.length);
}

function ScrollText(content,btnPrevious,btnNext,autoStart,timeout,isSmoothScroll)
{
    this.Speed = 5;
    this.Timeout = timeout;
    this.stopscroll =false;
    this.isSmoothScroll= isSmoothScroll;
    this.LineHeight = 20;
    this.NextButton = this.$(btnNext);
    this.PreviousButton = this.$(btnPrevious);
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;

    if(this.PreviousButton)

    {
        this.PreviousButton.onclick = this.GetFunction(this,"Previous");
        this.PreviousButton.onmouseover = this.GetFunction(this,"MouseOver");
        this.PreviousButton.onmouseout = this.GetFunction(this,"MouseOut");
    }
    if(this.NextButton){
        this.NextButton.onclick = this.GetFunction(this,"Next");
        this.NextButton.onmouseover = this.GetFunction(this,"MouseOver");
        this.NextButton.onmouseout = this.GetFunction(this,"MouseOut");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this,"MouseOver");
    this.ScrollContent.onmouseout = this.GetFunction(this,"MouseOut");

    if(autoStart)
    {
        this.Start();
    }
}

ScrollText.prototype = {

    $:function(element)
    {
        return document.getElementById(element);
    },
    Previous:function()
    {
        this.stopscroll = true;
        this.Scroll("up");
    },
    Next:function()
    {
        this.stopscroll = true;
        this.Scroll("down");
    },
    Start:function()
    {
        if(this.isSmoothScroll)
        {
            this.AutoScrollTimer = setInterval(this.GetFunction(this,"SmoothScroll"), this.Timeout);
        }
        else
        {
            this.AutoScrollTimer = setInterval(this.GetFunction(this,"AutoScroll"), this.Timeout);
        }
    },
    Stop:function()
    {
        clearTimeout(this.AutoScrollTimer);
        this.DelayTimerStop = 0;
    },
    MouseOver:function()
    {
        this.stopscroll = true;
    },
    MouseOut:function()
    {
        this.stopscroll = false;
    },
    AutoScroll:function()
    {
        if(this.stopscroll)
        {
            return;
        }
        this.ScrollContent.scrollTop++;
        if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
        {
            this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Speed);
        }
        else
        {
            if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
            {
                this.ScrollContent.scrollTop = 0;
            }
            clearTimeout(this.ScrollTimer);
            //this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
        }
    },
    SmoothScroll:function()
    {
        if(this.stopscroll)
        {
            return;
        }
        this.ScrollContent.scrollTop++;
        if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
    },
    Scroll:function(direction)
    {

        if(direction=="up")
        {
            this.ScrollContent.scrollTop--;
        }
        else
        {
            this.ScrollContent.scrollTop++;
        }
        if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
        else if(parseInt(this.ScrollContent.scrollTop)<=0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }

        if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
        {
            this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Speed);
        }
    },
    GetFunction:function(variable,method,param)
    {
        return function()
        {
            variable[method](param);
        }
    }
}

function ignoreError() {
    return true;
}
window.onerror = ignoreError;
var scroll2 = new ScrollText("breakNewsList","pre2","next2",true,50,true);
scroll2.LineHeight = 63;