var url = null; var startTime; var endTime = ""; var esDetailList; var data = { "interfaceId": "5503", "outId": "10503", "reqDateTime": new Date(), "tokenAuth": "", "data": { "deptId": "", "depotId": "", "startTime": "", "endTime": "" } }; function init() { var user = JSON.parse(localStorage.getItem('user')); var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId')); url = user.url + "/api-phone/v35/gateway"; data.tokenAuth = user.tokenAuth; data.data.deptId = selectDeptId; startTime = getDate(new Date()); document.getElementById("start").value = startTime; getEsDetailList(); } function getDate(date) { var year = date.getFullYear(); var month, day; month = date.getMonth() + 1; if (month > 0 && month <= 9) { month = "0" + month; } day = date.getDate() if (day > 0 && day <= 9) { day = "0" + day } return year + "-" + month + "-" + day } function chooseDate(tag) { var dtpicker = new mui.DtPicker({ type: "date", //设置日历初始视图模式 // beginDate: new Date(2015, 04, 25), //设置开始日期 // endDate: new Date(2016, 04, 25), //设置结束日期 }) if (tag == 'start') { var start = startTime; dtpicker.show(function(e) { startTime = e.value document.getElementById("start").value = e.value if(start != startTime){ getEsDetailList(); } }) } else { var end = endTime; dtpicker.show(function(e) { endTime = e.value; document.getElementById("end").value = e.value if(end != endTime){ getEsDetailList(); } }) } } function getEsDetailList() { data.data.startTime = startTime data.data.endTime = endTime console.log(JSON.stringify(data.data)) mui.ajax(url, { type: "POST", dataType: "json", crossDomain: true, contentType: "application/json;charset=utf-8", data: JSON.stringify(data), success: function(result) { if (result.code == "0000") { esDetailList = result.data; renderData(); } else { renderData(); mui.toast(result.msg); } }, error: function() { mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") } }) esDetailList = [{ "depotId": "16", "depotName": "值话各元", "startEs": "31", "endEs": "56", "epSum": "13", "eqSum": "37", "esSum": "25" }, { "depotId": "2", "depotName": "划点王数队", "startEs": "55", "endEs": "47", "epSum": "46", "eqSum": "42", "esSum": "59" }, { "depotId": "34", "depotName": "和多断们", "startEs": "78", "endEs": "24", "epSum": "37", "eqSum": "73", "esSum": "83" } ] } mui('.mui-content').on("tap", ".g-sobox div button", function() { data.data.depotId = document.getElementById("search").value getEsDetailList() }) //渲染页面 function renderData() { var html = ''; if (esDetailList && esDetailList.length > 0) { $.each(esDetailList, function(index, item) { html += '
' + item.depotName + '
' html += '
' html += '
' + item.startEs + ' KWh
起始能耗
' html += '
' html += '
' + item.endEs + ' KWh
截止能耗
' html += '
能耗统计信息
    ' html += '
  • ' + item.epSum + ' KWh
    有功电能
  • ' html += '
  • ' + item.eqSum + ' KWh
    无功电能
  • ' html += '
  • ' + item.esSum + ' KWh
    总电能
  • ' html += '
' }) } else { html += '
暂无能耗详情信息
'; } $("#recordList").html(html); } mui('.mui-scroll-wrapper').scroll({ indicators: false, //是否显示滚动条 deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 bounce: false, //是否启用回弹 deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 });