feat: 手机设备页面增加控制
parent
e1f852f984
commit
728b126b44
|
|
@ -1,175 +1,243 @@
|
||||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
pageEncoding="UTF-8"%>
|
pageEncoding="UTF-8" %>
|
||||||
<%@ page import="com.lp.cfg.ProConfig"%>
|
<%@ page import="com.lp.cfg.ProConfig" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><%=ProConfig.PROJECT_NAME %></title>
|
<title><%=ProConfig.PROJECT_NAME %>
|
||||||
<%@ include file="/WEB-INF/wechat/iot/common/resource_lib.jsp"%>
|
</title>
|
||||||
|
<%@ include file="/WEB-INF/wechat/iot/common/resource_lib.jsp" %>
|
||||||
<script type="text/javascript" src="<%=basePath%>/lib/mqtt/mqtt.min.js"></script>
|
<script type="text/javascript" src="<%=basePath%>/lib/mqtt/mqtt.min.js"></script>
|
||||||
<script type="text/javascript" src="../../lib/layer/layer.js"></script>
|
<script type="text/javascript" src="../../lib/layer/layer.js"></script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.sensor-container{
|
.sensor-container {
|
||||||
background: transparent;width:100%;
|
background: transparent;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
.sensor-container img{
|
|
||||||
vertical-align: middle;margin: 0 0 0 10px;width: 35px;
|
.sensor-container img {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 0 0 0 10px;
|
||||||
|
width: 35px;
|
||||||
}
|
}
|
||||||
.layui-layer-input{
|
|
||||||
|
.layui-layer-input {
|
||||||
border: 1px solid #d9d9d9 !important;
|
border: 1px solid #d9d9d9 !important;
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
.edit-param{
|
|
||||||
float: right;margin-right: 10px;width: 24px !important;
|
.edit-param {
|
||||||
|
float: right;
|
||||||
|
margin-right: 10px;
|
||||||
|
width: 24px !important;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
}
|
}
|
||||||
.sensor-container .sensor-name{
|
|
||||||
margin-left: 15px;font-size: 14px;
|
.sensor-container .sensor-name {
|
||||||
}
|
margin-left: 15px;
|
||||||
.sensor-container .sensor-value{
|
font-size: 14px;
|
||||||
float: right;font-size: 24px;margin-right: 10px; color: #008fcd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sensor-container .sensor-type{
|
.sensor-container .sensor-value {
|
||||||
float: right;font-size: 20px;margin-right: 13px;
|
float: right;
|
||||||
|
font-size: 24px;
|
||||||
|
margin-right: 10px;
|
||||||
|
color: #008fcd;
|
||||||
}
|
}
|
||||||
.sensor-container img.sensor-control{
|
|
||||||
float: right; padding-right: 13px;;
|
.sensor-container .sensor-type {
|
||||||
|
float: right;
|
||||||
|
font-size: 20px;
|
||||||
|
margin-right: 13px;
|
||||||
}
|
}
|
||||||
.weui-media-box{
|
|
||||||
|
.sensor-container img.sensor-control {
|
||||||
|
float: right;
|
||||||
|
padding-right: 13px;;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weui-media-box {
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempdata{
|
.tempdata {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #666;
|
color: #666;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.weui-panel.weui-panel_access.active .weui-panel__bd {
|
.weui-panel.weui-panel_access.active .weui-panel__bd {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.weui-panel.weui-panel_access.active .weui-panel__hd{
|
|
||||||
/* background: #f1f1f1; */
|
.weui-panel.weui-panel_access.active .weui-panel__hd {
|
||||||
|
/* background: #f1f1f1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
<script>
|
||||||
|
function uint8ArrayToJSON(fileData) {
|
||||||
|
var dataString = "";
|
||||||
|
for (var i = 0; i < fileData.length; i++) {
|
||||||
|
dataString += String.fromCharCode(fileData[i]);
|
||||||
|
}
|
||||||
|
return JSON.parse(dataString)
|
||||||
|
}
|
||||||
|
|
||||||
|
function debounce(fn, delay) {
|
||||||
|
let time = null;
|
||||||
|
return function () {
|
||||||
|
let _this = this;
|
||||||
|
let args = arguments;
|
||||||
|
if (time !== null) clearTimeout(time);
|
||||||
|
time = setTimeout(function () {
|
||||||
|
fn.apply(_this, args);
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function throttle(fn, delay) {
|
||||||
|
let _this, args;
|
||||||
|
let previous = 0;
|
||||||
|
return function () {
|
||||||
|
let now = +new Date();
|
||||||
|
_this = this;
|
||||||
|
args = arguments;
|
||||||
|
if (now - previous > delay) {
|
||||||
|
fn.apply(_this, args);
|
||||||
|
previous = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="t-c title-info" >
|
<div class="t-c title-info">
|
||||||
<span>设备信息</span>
|
<span>设备信息</span>
|
||||||
<%-- <div class="back" onclick="forward('/wiot/scene')" style=" position: fixed;top: 0px;" >返回</div>--%>
|
<%-- <div class="back" onclick="forward('/wiot/scene')" style=" position: fixed;top: 0px;" >返回</div>--%>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 50px;"></div>
|
<div style="height: 50px;"></div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="hide" id="hideContainer" >
|
<div class="hide" id="hideContainer">
|
||||||
</div>
|
</div>
|
||||||
<%@ include file="/WEB-INF/wechat/iot/common/pager.jsp"%>
|
<%@ include file="/WEB-INF/wechat/iot/common/pager.jsp" %>
|
||||||
<div id="template0" class="hide">
|
<div id="template0" class="hide">
|
||||||
<div class="weui-panel weui-panel_access active noid-{5}" >
|
<div class="weui-panel weui-panel_access active noid-{5}">
|
||||||
<div class="weui-panel__hd pointer">
|
<div class="weui-panel__hd pointer">
|
||||||
<span>{0}</span>
|
<span>{0}</span>
|
||||||
<span class="float-right" style="color:#3499da;border: 1px solid #3499da; border-radius: 3px;padding: 1px 2px; " onclick="forwrdSetting({5})" >参数设置</span>
|
<span class="float-right"
|
||||||
<span class="{4} float-right" style="margin-right:20px;" >{1}</span>
|
style="color:#3499da;border: 1px solid #3499da; border-radius: 3px;padding: 1px 2px; "
|
||||||
|
onclick="forwrdSetting({5})">参数设置</span>
|
||||||
|
<span class="{4} float-right" style="margin-right:20px;">{1}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="weui-panel__bd">
|
<div class="weui-panel__bd">
|
||||||
{3}
|
{3}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 连续型 -->
|
<!-- 连续型 -->
|
||||||
<div id="template1" class="hide">
|
<div id="template1" class="hide">
|
||||||
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
|
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg" id="sensor{2}">
|
||||||
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={3}" tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={3}">
|
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={3}"
|
||||||
<%-- <img src="<%=basePath%>/image/oss/iot/{4}.png" />--%>
|
tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={3}">
|
||||||
<img src="<%=sensorImg%>/{4}.png" />
|
<%-- <img src="<%=basePath%>/image/oss/iot/{4}.png" />--%>
|
||||||
<span class="sensor-name" >{0}</span>
|
<img src="<%=sensorImg%>/{4}.png"/>
|
||||||
|
<span class="sensor-name">{0}</span>
|
||||||
<img class="edit-param {5}" onclick="downparam({2})"
|
<img class="edit-param {5}" onclick="downparam({2})"
|
||||||
src="<%=wechatImg%>/edit.png"
|
src="<%=wechatImg%>/edit.png"
|
||||||
title="下发"
|
title="下发"
|
||||||
>
|
>
|
||||||
<%-- src="<%=basePath%>/image/wechat/iot/edit.png"--%>
|
<%-- src="<%=basePath%>/image/wechat/iot/edit.png"--%>
|
||||||
|
|
||||||
<span class="sensor-value" >{1}</span>
|
<span class="sensor-value">{1}</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- 开关 -->
|
<!-- 开关 -->
|
||||||
<div id="template2" class="hide">
|
<div id="template2" class="hide">
|
||||||
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
|
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg" id="sensor{2}">
|
||||||
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={4}" tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={4}">
|
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={4}"
|
||||||
<%-- <img src="<%=basePath%>/image/oss/iot/{6}.png" /> --%>
|
tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={4}">
|
||||||
<img src="<%=sensorImg%>/{6}.png" />
|
<%-- <img src="<%=basePath%>/image/oss/iot/{6}.png" /> --%>
|
||||||
<span class="sensor-name" >{0}</span>
|
<img src="<%=sensorImg%>/{6}.png"/>
|
||||||
<img class="edit-param {7}" onclick="downparam({2})"
|
|
||||||
<%-- src="<%=basePath%>/image/wechat/iot/edit.png" --%>
|
|
||||||
src="<%=wechatImg%>/edit.png"
|
|
||||||
title="下发"
|
|
||||||
>
|
|
||||||
<img style="width: 65px;margin-top: 3px;" tag="{5}" onclick="switchSensor(this,{2},{3})" {1} class="sensor-control" />
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<!-- 点动 -->
|
|
||||||
<div id="template6" class="hide">
|
|
||||||
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
|
|
||||||
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={4}" tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={4}">
|
|
||||||
<%-- <img src="<%=basePath%>/image/oss/iot/{6}.png" /> --%>
|
|
||||||
<img src="<%=sensorImg%>/{6}.png" />
|
|
||||||
<span class="sensor-name">{0}</span>
|
<span class="sensor-name">{0}</span>
|
||||||
<img style="width: 30px;margin-top: 3px;margin-right: 8px;" tag="{5}" onclick="switchSensordian(this,{2},{3})" {1} class="sensor-control" />
|
<img class="edit-param {7}" onclick="downparam({2})"
|
||||||
</div>
|
<%-- src="<%=basePath%>/image/wechat/iot/edit.png" --%>
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<!-- 离散 -->
|
|
||||||
<div id="template3" class="hide">
|
|
||||||
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
|
|
||||||
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={3}" tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={3}">
|
|
||||||
<%-- <img src="<%=basePath%>/image/oss/iot/{4}.png" />--%>
|
|
||||||
<img src="<%=sensorImg%>/{4}.png" />
|
|
||||||
<span class="sensor-name" >{0}</span>
|
|
||||||
<img class="edit-param {5}" onclick="downparam({2})"
|
|
||||||
<%-- src="<%=basePath%>/image/wechat/iot/edit.png" --%>
|
|
||||||
src="<%=wechatImg%>/edit.png"
|
src="<%=wechatImg%>/edit.png"
|
||||||
title="下发"
|
title="下发"
|
||||||
>
|
>
|
||||||
<span class="sensor-value" >{1}</span>
|
<img style="width: 65px;margin-top: 3px;" tag="{5}" onclick="switchSensor(this,{2},{3})" {1}
|
||||||
|
class="sensor-control"/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
</div>
|
||||||
|
<!-- 点动 -->
|
||||||
|
<div id="template6" class="hide">
|
||||||
|
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg" id="sensor{2}">
|
||||||
|
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={4}"
|
||||||
|
tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={4}">
|
||||||
|
<%-- <img src="<%=basePath%>/image/oss/iot/{6}.png" /> --%>
|
||||||
|
<img src="<%=sensorImg%>/{6}.png"/>
|
||||||
|
<span class="sensor-name">{0}</span>
|
||||||
|
<img style="width: 30px;margin-top: 3px;margin-right: 8px;" tag="{5}"
|
||||||
|
onclick="switchSensordian(this,{2},{3})" {1} class="sensor-control"/>
|
||||||
</div>
|
</div>
|
||||||
<!--定位型 -->
|
</a>
|
||||||
<div id="template4" class="hide">
|
</div>
|
||||||
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
|
<!-- 离散 -->
|
||||||
|
<div id="template3" class="hide">
|
||||||
|
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg" id="sensor{2}">
|
||||||
|
<div class="clear sensor-container switchbtn" url="/wiot/sensor?id={2}&did={3}"
|
||||||
|
tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={3}">
|
||||||
|
<%-- <img src="<%=basePath%>/image/oss/iot/{4}.png" />--%>
|
||||||
|
<img src="<%=sensorImg%>/{4}.png"/>
|
||||||
|
<span class="sensor-name">{0}</span>
|
||||||
|
<img class="edit-param {5}" onclick="downparam({2})"
|
||||||
|
<%-- src="<%=basePath%>/image/wechat/iot/edit.png" --%>
|
||||||
|
src="<%=wechatImg%>/edit.png"
|
||||||
|
title="下发"
|
||||||
|
>
|
||||||
|
<span class="sensor-value">{1}</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<!--定位型 -->
|
||||||
|
<div id="template4" class="hide">
|
||||||
|
<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg" id="sensor{2}">
|
||||||
<div class="clear sensor-container" tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={3}">
|
<div class="clear sensor-container" tag="<%=basePath%>/service/iot/sensors_detail?id={2}&sid={3}">
|
||||||
<%-- <img src="<%=basePath%>/image/oss/iot/{4}.png" />--%>
|
<%-- <img src="<%=basePath%>/image/oss/iot/{4}.png" />--%>
|
||||||
<img src="<%=sensorImg%>/{4}.png" />
|
<img src="<%=sensorImg%>/{4}.png"/>
|
||||||
<span class="sensor-name" >{0}</span>
|
<span class="sensor-name">{0}</span>
|
||||||
<span style="font-size: 17px;margin-top: 3px;" class="sensor-value" >{1}</span>
|
<span style="font-size: 17px;margin-top: 3px;" class="sensor-value">{1}</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function forwrdSetting(deviceId){
|
function forwrdSetting(deviceId) {
|
||||||
forward('/wiot/device_setting?id='+deviceId+'&sid='+ GetQueryString("id") );
|
forward('/wiot/device_setting?id=' + deviceId + '&sid=' + GetQueryString("id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据下发
|
* 数据下发
|
||||||
*/
|
*/
|
||||||
function downparam(id){
|
function downparam(id) {
|
||||||
|
|
||||||
layer.prompt({title: '数据下发', formType: 3}, function(val, index){
|
layer.prompt({title: '数据下发', formType: 3}, function (val, index) {
|
||||||
commonAjax('PUT',localUrl+'/sensor/param/down.json', {sdata : val ,id:id },function(data){
|
commonAjax('PUT', localUrl + '/sensor/param/down.json', {sdata: val, id: id}, function (data) {
|
||||||
if(isOK(data)){
|
if (isOK(data)) {
|
||||||
tip("写指令下发成功,请稍后...");
|
tip("写指令下发成功,请稍后...");
|
||||||
}else{
|
} else {
|
||||||
$.toptip(data.statusMsg, 'error');
|
$.toptip(data.statusMsg, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -177,164 +245,209 @@
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function getDisInfo(data){
|
|
||||||
|
|
||||||
var t =eval('('+ gdv( data.infos,'{}') +')');
|
function getDisInfo(data) {
|
||||||
if( t!= null && t.readType == 1){
|
|
||||||
return "" ;
|
var t = eval('(' + gdv(data.infos, '{}') + ')');
|
||||||
}else{
|
if (t != null && t.readType == 1) {
|
||||||
return "hide" ;
|
return "";
|
||||||
|
} else {
|
||||||
|
return "hide";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//客户端
|
//客户端
|
||||||
|
|
||||||
var client ;
|
var client;
|
||||||
function mqttInit(){
|
|
||||||
|
var sensorChangeDebounceFn = debounce(function (params) {
|
||||||
|
const _params = Object.assign(data, {sensor_id: params.sensor_id});
|
||||||
|
postAjax(localUrl + "/page/node/sensor/lists.json?pageSize=10&paged=1", _params, function (result) {
|
||||||
|
let _result = result.data.data;
|
||||||
|
const sid = GetQueryString("id");
|
||||||
|
let deviceHTML = '';
|
||||||
|
for (let i = 0; i < _result.length; i++) {
|
||||||
|
deviceHTML = getSensorListHtml(_result[i].iotSensorList, sid, _result[i].iot_node_status);
|
||||||
|
}
|
||||||
|
if (deviceHTML.length > 0) {
|
||||||
|
const sensorDOM = $("#sensor" + params.sensor_id);
|
||||||
|
sensorDOM.hide();
|
||||||
|
sensorDOM.after(deviceHTML);
|
||||||
|
sensorDOM.remove();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
var sensorChangeThrottleFn = throttle(function () {
|
||||||
|
for (var i = 1; i < paged; i++) {
|
||||||
|
reflesh(i);
|
||||||
|
}
|
||||||
|
}, 2000)
|
||||||
|
|
||||||
|
|
||||||
|
function mqttInit() {
|
||||||
// 连接选项
|
// 连接选项
|
||||||
const options = {
|
const options = {
|
||||||
connectTimeout: 4000, // 超时时间
|
connectTimeout: 4000, // 超时时间
|
||||||
// 认证信息
|
// 认证信息
|
||||||
clientId: 'brower_' + parseInt(Math.random()/31.1*10000000000),
|
clientId: 'brower_' + parseInt(Math.random() / 31.1 * 10000000000),
|
||||||
username: '<%=ProConfig.MQTT.USERNAME%>',
|
username: '<%=ProConfig.MQTT.USERNAME%>',
|
||||||
password: '<%=ProConfig.MQTT.PASSWORD%>',
|
password: '<%=ProConfig.MQTT.PASSWORD%>',
|
||||||
}
|
}
|
||||||
client = mqtt.connect('<%=ProConfig.MQTT.MQTTSIMPLEURI%>', options) ;
|
client = mqtt.connect('<%=ProConfig.MQTT.MQTTSIMPLEURI%>', options);
|
||||||
// client = mqtt.connect('ws://'+document.domain+':8083/mqtt', options) ;
|
// client = mqtt.connect('ws://'+document.domain+':8083/mqtt', options) ;
|
||||||
client.on('reconnect', function(error) {
|
client.on('reconnect', function (error) {
|
||||||
for(var i=1;i< paged;i++){
|
for (var i = 1; i < paged; i++) {
|
||||||
reflesh(i);
|
reflesh(i);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
client.on('error', function(error) {
|
client.on('error', function (error) {
|
||||||
console.log('连接失败:', error)
|
console.log('连接失败:', error)
|
||||||
})
|
})
|
||||||
client.on('message', function(topic, message,s) {
|
|
||||||
console.log('mqtt reflush with [%o],[%o],[%o] now', topic, message,s);
|
client.on('message', function (topic, message, s) {
|
||||||
if( message.toString() == '1' ){
|
message = uint8ArrayToJSON(message);
|
||||||
for(var i=1;i< paged;i++){
|
let reportFlag, sensorID;
|
||||||
reflesh(i);
|
|
||||||
}
|
if (Object.prototype.toString.call(message) == '[object Object]') {
|
||||||
|
reportFlag = message['report_flag'].toString();
|
||||||
|
sensorID = message['sensor_id'];
|
||||||
|
} else {
|
||||||
|
reportFlag = '0'
|
||||||
}
|
}
|
||||||
|
if (reportFlag == '0') {
|
||||||
|
sensorChangeThrottleFn();
|
||||||
|
} else if (reportFlag == '1' && sensorID != null && sensorID != '') {
|
||||||
|
// 控制頻率
|
||||||
|
sensorChangeDebounceFn({
|
||||||
|
sensor_id: sensorID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 查询条件
|
// 查询条件
|
||||||
// 获取scene id
|
// 获取scene id
|
||||||
|
|
||||||
|
|
||||||
var scene_id = GetQueryString("id") ;
|
var scene_id = GetQueryString("id");
|
||||||
var data = {scene_id: scene_id , node_data_type:0 } ;
|
var data = {scene_id: scene_id, node_data_type: 0};
|
||||||
|
|
||||||
var paged = 1;
|
var paged = 1;
|
||||||
// $(".weui-tabbar .weui-tabbar__icon").eq(0).addClass("active");
|
// $(".weui-tabbar .weui-tabbar__icon").eq(0).addClass("active");
|
||||||
|
|
||||||
$(function(){
|
$(function () {
|
||||||
|
|
||||||
mqttInit();
|
mqttInit();
|
||||||
|
|
||||||
setTimeout( function() {
|
setTimeout(function () {
|
||||||
var tempT = "/scene/update/"+ scene_id ;
|
var tempT = "/scene/update/" + scene_id;
|
||||||
client.subscribe(tempT );
|
client.subscribe(tempT);
|
||||||
client.publish('/sys/update/scene' , scene_id );
|
client.publish('/sys/update/scene', scene_id);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
getData(paged++);
|
getData(paged++);
|
||||||
var loading = false; //状态标记
|
var loading = false; //状态标记
|
||||||
$(document.body).infinite().on("infinite", function() {
|
$(document.body).infinite().on("infinite", function () {
|
||||||
if (loading)
|
if (loading)
|
||||||
return;
|
return;
|
||||||
loading = true;
|
loading = true;
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
// 获取商品信息
|
// 获取商品信息
|
||||||
getData(paged++);
|
getData(paged++);
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
function getData(paged){
|
function getData(paged) {
|
||||||
var sid = GetQueryString("id") ;
|
var sid = GetQueryString("id");
|
||||||
postAjax(localUrl+"/page/node/sensor/lists.json?pageSize=12&paged="+paged , data ,function(data){
|
postAjax(localUrl + "/page/node/sensor/lists.json?pageSize=12&paged=" + paged, data, function (data) {
|
||||||
if(isOK(data)){
|
if (isOK(data)) {
|
||||||
var dataObj = data.data.data ;
|
var dataObj = data.data.data;
|
||||||
for(var i=0; i <dataObj.length;i++){
|
for (var i = 0; i < dataObj.length; i++) {
|
||||||
$(".container").append($("#template0").html().format(
|
$(".container").append($("#template0").html().format(
|
||||||
dataObj[i].name
|
dataObj[i].name
|
||||||
,dataObj[i].data.iot_node_status
|
, dataObj[i].data.iot_node_status
|
||||||
,disvalue(dataObj[i].device_code,10)
|
, disvalue(dataObj[i].device_code, 10)
|
||||||
,getSensorListHtml(dataObj[i].iotSensorList,sid ,dataObj[i].iot_node_status )
|
, getSensorListHtml(dataObj[i].iotSensorList, sid, dataObj[i].iot_node_status)
|
||||||
, getDeviceState(dataObj[i].iot_node_status),
|
, getDeviceState(dataObj[i].iot_node_status),
|
||||||
dataObj[i].id
|
dataObj[i].id
|
||||||
) );
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.data.totalPage > data.data.paged){
|
if (data.data.totalPage > data.data.paged) {
|
||||||
loading = false;
|
loading = false;
|
||||||
}else{
|
} else {
|
||||||
loading =true ;
|
loading = true;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
loading =true ;
|
loading = true;
|
||||||
}
|
}
|
||||||
// 传data就可以,分页的
|
// 传data就可以,分页的
|
||||||
pagerinit(data,".container");
|
pagerinit(data, ".container");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(function() {
|
setInterval(function () {
|
||||||
for(var i=1;i< paged;i++){
|
for (var i = 1; i < paged; i++) {
|
||||||
reflesh(i);
|
reflesh(i);
|
||||||
}
|
}
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
|
|
||||||
// 点击激活
|
// 点击激活
|
||||||
$(document).delegate(".weui-panel.weui-panel_access .weui-panel__hd","click",function(){
|
$(document).delegate(".weui-panel.weui-panel_access .weui-panel__hd", "click", function () {
|
||||||
if( $(this).parent().hasClass("active")){
|
if ($(this).parent().hasClass("active")) {
|
||||||
$(this).parent().removeClass("active");
|
$(this).parent().removeClass("active");
|
||||||
}else{
|
} else {
|
||||||
$(this).parent().addClass("active");
|
$(this).parent().addClass("active");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 委托冒泡
|
// 委托冒泡
|
||||||
$(document).on("click",".sensor-control",function(e){
|
$(document).on("click", ".sensor-control", function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
})
|
})
|
||||||
|
|
||||||
$(document).on("click",".edit-param",function(e){
|
$(document).on("click", ".edit-param", function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转
|
* 跳转
|
||||||
*/
|
*/
|
||||||
$(document).on("click",".switchbtn",function(){
|
$(document).on("click", ".switchbtn", function () {
|
||||||
forward( $(this).attr("url") );
|
forward($(this).attr("url"));
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 更新数值
|
// 更新数值
|
||||||
function reflesh(paged){
|
function reflesh(paged) {
|
||||||
var sid = GetQueryString("id") ;
|
var sid = GetQueryString("id");
|
||||||
postAjax(localUrl+"/page/node/sensor/lists.json?pageSize=12&paged="+paged , data ,function(data){
|
postAjax(localUrl + "/page/node/sensor/lists.json?pageSize=12&paged=" + paged, data, function (data) {
|
||||||
if(isOK(data)){
|
if (isOK(data)) {
|
||||||
var dataObj = data.data.data ;
|
var dataObj = data.data.data;
|
||||||
for(var i=0; i <dataObj.length;i++){
|
for (var i = 0; i < dataObj.length; i++) {
|
||||||
$("#hideContainer").append( $("#template0").html().format(dataObj[i].name ,dataObj[i].data.iot_node_status
|
$("#hideContainer").append($("#template0").html().format(dataObj[i].name, dataObj[i].data.iot_node_status
|
||||||
,disvalue(dataObj[i].device_code,10)
|
, disvalue(dataObj[i].device_code, 10)
|
||||||
,getSensorListHtml(dataObj[i].iotSensorList,sid , dataObj[i].iot_node_status)
|
, getSensorListHtml(dataObj[i].iotSensorList, sid, dataObj[i].iot_node_status)
|
||||||
, getDeviceState(dataObj[i].iot_node_status)
|
, getDeviceState(dataObj[i].iot_node_status)
|
||||||
, dataObj[i].id) );
|
, dataObj[i].id));
|
||||||
$(".container .noid-"+dataObj[i].id ).html( $("#hideContainer .noid-"+dataObj[i].id).html() );
|
$(".container .noid-" + dataObj[i].id).html($("#hideContainer .noid-" + dataObj[i].id).html());
|
||||||
$("#hideContainer").empty();
|
$("#hideContainer").empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchSensordian(obj,id,value){
|
function switchSensordian(obj, id, value) {
|
||||||
commonAjax('PUT',localUrl+"/sensor/control/realtime/update", {id:id,request_sdata: value },function(data){
|
commonAjax('PUT', localUrl + "/sensor/control/realtime/update", {
|
||||||
if(isOK(data)){
|
id: id,
|
||||||
|
request_sdata: value
|
||||||
|
}, function (data) {
|
||||||
|
if (isOK(data)) {
|
||||||
tip("下发成功");
|
tip("下发成功");
|
||||||
}else{
|
} else {
|
||||||
tip(data.statusMsg);
|
tip(data.statusMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -343,154 +456,153 @@
|
||||||
/**
|
/**
|
||||||
* 控制
|
* 控制
|
||||||
*/
|
*/
|
||||||
function switchSensor(obj,id,value){
|
function switchSensor(obj, id, value) {
|
||||||
var obj = $(obj) ;
|
var obj = $(obj);
|
||||||
var requestData = '',src='' ;
|
var requestData = '', src = '';
|
||||||
if( obj.attr("src").indexOf("loading") >-1 ){
|
if (obj.attr("src").indexOf("loading") > -1) {
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
var measure_type_value = obj.attr("tag");
|
var measure_type_value = obj.attr("tag");
|
||||||
if(convertControl(value,measure_type_value,'打开')){
|
if (convertControl(value, measure_type_value, '打开')) {
|
||||||
requestData = convertControl(value,measure_type_value,'打开');
|
requestData = convertControl(value, measure_type_value, '打开');
|
||||||
<%--src = "<%=basePath%>/image/oss/iot/off_loading.gif";--%>
|
<%--src = "<%=basePath%>/image/oss/iot/off_loading.gif";--%>
|
||||||
src = "<%=sensorImg%>/off_loading.gif";
|
src = "<%=sensorImg%>/off_loading.gif";
|
||||||
}else if(convertControl(value,measure_type_value,'关闭')){
|
} else if (convertControl(value, measure_type_value, '关闭')) {
|
||||||
requestData =convertControl(value,measure_type_value,'关闭') ;
|
requestData = convertControl(value, measure_type_value, '关闭');
|
||||||
<%--src = "<%=basePath%>/image/oss/iot/on_loading.gif" ;--%>
|
<%--src = "<%=basePath%>/image/oss/iot/on_loading.gif" ;--%>
|
||||||
src = "<%=sensorImg%>/on_loading.gif" ;
|
src = "<%=sensorImg%>/on_loading.gif";
|
||||||
}else if(convertControl(value,measure_type_value,'开门成功')){
|
} else if (convertControl(value, measure_type_value, '开门成功')) {
|
||||||
requestData = convertControl(value,measure_type_value,'开门成功');
|
requestData = convertControl(value, measure_type_value, '开门成功');
|
||||||
<%--src = "<%=basePath%>/image/oss/iot/off_loading.gif";--%>
|
<%--src = "<%=basePath%>/image/oss/iot/off_loading.gif";--%>
|
||||||
src = "<%=sensorImg%>/off_loading.gif";
|
src = "<%=sensorImg%>/off_loading.gif";
|
||||||
}else if(convertControl(value,measure_type_value,'正常')){
|
} else if (convertControl(value, measure_type_value, '正常')) {
|
||||||
requestData = convertControl(value,measure_type_value,'正常');
|
requestData = convertControl(value, measure_type_value, '正常');
|
||||||
<%--src = "<%=basePath%>/image/oss/iot/on_loading.gif";--%>
|
<%--src = "<%=basePath%>/image/oss/iot/on_loading.gif";--%>
|
||||||
src = "<%=sensorImg%>/on_loading.gif";
|
src = "<%=sensorImg%>/on_loading.gif";
|
||||||
}
|
}
|
||||||
obj.attr("src",src);
|
obj.attr("src", src);
|
||||||
commonAjax('PUT',localUrl+"/sensor/control/realtime/update", {id:id,request_sdata:requestData },function(data){
|
commonAjax('PUT', localUrl + "/sensor/control/realtime/update", {
|
||||||
if(isOK(data)){
|
id: id,
|
||||||
obj.attr("src",src);
|
request_sdata: requestData
|
||||||
}else{
|
}, function (data) {
|
||||||
|
if (isOK(data)) {
|
||||||
|
obj.attr("src", src);
|
||||||
|
} else {
|
||||||
$.toptip(data.statusMsg, 'error');
|
$.toptip(data.statusMsg, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceState(state){
|
function getDeviceState(state) {
|
||||||
if(state == 16 ){
|
if (state == 16) {
|
||||||
return "state";
|
return "state";
|
||||||
}else if(state == 19 || state == 17){
|
} else if (state == 19 || state == 17) {
|
||||||
return "state-red" ;
|
return "state-red";
|
||||||
}else if(state == 18 ){
|
} else if (state == 18) {
|
||||||
return "state-default" ;
|
return "state-default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSensorListHtml(dataT,sid , node_status ){
|
function getSensorListHtml(dataT, sid, node_status) {
|
||||||
var str = '' ;
|
var str = '';
|
||||||
<%--var src1 = 'src="<%=basePath%>/image/oss/iot/on.png"';--%>
|
<%--var src1 = 'src="<%=basePath%>/image/oss/iot/on.png"';--%>
|
||||||
var src1 = 'src="<%=sensorImg%>/on.png"';
|
var src1 = 'src="<%=sensorImg%>/on.png"';
|
||||||
<%--var src2 = 'src="<%=basePath%>/image/oss/iot/off.png"';--%>
|
<%--var src2 = 'src="<%=basePath%>/image/oss/iot/off.png"';--%>
|
||||||
var src2 = 'src="<%=sensorImg%>/off.png"';
|
var src2 = 'src="<%=sensorImg%>/off.png"';
|
||||||
// console.log("device getSensorListHtml with %s, %o, %s", sid, dataT, node_status);
|
// console.log("device getSensorListHtml with %s, %o, %s", sid, dataT, node_status);
|
||||||
for(var i=0;i<dataT.length;i++){
|
for (let i = 0; i < dataT.length; i++) {
|
||||||
if( dataT[i].data_type ==2){
|
if (dataT[i].data_type == 2) {
|
||||||
continue ;
|
continue;
|
||||||
}
|
}
|
||||||
// 传感器logo数据
|
// 传感器logo数据
|
||||||
var sensorLogo = dataT[i].measure_unit_type ;
|
var sensorLogo = dataT[i].measure_unit_type;
|
||||||
if( dataT[i].iot_sensor_type == 25 ){
|
if (dataT[i].iot_sensor_type == 25) {
|
||||||
|
|
||||||
str+=$("#template1").html().format(disvalue(dataT[i].name,15),
|
str += $("#template1").html().format(disvalue(dataT[i].name, 15),
|
||||||
getDsv( gdv(dataT[i].sdata,0),node_status ) +" "+dataT[i].data.measure_unit_type
|
getDsv(gdv(dataT[i].sdata, 0), node_status) + " " + dataT[i].data.measure_unit_type
|
||||||
,dataT[i].id
|
, dataT[i].id
|
||||||
,sid
|
, sid
|
||||||
,sensorLogo
|
, sensorLogo
|
||||||
, getDisInfo(dataT[i]) );
|
|
||||||
}
|
|
||||||
else if( dataT[i].iot_sensor_type == 26 ){
|
|
||||||
|
|
||||||
if( dataT[i].measure_unit_type == 250 ){
|
|
||||||
str+=$("#template3").html().format(disvalue(dataT[i].name,15),
|
|
||||||
getDsv( getWindUint(gdv(dataT[i].sdata,0)) ,node_status)
|
|
||||||
,dataT[i].id
|
|
||||||
,sid
|
|
||||||
,sensorLogo
|
|
||||||
, getDisInfo(dataT[i]));
|
, getDisInfo(dataT[i]));
|
||||||
}else{
|
} else if (dataT[i].iot_sensor_type == 26) {
|
||||||
str+=$("#template3").html().format(disvalue(dataT[i].name,15),
|
|
||||||
getDsv( gdv(dataT[i].data.measure_unit_type,'-') , node_status)
|
if (dataT[i].measure_unit_type == 250) {
|
||||||
,dataT[i].id
|
str += $("#template3").html().format(disvalue(dataT[i].name, 15),
|
||||||
,sid
|
getDsv(getWindUint(gdv(dataT[i].sdata, 0)), node_status)
|
||||||
,sensorLogo
|
, dataT[i].id
|
||||||
|
, sid
|
||||||
|
, sensorLogo
|
||||||
|
, getDisInfo(dataT[i]));
|
||||||
|
} else {
|
||||||
|
str += $("#template3").html().format(disvalue(dataT[i].name, 15),
|
||||||
|
getDsv(gdv(dataT[i].data.measure_unit_type, '-'), node_status)
|
||||||
|
, dataT[i].id
|
||||||
|
, sid
|
||||||
|
, sensorLogo
|
||||||
, getDisInfo(dataT[i]));
|
, getDisInfo(dataT[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (dataT[i].iot_sensor_type == 27) {
|
||||||
else if( dataT[i].iot_sensor_type == 27 ){
|
str += $("#template2").html().format(disvalue(dataT[i].name, 15),
|
||||||
str+=$("#template2").html().format(disvalue(dataT[i].name,15),
|
tom(getSwitch(dataT[i].sdata, node_status) == 1.0, src1, src2),
|
||||||
tom( getSwitch( dataT[i].sdata, node_status) == 1.0 ,src1,src2 ),
|
dataT[i].id, dataT[i].sdata, sid, dataT[i].data.measure_unit_type_value, sensorLogo, getDisInfo(dataT[i]));
|
||||||
dataT[i].id,dataT[i].sdata,sid,dataT[i].data.measure_unit_type_value,sensorLogo, getDisInfo(dataT[i]) );
|
} else if (dataT[i].iot_sensor_type == 90) {
|
||||||
}
|
|
||||||
else if(dataT[i].iot_sensor_type == 90 ){
|
|
||||||
|
|
||||||
str+=$("#template4").html().format(disvalue(dataT[i].name,15),
|
str += $("#template4").html().format(disvalue(dataT[i].name, 15),
|
||||||
getDsv( gdv(dataT[i].str_sdata,'-'),node_status) ,dataT[i].id,sid,sensorLogo);
|
getDsv(gdv(dataT[i].str_sdata, '-'), node_status), dataT[i].id, sid, sensorLogo);
|
||||||
}
|
} else if (dataT[i].iot_sensor_type == 190) {
|
||||||
else if(dataT[i].iot_sensor_type == 190){
|
|
||||||
|
|
||||||
str+=$("#template6").html().format(disvalue(dataT[i].name,15),
|
str += $("#template6").html().format(disvalue(dataT[i].name, 15),
|
||||||
<%--'src="<%=basePath%>/image/oss/iot/switch.png"',--%>
|
<%--'src="<%=basePath%>/image/oss/iot/switch.png"',--%>
|
||||||
'src="<%=sensorImg%>/switch.png"',
|
'src="<%=sensorImg%>/switch.png"',
|
||||||
dataT[i].id,dataT[i].param_type,sid,dataT[i].data.measure_unit_type,sensorLogo );
|
dataT[i].id, dataT[i].param_type, sid, dataT[i].data.measure_unit_type, sensorLogo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(validater.empty(str)){
|
|
||||||
|
|
||||||
|
if (validater.empty(str)) {
|
||||||
str = "<p class='tempdata'>暂无数据</p>";
|
str = "<p class='tempdata'>暂无数据</p>";
|
||||||
}
|
}
|
||||||
return str ;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSwitch(value, status){
|
function getSwitch(value, status) {
|
||||||
if( status != 16 ){
|
if (status != 16) {
|
||||||
return 0 ;
|
return 0;
|
||||||
}else{
|
} else {
|
||||||
return value ;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDsv(value ,status ){
|
function getDsv(value, status) {
|
||||||
if( status != 16 ){
|
if (status != 16) {
|
||||||
return "-" ;
|
return "-";
|
||||||
}else{
|
} else {
|
||||||
return value ;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function forwardVideo(){
|
function forwardVideo() {
|
||||||
forward('/wiot/video?id='+GetQueryString("id") );
|
forward('/wiot/video?id=' + GetQueryString("id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWindUint(sdata){
|
function getWindUint(sdata) {
|
||||||
if( sdata == 0 ){
|
if (sdata == 0) {
|
||||||
return "北风 " ;
|
return "北风 ";
|
||||||
}else if( sdata >0 && sdata <90 ){
|
} else if (sdata > 0 && sdata < 90) {
|
||||||
return "东北 ";
|
return "东北 ";
|
||||||
}else if( sdata == 90 ){
|
} else if (sdata == 90) {
|
||||||
return "东 ";
|
return "东 ";
|
||||||
}else if( sdata >90 && sdata <180 ){
|
} else if (sdata > 90 && sdata < 180) {
|
||||||
return "东南 ";
|
return "东南 ";
|
||||||
}else if( sdata== 180 ){
|
} else if (sdata == 180) {
|
||||||
return "南 ";
|
return "南 ";
|
||||||
}else if( sdata >180 && sdata <270 ){
|
} else if (sdata > 180 && sdata < 270) {
|
||||||
return "西南 ";
|
return "西南 ";
|
||||||
}else if( sdata ==270 ){
|
} else if (sdata == 270) {
|
||||||
return "西 ";
|
return "西 ";
|
||||||
}else if( sdata >270 ){
|
} else if (sdata > 270) {
|
||||||
return "西北 ";
|
return "西北 ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue