<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<title>门禁控制</title>
|
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
<link href="./css/mui.min.css" rel="stylesheet" />
|
|
<style>
|
.mui-bar-nav {
|
background: #245ca7;
|
-webkit-box-shadow: none;
|
box-shadow: none;
|
}
|
|
.mui-title {
|
color: #FFFFFF;
|
}
|
|
.mui-icon-back:before,
|
.mui-icon-left-nav:before {
|
color: #FFFFFF;
|
}
|
|
.mui-grid-view.mui-grid-9 .mui-media .mui-icon {
|
font-size: 2.4em;
|
position: relative;
|
border-radius: 50px;
|
padding: 12px;
|
}
|
|
.mui-grid-view.mui-grid-9 .mui-media {
|
background: #ddd;
|
height: 130px;
|
width: 33.3333%;
|
}
|
|
.mui-grid-view.mui-grid-9 {
|
padding: 5px 5px;
|
border-top: none;
|
border-left: none;
|
}
|
|
.mui-table-view.mui-grid-view .mui-table-view-cell .mui-media-body {
|
color: #0062cc;
|
margin-top: unset;
|
}
|
|
.img_ico {
|
width: 70px;
|
height: auto;
|
display: block;
|
margin: auto;
|
margin-top: 10px;
|
}
|
|
.title {
|
background-color: #FFFFFF;
|
display: block;
|
padding: 0 15px;
|
box-sizing: border-box;
|
color: #333;
|
height: 40px;
|
line-height: 40px;
|
}
|
|
/*操作弹出窗*/
|
.mark_one {
|
background: rgba(0, 0, 0, .8);
|
position: fixed;
|
left: 0px;
|
top: 0px;
|
right: 0px;
|
bottom: 0px;
|
z-index: 10000;
|
display: flex;
|
}
|
|
.mark_one_layer {
|
background: #fff;
|
width: 85%;
|
margin: auto;
|
border-radius: 5px;
|
}
|
|
.mark_one_layer .title {
|
background: #245ca7;
|
line-height: 40px;
|
padding: 0 15px;
|
box-sizing: border-box;
|
color: #fff;
|
border-radius: 5px 5px 0 0;
|
}
|
|
.mark_one_layer .title a {
|
line-height: 40px;
|
font-size: 2.5rem;
|
float: right;
|
}
|
|
.mark_one_layer .btn {
|
display: block;
|
font-size: 1.5rem;
|
text-align: center;
|
}
|
|
.mark_one_layer .btn button {
|
color: #fff;
|
border-radius: 5px;
|
line-height: 35px;
|
font-size: 16px;
|
margin: 10px 10px;
|
}
|
|
.mark_one_btn1 {
|
background: #2f64ab;
|
width: 40%;
|
}
|
|
.mark_one_btn2 {
|
background: #e4606d;
|
width: 40%;
|
}
|
|
a {
|
text-decoration: none;
|
color: #f7f7f7;
|
}
|
</style>
|
</head>
|
<body>
|
<header class="mui-bar mui-bar-nav">
|
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
|
<h1 class="mui-title"><span id="depotName"></span>门禁设备</h1>
|
</header>
|
<div class="mui-content">
|
<div id="deviceList1">
|
<!-- <div class="title"><strong>仓库正面</strong></div>
|
<ul class="mui-table-view mui-grid-view mui-grid-9">
|
<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
|
<a href="javascript:void(0)" onclick="openDialog(1)">
|
<div class="mui-media-body">##1</div>
|
<img class="img_ico" src="./images/device-status/lock.png">
|
</a>
|
</li>
|
</ul> -->
|
</div>
|
<div id="deviceList2">
|
<!-- <div class="title"><strong>仓库背面</strong></div>
|
<ul class="mui-table-view mui-grid-view mui-grid-9">
|
<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
|
<a href="javascript:void(0)" onclick="openDialog(1)">
|
<div class="mui-media-body">##1</div>
|
<img class="img_ico" src="./images/device-status/lock_open.png">
|
|
</a>
|
</li>
|
</ul> -->
|
</div>
|
|
<!--弹窗-->
|
<div class="mark_one" id="openOne" style="display: none;">
|
<div class="mark_one_layer">
|
<div class="title">
|
<span style="font-size: 16px;" id="markName1">设备操作</span>
|
<a onclick="closeDialog()" class="close">×</a>
|
</div>
|
<div class="btn">
|
<button class="mark_one_btn1 mb-3" onclick="toExecute('OPEN')">
|
开门
|
</button>
|
<button class="mark_one_btn2 mb-3" onclick="toExecute('CLOSE')">
|
关门
|
</button>
|
</div>
|
</div>
|
</div>
|
</div>
|
<script src="./js/mui.js"></script>
|
<script src="./js/jquery.min.js"></script>
|
<script src="./js/echarts.min.js"></script>
|
|
<script type="text/javascript" charset="utf-8">
|
var url; //接口路径
|
var deviceList; //设备集合
|
var indexTag = null; //设备操作时的标记
|
//获取仓库下的门禁设备请求参数
|
var data1 = {
|
"interfaceId": "5402",
|
"sign": "10402",
|
"outId": "10402",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data": {
|
"depotId": "",
|
"type": "0E" //门禁
|
}
|
};
|
//控制设备参数
|
var data2 = {
|
"interfaceId": "5405",
|
"sign": "10405",
|
"outId": "",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data1": []
|
};
|
mui.init()
|
mui.plusReady(function() {
|
//获取参数
|
var curr = plus.webview.currentWebview();
|
var user = JSON.parse(localStorage.getItem('user'));
|
$("#depotName").html(curr.depotName);
|
//参数赋值
|
data1.tokenAuth = user.tokenAuth;
|
data1.data.depotId = curr.depotId;
|
//设置门禁权限码
|
data2.outId = curr.doorToken;
|
|
data2.tokenAuth = user.tokenAuth;
|
url = user.url + "/api-phone/gateway";
|
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") {
|
deviceList = result.data;
|
if (deviceList != null && deviceList.length > 0) {
|
renderDeviceList();
|
} else {
|
mui.alert('暂无设备!', '提示',["确定"],function(){},"div");
|
}
|
} else {
|
mui.alert('无相关设备信息!', '提示',["确定"],function(){},"div");
|
}
|
},
|
error: function() {
|
mui.alert('系统繁忙,请重试!', '提示',["确定"],function(){},"div");
|
}
|
})
|
}
|
|
//渲染
|
function renderDeviceList() {
|
//标记仓库正反面的设备数
|
var count1 = 0;
|
var count2 = 0;
|
|
var html1 = '';
|
var html2 = '';
|
html1 += '<div class="title"><strong>仓库正面</strong></div><ul class="mui-table-view mui-grid-view mui-grid-9">';
|
html2 += '<div class="title"><strong>仓库背面</strong></div><ul class="mui-table-view mui-grid-view mui-grid-9">';
|
var img_url;
|
$.each(deviceList, function(index, item) {
|
img_url = '';
|
//设置设备图片路径
|
if (item.type == "0E") {
|
if (item.status == "OPEN") {
|
img_url = './images/device-status/lock_open.png';
|
} else {
|
img_url = './images/device-status/lock.png';
|
}
|
}
|
|
//仓库正面
|
if (item.location == '01') {
|
html1 += '<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3"><a href="javascript:void(0)" ' +
|
'onclick="openDialog(\'' + index + '\')">';
|
html1 += '<div class="mui-media-body">' + item.name + '</div><img class="img_ico" ';
|
html1 += 'src="' + img_url + '">';
|
html1 += '</a></li>';
|
count1++;
|
}
|
//仓库背面
|
if (item.location == '02') {
|
html2 += '<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3"><a href="javascript:void(0)" ' +
|
'onclick="openDialog(\'' + index + '\')">';
|
html2 += '<div class="mui-media-body">' + item.name + '</div><img class="img_ico" ';
|
html2 += 'src="' + img_url + '">';
|
html2 += '</a></li>';
|
count2++;
|
}
|
})
|
html1 += '</ul>';
|
html2 += '</ul>';
|
if (count1 > 0) {
|
$("#deviceList1").html(html1);
|
} else {
|
$("#deviceList1").html("");
|
}
|
if (count2 > 0) {
|
$("#deviceList2").html(html2);
|
} else {
|
$("#deviceList2").html("");
|
}
|
}
|
|
//设备操作
|
function toExecute(targetStatus) {
|
if (indexTag != null && indexTag >= 0) {
|
var batchTag = false;
|
//判断是否是批量
|
if (targetStatus == 'W_OPEN_ALL') {
|
targetStatus = 'OPEN';
|
batchTag = true;
|
}
|
if (targetStatus == 'W_CLOSE_ALL') {
|
targetStatus = 'CLOSE';
|
batchTag = true;
|
}
|
//参数清空
|
data2.data1 = [];
|
if (batchTag) { //批量操作
|
$.each(deviceList, function(index, item) {
|
if (deviceList[indexTag].type == item.type) {
|
data2.data1.push({
|
"id": item.id,
|
"depotId": item.depotId,
|
"passCode": item.passCode,
|
"name": item.name,
|
"serId": item.serId,
|
"link": item.link,
|
"type": item.type,
|
"targetStatus": targetStatus
|
})
|
}
|
})
|
} else { //单设备操作
|
data2.data1.push({
|
"id": deviceList[indexTag].id,
|
"depotId": deviceList[indexTag].depotId,
|
"passCode": deviceList[indexTag].passCode,
|
"name": deviceList[indexTag].name,
|
"serId": deviceList[indexTag].serId,
|
"link": deviceList[indexTag].link,
|
"type": deviceList[indexTag].type,
|
"targetStatus": targetStatus
|
})
|
}
|
//发送操作请求
|
toControlDevice();
|
|
//关闭弹窗
|
closeDialog();
|
}
|
}
|
|
//设备操作请求
|
function toControlDevice() {
|
mui.ajax(url, {
|
type: "POST",
|
dataType: "json",
|
crossDomain: true,
|
contentType: "application/json;charset=utf-8",
|
data: JSON.stringify(data2),
|
success: function(result) {
|
if (result.code == "0000") {
|
mui.alert('操作命令发送成功,请等待30秒后重新打开此页面!', '提示',["确定"],function(){},"div");
|
} else {
|
mui.alert(result.msg, '提示',["确定"],function(){},"div");
|
}
|
},
|
error: function() {
|
mui.alert('系统繁忙,请重试!', '提示',["确定"],function(){},"div");
|
}
|
})
|
}
|
|
//打开弹窗
|
function openDialog(index) {
|
indexTag = index;
|
$("#markName1").html("设备操作 - " + deviceList[index].name);
|
$('#openOne').css('display', 'flex');
|
}
|
|
//关闭弹窗
|
function closeDialog() {
|
indexTag = null;
|
$("#openOne").css('display', 'none');
|
}
|
</script>
|
</body>
|
</html>
|