| var url = null; | 
| var pestData; | 
| var data = { | 
|     "interfaceId": "5306", | 
|     "sign": "10306", | 
|     "outId": "10306", | 
|     "reqDateTime": new Date(), | 
|     "tokenAuth": "", | 
|     "data": { | 
|         "deptId": "" | 
|     } | 
| }; | 
| //虫害采集参数 | 
| var data0 = { | 
|     "interfaceId": "5307", | 
|     "sign": "10307", | 
|     "outId": "10307", | 
|     "reqDateTime": new Date(), | 
|     "tokenAuth": "", | 
|     "data": { | 
|         "deptId": "", | 
|         "depotId": "" | 
|     } | 
| }; | 
|   | 
| //初始化数据 | 
| 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; | 
|     data0.tokenAuth = user.tokenAuth; | 
|     data0.data.deptId = selectDeptId; | 
|   | 
|     getPestData(); | 
| } | 
|   | 
| //获取仓库最新虫害采集信息 | 
| function getPestData() { | 
|     //发送请求获取仓库信息 | 
|     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") { | 
|                 pestData = result.data; | 
|                 renderPest(); | 
|             } else { | 
|                 mui.alert(result.msg, '提示', ["确定"], function() {}, "div"); | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert('系统繁忙,请重新登录尝试!', '提示', ["确定"], function() {}, "div"); | 
|         } | 
|     }) | 
| } | 
|   | 
| //渲染虫害数据 | 
| function renderPest() { | 
|     var html = ''; | 
|     if (pestData != null && pestData.length > 0) { | 
|         $.each(pestData, function(index, item) { | 
|             html += '<li><div class="con"><div class="tit">'; | 
|             html += '仓库名称: <span>' + item.depotName + '</span>'; | 
|             html += '<a id="' + item.depotId + '" class="more">虫害采集</a></div>'; | 
|             html += '<div class="txt"><div class="box">'; | 
|             if (index % 2 == 0) { | 
|                 html += '<div class="group out">'; | 
|             } else { | 
|                 html += '<div class="group in">'; | 
|             } | 
|             html += '<div class="desc">' + item.depotStatusName + '</div>'; | 
|             html += '<div class="ort">仓库状态</div></div></div>'; | 
|             html += '<div class="box">'; | 
|             if (item.pestNum == null) { | 
|                 html += '<div class="group no"><div class="desc">--</div>'; | 
|             } else if (item.pestNum > 0) { | 
|                 html += '<div class="group y"><div class="desc">有</div>'; | 
|             } else { | 
|                 html += '<div class="group no"><div class="desc">无</div>'; | 
|             } | 
|             html += '<div class="ort">是否有虫</div></div>'; | 
|             html += '</div></div><div class="time">检测时间: '; | 
|             html += (item.receiveDate == null ? '暂无检测记录' : item.receiveDate) + '</div></li>'; | 
|         }) | 
|     } | 
|     $("#pestList").html(html); | 
| } | 
|   | 
| //滑动 | 
| mui('.mui-scroll-wrapper').scroll({ | 
|     indicators: false, //是否显示滚动条 | 
|     deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 | 
|     bounce: false, //是否启用回弹 | 
|     deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 | 
| }); | 
|   | 
| //虫害采集 | 
| mui(".mui-content").on("tap", ".mui-scroll-wrapper ul li a", function() { | 
|     var depotId = this.getAttribute("id"); | 
|     gatherPest(depotId); | 
| }); | 
|   | 
| //气体采集 | 
| function gatherPest(depotId) { | 
|     data0.data.depotId = depotId; | 
|     //发送获取粮情请求 | 
|     mui.ajax(url, { | 
|         type: "POST", | 
|         dataType: "json", | 
|         crossDomain: true, | 
|         contentType: "application/json;charset=utf-8", | 
|         data: JSON.stringify(data0), | 
|         success: function(data) { | 
|             if (data.code == "0000") { | 
|                 mui.alert('采集命令发送成功,请等待10秒重新打开此页面查看采集数据!', '提示', ["确定"], function() {}, "div"); | 
|             } else { | 
|                 mui.alert(data.msg, '提示', ["确定"], function() {}, "div"); | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert('系统繁忙,请重试!', '提示', ["确定"], function() {}, "div"); | 
|         } | 
|     }) | 
| } |