var url; var electricList; var dateTime; var data = { "interfaceId": "5501", "outId": "10501", "reqDateTime": new Date(), "tokenAuth": "", "data": { "deptId": "" } }; 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()); getElectric(); } //日期格式化yyyy-MM-dd function getDate(date) { var year = date.getFullYear(); var month, day,hour,minute; month = date.getMonth() + 1; if (month > 0 && month <= 9) { month = "0" + month; } day = date.getDate() if (day > 0 && day <= 9) { day = "0" + day } hour = date.getHours(); minute = date.getMinutes(); return year + "-" + month + "-" + day + " "+ hour + ":" + minute } function getElectric() { 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") { electricList = result.data; renderData(); // console.log(JSON.stringify(result.data)) } else { renderData(); mui.toast(result.msg); console.log(JSON.stringify(result)) } }, error: function() { mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") } }) } //渲染页面 function renderData() { var html = ''; if (electricList && electricList.length > 0) { $.each(electricList, function(index, item) { html += '
  • '; if (item.depotType == '01') { html += ''; } else if (item.depotType == '02') { html += '' } if (item.depotType == '03') { html += '' } html += '' + item.depotName + '
    '; html += '
    更新时间: ' + (item.updateTime == null || item.updateTime == "" ? dateTime : item.updateTime) + '
    '; html += '
    ' + (item.ua == null || item.ua == "" ? "0" : item.ua) + ' V
    A相电压
    '; html += '
    ' + (item.ub == null || item.ub == "" ? "0" : item.ub) + ' V
    B相电压
    '; html += '
    ' + (item.uc == null || item.uc == "" ? "0" : item.uc) + ' V
    B相电压
    '; html += '
    ' + (item.ia == null || item.ib == "" ? "0" : item.ib) + ' V
    A相电流
    '; html += '
    ' + (item.ib == null || item.ic == "" ? "0" : item.ic) + ' V
    B相电流
    '; html += '
    ' + (item.ic == null || item.ic == "" ? "0" : item.ic) + ' V
    C相电流
    '; html += '
  • ' }) } else { html += '
  • '; html += ''; html += '暂无配电数据
    '; html += '
    更新时间: ' + dateTime + '
    '; html += '
    0 V
    A相电压
    '; html += '
    0 V
    B相电压
    '; html += '
    0 V
    B相电压
    '; html += '
    0 V
    A相电流
    '; html += '
    0 V
    B相电流
    '; html += '
    0 V
    C相电流
    '; html += '
  • ' } $("#recordList").html(html); } var slider = mui(".mui-slider"); slider.slider({ interval: 3000 }); mui('.mui-scroll-wrapper').scroll({ indicators: false, //是否显示滚动条 deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 bounce: false, //是否启用回弹 deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 });