物联网平台 +Web 组态
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
4.5 KiB

2 years ago
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.lp.cfg.ProConfig"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<title><%=ProConfig.PROJECT_NAME %></title>
<%@ include file="/WEB-INF/wechat/iot/common/resource_lib.jsp"%>
<style type="text/css">
.body-container{
background: #fff ;
padding-top: 20px;
}
.weui-cells{
margin-top: 0;
font-size: 15px;
}
.qrcode{
position: absolute;
width: 24px;
top: 10px;
right: 25px;
}
.weui-select{
height: 35px !important;
line-height: 35px !important;
padding-left:0;
}
</style>
</head>
<body>
<div class="container">
<div class="t-c title-info">
<span id="device_edit">绑定设备</span>
<div class="back" onclick="back()" style=" position: fixed;top: 0px;" >返回</div>
</div>
<div style="height: 50px;"></div>
<div class="body-container">
<div id="form_submit" class="weui-cells weui-cells_form jui-form_submit" data-options="url:'/node/bind',
submit:'#saveBtn',
success:'sunccessReturn'">
<div id="form_submit_update" data-options=" 'url':'/node/bind','method':'put',
'submit':'#saveBtn',
'success':'sunccessReturn' " >
<div id="detail_get" config-option=" 'url':'/node?id=$#init-id$' ">
<div class="weui-cell">
<div class="weui-cell__hd">
<label for="date" class="weui-label">所属项目:</label>
</div>
<div class="weui-cell__bd">
<select class="weui-select jui-selecter" id="sceneid" type-name="scene_id" validate="empty:请选择项目">
<option value=''>请选择项目</option>
</select>
</div>
</div>
<div class="weui-cell" style="position: relative;">
<div class="weui-cell__hd">
<label class="weui-label">设备号:</label>
</div>
<div class="weui-cell__bd">
<input class="weui-input device_code" maxlength="32" type-name="device_code" validate="empty" style="width: 80%" placeholder="请输入设备SN号">
<img class="qrcode" onclick="scanQRCode()" src="<%=basePath%>/image/wechat/iot/qrcodeimg.png" >
</div>
</div>
</div>
</div>
</div>
<div class="width80 m-auto" style="padding: 30px 0;margin-top: 70px;">
<a class="weui-btn" style="background: #3499da;" href="javascript:" id="saveBtn">绑定设备</a>
</div>
</div>
</div>
</body>
<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script src="<%=basePath%>/lib/weixinLib/WeixinApi.js"></script>
<script type="text/javascript">
var noncestr = "${noncestr}" ;
var timestamp = "${timestamp}" ;
var signature = "${signature}" ;
wx.config({
debug : false, // 开启调试模式
appId : "<%=ProConfig.WEIXIN.APP_ID%>",
timestamp : timestamp, // 必填,生成签名的时间戳
nonceStr : noncestr, // 必填,生成签名的随机串
signature : signature,// 必填,签名,见附录1
jsApiList : [ 'checkJsApi', 'scanQRCode','configWXDeviceWiFi' ]
});
var flag = WeixinApi.openInWeixin();
if(!flag){
// alert("请在微信浏览器中打开");
$(".qrcode").hide();
}
function scanQRCode(){
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
if(result != null && result.indexOf('device_id:')>-1 ){
$(".device_code").val(result.substring(10));
}else{
tip('设备号错误','w');
}
}
});
}
function getDataInfo(n){
postAjax(localUrl+"/page/scene.json?pageSize=100&paged="+n, {},function(data){
if(isOK(data)){
var dataT = data.data.data ;
var name = [] ;
var value = [] ;
for(var i=0;i<dataT.length;i++){
$("#sceneid").append( "<option value='"+dataT[i].id + "'>"+ dataT[i].name +"</option>");
}
}
});
}
$(function(){
getDataInfo(1);
})
function sunccessReturn(data){
if(isOK(data)){
tip("绑定成功");
setTimeout(function() {
forward('/wiot/mdevice?id='+GetQueryString("id") );
}, 1000);
}else{
tip(data.statusMsg,'w');
}
}
</script>
</html>