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 getDeviceList(); } //获取设备列表(电磁阀) 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; renderDevice(); } else { mui.toast(result.msg); renderDevice(); } }, 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() { console.log(JSON.stringify(deviceData)) 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 += '