YYC
2023-06-07 4f20ad52b8d4ab206e3458e488d3950eb2bfb5a3
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
var deviceData;
//阀门控制
var data = {
    "interfaceId": "5402",
    "outId": "10402",
    "reqDateTime": new Date(),
    "tokenAuth": "",
    "data": {
        "deptId": "",
        "depotId": "",
        "type": "09",
        "passCode": "",
        "serId": "",
        "targetStatus":""
    }
};
//设备列表 - 电磁阀
var data1 = {
    "interfaceId": "5401",
    "outId": "10401",
    "reqDateTime": new Date(),
    "tokenAuth": "",
    "data": {
        "deptId": "",
        "depotId": "",
        "type": "09",
    }
};
 
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 = user.deptId;
    data1.tokenAuth = user.tokenAuth;
    data1.data.deptId = user.deptId;
    //获取从上一个页面传递的数据
    var self = plus.webview.currentWebview();
    data.data.depotId = self.depotId
    data1.data.depotId = self.depotId
    // depotType = self.depotType
    // depotName = self.depotName
}
 
 
//获取设备列表(电磁阀)
function getDeviceList() {
    mui.ajax(url, {
        type: "POST",
        dataType: "json",
        crossDomain: true,
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify(data1),
        success: function(result) {
            if (result.code == "0000") {
                deviceData = result.data;
            } else {
                mui.toast(result.msg);
            }
        },
        error: function() {
            mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div")
        }
    })
 
}
 
 
//阀门管理
function setTemp() {
    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") {
                mui.toast(result.msg);
            } else {
                mui.toast(result.msg);
            }
        },
        error: function() {
            mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div")
        }
    })
}
 
//渲染页面
function renderDevice() {
    var html = '';
    if (deviceData) {
        var deviceList = deviceData.listDevice
        if (deviceList && deviceList.length > 0) {
            var frontList = [];
            var backList = [];
            var leftList = [];
            var rightList = [];
            $.each(deviceList, function(index, item) {
                if (item.location == '01') {
                    frontList.push(item)
                } else if (item.location == '02') {
                    backList.push(item)
                } else if (item.location == '03') {
                    leftList.push(item)
                } else if (item.location == '04') {
                    rightList.push(item)
                }
            })
            if (frontList && frontList.length > 0) {
                html += '<div class="m-tf"><div class="g-tittf1">仓库正面</div><ul class="ul-listmana1 ullisttf1">';
                $.each(frontList, function(index, item) {
                    if (item.location == '01') {
                        html += '<li><div class="con myfancy" passCode="' + item.passCode + '" serId="' +
                            item.serId +
                            '"  data-win="#win_kt"><div class="pic pic2"><img src="images/e2.png"></div>';
                        if (targetStatus == 'OPEN') {
                            html += '<div class="info out" style="background-image: url(images/e5.png);">' +
                                item.name + '</div>'
                        } else {
                            html += '<div class="info out" style="background-image: url(images/e9.png);">' +
                                item.name + '</div>'
                        }
                        html += '</div></div></li>'
                    }
                })
                html += '</ul></div>'
            }
            if (backList && backList.length > 0) {
                html += '<div class="m-tf"><div class="g-tittf1">仓库反面</div><ul class="ul-listmana1 ullisttf1">';
                $.each(backList, function(index, item) {
                    if (item.location == '02') {
                        html += '<li><div class="con myfancy" passCode="' + item.passCode + '" serId="' +
                            item.serId +
                            '" data-win="#win_fm"><div class="pic pic2"><img src="images/e2.png"></div>';
                        if (targetStatus == 'OPEN') {
                            html += '<div class="info full" style="background-image: url(images/e5.png);">' +
                                item.name + '</div>'
                        } else {
                            html += '<div class="info full" style="background-image: url(images/e9.png);">' +
                                item.name + '</div>'
                        }
                        html += '</div></div></li>'
                    }
                })
                html += '</ul></div>'
            }
            if (leftList && leftList.length > 0) {
                html += '<div class="m-tf"><div class="g-tittf1">仓库左侧面</div><ul class="ul-listmana1 ullisttf1">';
                $.each(leftList, function(index, item) {
                    if (item.location == '03') {
                        html += '<li><div class="con myfancy" passCode="' + item.passCode + '" serId="' +
                            item.serId +
                            '" data-win="#win_fm"><div class="pic pic2"><img src="images/e2.png"></div>';
                        if (targetStatus == 'OPEN') {
                            html += '<div class="info full" style="background-image: url(images/e5.png);">' +
                                item.name + '</div>'
                        } else {
                            html += '<div class="info full" style="background-image: url(images/e9.png);">' +
                                item.name + '</div>'
                        }
                        html += '</div></div></li>'
                    }
                })
                html += '</ul></div>'
            }
            if (rightList && rightList.length > 0) {
                html += '<div class="m-tf"><div class="g-tittf1">仓库右侧面</div><ul class="ul-listmana1 ullisttf1">';
                $.each(rightList, function(index, item) {
                    if (item.location == '04') {
                        html += '<li><div class="con myfancy" passCode="' + item.passCode + '" serId="' +
                            item.serId +
                            '" data-win="#win_fm"><div class="pic pic2"><img src="images/e2.png"></div>';
                        if (targetStatus == 'OPEN') {
                            html += '<div class="info full" style="background-image: url(images/e5.png);">' +
                                item.name + '</div>'
                        } else {
                            html += '<div class="info full" style="background-image: url(images/e9.png);">' +
                                item.name + '</div>'
                        }
                        html += '</div></div></li>'
                    }
                })
                html += '</ul></div>'
            }
        } else {
            html += '<div class="m-tf"><div class="g-tittf1" style="text-align: center;font-size: 20px;color:#dd524d>暂无数据</div>';
        }
    } else {
        html += '<div class="m-tf"><div class="g-tittf1" style="text-align: center;font-size: 20px;color:#dd524d>暂无数据</div>';
    }
    // $("#recordList").html(html);
}
 
//电磁阀操作
mui(".mui-scroll-wrapper").on("tap", ".m-tf ul li .con", function() {
    var passCode = this.getAttribute("passCode");
    var serId = this.getAttribute("serId");
    data.data.passCode = passCode;
    data.data.serId = serId;
    $('.m-pop').css('display', 'flex');
});
mui(".m-pop").on("tap", ".inner a", function() {
    var id = this.getAttribute("id");
    mui.toast(id);
    closePop();
});
//关闭弹窗
function closePop() {
    $(".m-pop").css('display', 'none');
}
$('.pop-bg,.m-pop .close').click(function(e) {
    e.stopPropagation();
    $('.m-pop').fadeOut();
});
 
 
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
});