var deviceData; var targetStatus; //阀门控制 var data = { "interfaceId": "5402", "outId": "10402", "reqDateTime": new Date(), "tokenAuth": "", "data": { "deptId": "", "depotId": "", "type": "09", "passCode": "", "serId": "", "targetStatus":"", "batchTag":"" } }; //设备列表 - 电磁阀 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() { 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 += '
仓库正面
' } if (backList && backList.length > 0) { html += '
仓库反面
' } if (leftList && leftList.length > 0) { html += '
仓库左侧面
' } if (rightList && rightList.length > 0) { html += '
仓库右侧面
' } } else { html += '
暂无数据
'; } } else { html += '
暂无数据
'; // html += '
1111
' } $("#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"); targetStatus = this.getAttribute("targetStatus"); data.data.targetStatus = targetStatus; 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"); console.log(JSON.stringify(data.data)) if(id==1){ data.data.targetStatus="OPEN" batchTag = false; } if(id==2){ data.data.targetStatus="CLOSE" batchTag = false; } if(id==3){ data.data.targetStatus="OPEN" batchTag = true; } if(id==4){ data.data.targetStatus="CLOSE" batchTag = true; } setTemp(); 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 });