YYC
2023-05-29 397dbf892f842c834af17a91c788c94fd96003f8
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
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), //设置结束日期 
 
    })
    dtpicker.show(function(e) {
        dateTime = e.value;
        document.getElementById("date").value = e.value
        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 style="text-align: center;font-size: 20px;color:#dd524d;">暂无远程抄表信息</div></div>';
    }
    $("#recordList").html(html);
}
 
mui('.mui-scroll-wrapper').scroll({
    indicators: false, //是否显示滚动条
    deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
    bounce: false, //是否启用回弹
    deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
});