YYC
2023-06-09 5132d695e4edc00e2a80f7bf40b5164be34e9499
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
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;
                // console.log(JSON.stringify(depotList))
                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("请返回重试!");
    }
});