物联网平台 +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.
 
 
 
 

118 lines
3.2 KiB

<%@ 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;
padding-bottom: 20px;
background: #fff;
}
.weui-cells{
margin-top: 0;
font-size: 15px;
}
</style>
</head>
<body>
<div class="container">
<div class="t-c title-info">
<span>子账户授权</span>
<div class="back" onclick="forward('/wiot/maccount')" style=" position: fixed;top: 0px;" >返回</div>
</div>
<div style="height: 50px;"></div>
<div class="body-container">
<div class="weui-cells weui-cells_form">
<div class="weui-cell">
<div class="weui-cell__hd">
<label class="weui-label">子账户</label>
</div>
<input type="hidden" id="init-id" >
<div class="weui-cell__bd jui-auto hide" data-options="method:'GET', url:'/user/info?id=$#init-id$' ">
<span > {name} </span>
</div>
</div>
</div>
<div class="weui-cells__title">项目列表</div>
<div class="weui-cells weui-cells_checkbox body-containers">
</div>
<div class="width80 m-auto" style="padding: 30px 0;">
<a class="weui-btn" style="background: #3499da;" href="javascript:" id="saveBtn">保存</a>
</div>
</div>
<div id="template" class="hide" >
<label class="weui-cell weui-check__label" for="s{scene_id}">
<div class="weui-cell__hd">
<input type="checkbox" class="weui-check" sid="{scene_id}"
id="s{scene_id}" > <i class="weui-icon-checked"></i>
</div>
<div class="weui-cell__bd">
<p>{name}</p>
</div>
</label>
</div>
</div>
</body>
<script type="text/javascript">
$(function(){
$("#init-id").val( GetQueryString("id") ) ;
scene_init();
function scene_init(){
postAjax(localUrl+"/page/relation/scene/user?paged=1&pageSize=100", {user_id:'${user.id}' },function(data){
if( isOK(data) ){
var dataT = data.data.data ;
for(var i=0 ;i<dataT.length;i++){
$(".body-containers").append( $("#template").html().format(dataT[i]) );
}
//
// 获取该用户已有的授权信息
postAjax(localUrl+"/page/relation/scene/user?paged=1&pageSize=100", {user_id: GetQueryString("id") },function(data){
if( isOK(data) ){
var dataT = data.data.data ;
for(var i=0 ;i<dataT.length;i++){
$("#s"+ dataT[i].scene_id).attr("checked",true);
}
}
})
}
})
}
$("#saveBtn").click(function(){
var obj ='';
for(var i=0;i<$(".weui-check:checked").length;i++){
obj += ","+$(".weui-check:checked").eq(i).attr("sid");
}
// 保存更新数据
postAjax(localUrl+"/relation/scene/user", {user_id:GetQueryString("id") ,ids:obj.substring(1) },function(data){
if( isOK(data) ){
tip("保存成功");
setTimeout(function(){
forward("/wiot/maccount") ;
}, 500);
}else{
tip(data.statusMsg);
}
})
})
})
</script>
</html>