YYC
2023-06-09 5132d695e4edc00e2a80f7bf40b5164be34e9499
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
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 chooseStartDate() {
    var dtpicker = new mui.DtPicker({
        type: "date", //设置日历初始视图模式 
        // beginDate: new Date(2015, 04, 25), //设置开始日期 
        // endDate: new Date(2016, 04, 25), //设置结束日期 
        value: startTime
    })
    var start = startTime;
    dtpicker.show(function(e) {
        startTime = e.value
        document.getElementById("start").value = e.value
        if (start != startTime) {
            getEsDetailList();
        }
    })
}
 
function chooseEndDate() {
    var dtpicker = new mui.DtPicker({
        type: "date", //设置日历初始视图模式 
        // beginDate: new Date(2015, 04, 25), //设置开始日期 
        // endDate: new Date(2016, 04, 25), //设置结束日期 
        value: endTime
    })
    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 += '<div class="wp"><div class="m-ck-cont"><div class="g-titck1">' + item.depotName + '</div>'
            html += '<div class="m-energy1"><div class="inner"><div class="con con1">'
            html += '<div class="num"><div class="l"></div>' + item.startEs +
                ' <span> KWh</span></div><div class="desc">起始能耗</div></div></div>'
            html += '<div class="inner"><div class="con con2">'
            html += '<div class="num"><div class="l"></div>' + item.endEs +
                ' <span> KWh</span></div><div class="desc">截止能耗</div></div></div></div>'
            html += '<div class="m-energy2"><div class="tit">能耗统计信息</div><ul class="ul-txtliste1">'
            html += '<li><div class="con"><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><div class="desc">无功电能</div></div></li>'
            html += '<li><div class="con"><div class="num">' + item.esSum +
                ' <span> KWh</span></div><div class="desc">总电能</div></div></li>'
            html += '</ul></div></div></div>'
        })
    } else {
        html += '<div class="wp"><div class="m-ck-cont"><div class="g-titck1">暂无能耗详情信息</div>'
        html += '<div class="m-energy1"><div class="inner"><div class="con con1">'
        html += '<div class="num"><div class="l"></div>0<span> KWh</span></div><div class="desc">起始能耗</div></div></div>'
        html += '<div class="inner"><div class="con con2">'
        html += '<div class="num"><div class="l"></div>0<span> KWh</span></div><div class="desc">截止能耗</div></div></div></div>'
        html += '<div class="m-energy2"><div class="tit">能耗统计信息</div><ul class="ul-txtliste1">'
        html += '<li><div class="con"><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><div class="desc">无功电能</div></div></li>'
        html += '<li><div class="con"><div class="num">0<span> KWh</span></div><div class="desc">总电能</div></div></li>'
        html += '</ul></div></div></div>'
        
    }
    $("#recordList").html(html);
}
 
mui('.mui-scroll-wrapper').scroll({
    indicators: false, //是否显示滚动条
    deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
    bounce: false, //是否启用回弹
    deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
});