| var dateTime; | 
| var meterList; | 
| var url; | 
| var data = { | 
|     "interfaceId": "5502", | 
|     "outId": "10502", | 
|     "reqDateTime": new Date(), | 
|     "tokenAuth": "", | 
|     "data": { | 
|         "deptId": "", | 
|         "dataTime": "" | 
|     } | 
| }; | 
|   | 
| 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; | 
|     dateTime = getDate(new Date()); | 
|     document.getElementById("date").value = dateTime; | 
|     getMeterList(); | 
| } | 
|   | 
| //日期格式化yyyy-MM-dd | 
| 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() { | 
|     var dtpicker = new mui.DtPicker({ | 
|         type: "date", //设置日历初始视图模式  | 
|         // beginDate: new Date(2015, 04, 25), //设置开始日期  | 
|         // endDate: new Date(2016, 04, 25), //设置结束日期  | 
|         value:dateTime | 
|     }) | 
|     var time = dateTime; | 
|     dtpicker.show(function(e) { | 
|         dateTime = e.value; | 
|         document.getElementById("date").value = e.value | 
|         if(time != dateTime){ | 
|             getMeterList(); | 
|         } | 
|     }) | 
| } | 
| //加减日期(天数) | 
| function addAndReduceDay(tag) { | 
|     var date = new Date(dateTime); | 
|     date = date.setDate(date.getDate() + tag); | 
|     date = new Date(date); | 
|     dateTime = getDate(date); | 
|     document.getElementById("date").value = dateTime | 
|     getMeterList(); | 
|   | 
| } | 
|   | 
| //渲染页面 | 
| function getMeterList() { | 
|     //赋值参数的日期 | 
|     data.data.dataTime = dateTime | 
|     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") { | 
|                 meterList = result.data; | 
|                 renderData(); | 
|             } else { | 
|                 renderData(); | 
|                 mui.toast(result.msg); | 
|                 console.log(JSON.stringify(result)) | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") | 
|         } | 
|     }) | 
|     // meterList = [{ | 
|     //         "depotId": "40", | 
|     //         "depotName": "里消第角务", | 
|     //         "epSum": 36, | 
|     //         "eqSum": 51, | 
|     //         "updateTime": "2004-04-04 17:19:14", | 
|     //         "esSum": 13 | 
|     //     }, | 
|     //     { | 
|     //         "depotId": "84", | 
|     //         "depotName": "石老权及", | 
|     //         "epSum": 48, | 
|     //         "eqSum": 57, | 
|     //         "updateTime": "1973-05-07 03:38:11", | 
|     //         "esSum": 7 | 
|     //     }, | 
|     //     { | 
|     //         "depotId": "39", | 
|     //         "depotName": "决听军经格", | 
|     //         "epSum": 36, | 
|     //         "eqSum": 3, | 
|     //         "updateTime": "2003-09-19 06:57:50", | 
|     //         "esSum": 72 | 
|     //     }, | 
|     //     { | 
|     //         "depotId": "77", | 
|     //         "depotName": "院什期由信", | 
|     //         "epSum": 44, | 
|     //         "eqSum": 59, | 
|     //         "updateTime": "1984-02-29 20:11:43", | 
|     //         "esSum": 92 | 
|     //     }, | 
|     //     { | 
|     //         "depotId": "21", | 
|     //         "depotName": "报候联有", | 
|     //         "epSum": 40, | 
|     //         "eqSum": 15, | 
|     //         "updateTime": "2016-03-20 19:38:43", | 
|     //         "esSum": "" | 
|     //     } | 
|     // ] | 
|      | 
|      | 
| } | 
| //渲染页面 | 
| function renderData() { | 
|     var html = '' | 
|     if (meterList && meterList.length > 0) { | 
|         $.each(meterList, function(index, item) { | 
|             html += '<div class="m-ck-cont"><div class="g-titck1">' + item.depotName + | 
|                 ' <span class="right">更新时间: ' + item.updateTime + '</span></div>'; | 
|             html += '<div class="m-energy2"><ul class="ul-txtliste1"><li><div class="con">'; | 
|             html += '<div class="num">' + item.epSum + | 
|                 ' <span> KWh</span></div><div class="desc">有功电能</div></div></li>'; | 
|             html += '<li><div class="con"><div class="num">' + item.eqSum + '<span> KWh</span></div>' | 
|             html += '<div class="desc">无功电能</div></div></li>'; | 
|             html += '<li><div class="con"><div class="num">' + (item.esSum == null || item.esSum == "" ? "--" : item.esSum) + ' <span> KWh</span></div>'; | 
|             html += '<div class="desc">总电能</div></div></li>' | 
|             html += '</ul></div></div>'; | 
|         }) | 
|     } else { | 
|         html += '<div class="m-ck-cont"><div class="g-titck1">暂无信息 <span class="right">更新时间: 2023-01-01 00:00:00</span></div>'; | 
|         html += '<div class="m-energy2"><ul class="ul-txtliste1"><li><div class="con">'; | 
|         html += '<div class="num">0<span> KWh</span></div><div class="desc">有功电能</div></div></li>'; | 
|         html += '<li><div class="con"><div class="num">0<span> KWh</span></div>' | 
|         html += '<div class="desc">无功电能</div></div></li>'; | 
|         html += '<li><div class="con"><div class="num">0<span> KWh</span></div>'; | 
|         html += '<div class="desc">总电能</div></div></li>' | 
|         html += '</ul></div></div>'; | 
|          | 
|     } | 
|     $("#recordList").html(html); | 
| } | 
|   | 
| mui('.mui-scroll-wrapper').scroll({ | 
|     indicators: false, //是否显示滚动条 | 
|     deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 | 
|     bounce: false, //是否启用回弹 | 
|     deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 | 
| }); |