var url = null;
|
var depotList = null;
|
var tag = "";
|
var data = {
|
"interfaceId": "5102",
|
"sign": "10102",
|
"outId": "10102",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data": {
|
"deptId": ""
|
}
|
};
|
|
//初始化数据
|
function init() {
|
//获取参数
|
var curr = plus.webview.currentWebview();
|
if (curr.titleName) {
|
$("#titleName").html(curr.titleName);
|
}
|
tag = curr.tag;
|
|
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;
|
getData();
|
}
|
|
//获取仓库信息
|
function getData() {
|
//发送请求获取仓库信息
|
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") {
|
depotList = result.data;
|
renderDepotList();
|
} else {
|
mui.alert(result.msg, '提示', ["确定"], function() {}, "div");
|
}
|
},
|
error: function() {
|
mui.alert('系统繁忙,请重新登录尝试!', '提示', ["确定"], function() {}, "div");
|
}
|
})
|
}
|
|
//渲染
|
function renderDepotList() {
|
if (depotList && depotList.length > 0) {
|
var html = '';
|
$.each(depotList, function(index, item) {
|
html += '<li><a id="'+ index;
|
html += '" class="con"><div class="pic">';
|
//根据仓库类型配置不同图标
|
if(item.depotType == "01"){
|
html += '<img src="images/a9.png">';
|
}else if(item.depotType == "02"){
|
html += '<img src="images/b1.png">';
|
}else if(item.depotType == "03"){
|
html += '<img src="images/b2.png">';
|
}else if(item.depotType == "04"){
|
html += '<img src="images/b1.png">';
|
}else{
|
html += '<img src="images/a9.png">';
|
}
|
|
html += '</div><div class="txt">' + item.name + '</div>';
|
|
//根据仓库状态显示不同颜色
|
if(item.depotStatus == "01"){
|
html += '<div class="info empt">';
|
}else if(item.depotStatus == "02"){
|
html += '<div class="info full">';
|
}else if(item.depotStatus == "03"){
|
html += '<div class="info in">';
|
}else if(item.depotStatus == "04"){
|
html += '<div class="info out">';
|
}else if(item.depotStatus == "05"){
|
html += '<div class="info q">';
|
}else if(item.depotStatus == "06"){
|
html += '<div class="info xun">';
|
}else if(item.depotStatus == "07"){
|
html += '<div class="info wind">';
|
}else if(item.depotStatus == "08"){
|
html += '<div class="info repair">';
|
}else{
|
html += '<div class="info empt">';
|
}
|
|
html += (item.depotStatusName==null?"--":item.depotStatusName) + '</div>';
|
html += '</a></li>';
|
})
|
$("#depotList").html(html);
|
} else {
|
mui.alert('未获取到仓库列表,请重试!', '提示', ["确定"], function() {}, "div");
|
}
|
}
|
|
//滑动
|
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 index = this.getAttribute("id");
|
var depotId = depotList[index].id;
|
var depotType = depotList[index].depotType;
|
var depotName = depotList[index].name;
|
var html = null;
|
//粮情详细
|
if (tag == "grain") {
|
html = "grain-detail";
|
}
|
//门禁控制
|
if (tag == "door") {
|
html = "security-door";
|
}
|
//通风操作
|
if (tag == "verb") {
|
html = "device-verb";
|
}
|
//气调操作
|
if (tag == "n2") {
|
html = "device-n2";
|
}
|
//温控操作
|
if (tag == "temp") {
|
html = "device-temp";
|
}
|
if (html) {
|
mui.openWindow({
|
url: html + ".html",
|
id: html,
|
extras: {
|
depotId: depotId,
|
depotType: depotType,
|
depotName: depotName
|
}
|
})
|
} else {
|
mui.toast("请返回重试!");
|
}
|
});
|