<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> 
<title>公司认证</title>
<link rel="stylesheet" type="text/css" href="${ctx }/styles/common/reset.css?v=2.0" />
<link rel="stylesheet" type="text/css" href="${ctx }/styles/common/loadview.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/styles/userset/authentication.css?v=1.3" />
<script type="text/javascript" src="${ctx }/scripts/common/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="${ctx }/scripts/common/common.js?v=1.0"></script>
<script type="text/javascript" src="${ctx }/scripts/wechat/controlOptionMenu.js"></script>
<script type="text/javascript">
	var contextPath="";

	$(function(){
		contextPath=$("#contextPath").val();
		
		//初始化院系
		initvirtualArch();
		
		$(".arrow-right").click(function(event) {
            $(".tips-mask").show();
        });
		
        $(".tip-btn a").click(function(event) {
          $(".tips-mask").hide();
        });
        
      	//确定按钮
		$(".success-back").click(function(){
			$(".success-mask").hide();
			var detailsUrl=contextPath+"/wechat/appUser/uauthentication?userId="+$("#userId").val()+"&developId="+$("#developId").val()+"&openId="+$("#openId").val()+"&organizationId="+$("#organizationId").val()+"&actType=edit";
			window.location.href = detailsUrl;
		});
        
        $("#submitBtn").click(function(){
        	$(".tcbj").show();
        });
	});
	
	function initvirtualArch(){
		var organizationId=$("#organizationId").val();
		if(organizationId!=null&&""!=organizationId){
			$.ajax({
    	    	url: contextPath+"/wechat/appUser/getVirtualArchitectureList",
    	    	data: {organizationId:organizationId,type:"1"},
    	        type: "POST",
    	        dataType: "json",
    	        success: function(data){
    	        	var virtualArchId_=$("#virtualArchId_").val();
    	        	var htmlStr="<option value=''>暂无选择公司</option>";
    	        	$.each(data,function(index,obj){
    	        		if(virtualArchId_!=""&&virtualArchId_==obj.id){
    	        			htmlStr+="<option value='"+obj.id+"' selected='selected'>"+obj.name+"</option>";
    	        		}
    	        		else{
    	        			htmlStr+="<option value='"+obj.id+"'>"+obj.name+"</option>";
    	        		}
    	        	});
    	        	$("#groupId").html(htmlStr);
    	        },
    	        error: function(){
    	        	alert("请检查您的网络，通信超时.");
    	        }
    	    });	
		} 
	}
	
	function doExecute(){
		$(".tcbj").hide();
		
   		var userId=$("#userId").val();
   		$.ajax({
	    	url: contextPath+"/wechat/appUser/removeBinding",
	    	data: {userId:userId},
	        type: "POST",
	        beforeSend: function(){
	        	$("#tcc").show();
	        },
	        success: function(data){
	        	if("success"==data){
	        		$("#tcc").hide();
	        		$(".success-mask").show();
	        	}
	        	else{
	        		alert("解绑失败，请检查网络稍后再试.");
	        		$("#tcc").hide();
	        	}
	        },
	        error: function(){
	        	alert("请检查您的网络，通信超时.");
	        }
	    });	
	}
	
	//取消操作
	function cancle(){
		$(".tcbj").hide();
	}
</script>
</head>
<body>
	<input type="hidden" id="contextPath" value="${ctx}" />
	<input type="hidden" id="virtualArchId_" value="${appUser.virtualArchId}" />
	<input type="hidden" id="userId" value="${appUser.id}" />
	<input type="hidden" id="developId" value="${developId}" />
	<input type="hidden" id="openId" value="${openId}" />
	<input type="hidden" id="organizationId" value="${organizationId}" />
	
	<div class="auth-form">
		<fieldset>
			<div class="auth-entry">
	            <label for="">姓名</label>${appUser.userName}
            </div>
			<div class="auth-select">
				<label for="">公司</label>
				<select name="" id="groupId" placeholder="请选择所在公司" disabled="disabled">
				</select>
			</div>
			<!-- 上传头像 -->
			<div class="auth-img clearfix">
				<em>头像</em> <span>上传脸部照片可开启刷脸开门</span> <i class="arrow-right"></i>
				<div class="uploadDiv clearfix">
					<c:forEach items="${userImageInfoList }" var="obj" >
						<div class='choiceHeadBtn' id='tempHeadDiv' ><img src='${visitPrefix }${obj.imageUrl}'></div>
					</c:forEach>
				</div>
			</div>
			<!-- 上传证件照片 -->
			<div class="auth-img clearfix">
				<em>证件照片</em> <span>工牌、工作证、身份证等</span>
				<div class="uploadDiv clearfix">
                    <c:if test="${!empty appUser.imageUrl01 }">
						<div class="addButton" >
	                    	<img src="${visitPrefix }${appUser.imageUrl01}">
	                    </div>
					</c:if>
					<c:if test="${!empty appUser.imageUrl02 }">
						<div class="addButton" >
	                    	<img src="${visitPrefix }${appUser.imageUrl02}">
	                    </div>
					</c:if>
					<c:if test="${!empty appUser.imageUrl03 }">
						<div class="addButton" >
	                    	<img src="${visitPrefix }${appUser.imageUrl03}">
	                    </div>
					</c:if>
				</div>
			</div>
		</fieldset>
		<input type="submit" value="解绑" class="superbtn" id="submitBtn" />
	</div>
	<div class="tips-mask" style="display: none;">
		<div class="tip">
			<img src="${ctx}/images/userlogin/facespecification.jpg" alt="" />
			<p class="tip-btn">
				<a href="javascript: void(0);">返回</a>
			</p>
		</div>
	</div>
	
	<div class="success-mask">
		<div class="success-con">
			<i class="success-icon"></i>
			<p>解绑成功</p>
			<a href="javascript: void(0);" class="success-back">确定</a>
		</div>
	</div>
	
	<!-- 加载层 -->
    <div id="tcc" class="tcbj1" style="display:none;">
        <div class="tcck1">
            <div class="load-container load4">
            <div class="loader">Loading...</div>
            </div>
        </div>
    </div>
    
    <div class="tcbj" style=" display:none">
	    <div class="tcck">
	        <div class="tcnr">
				确定解绑吗 ？(解绑之后，需要重新提交资料审核认证)
	        </div>
	        <div class="tcnn">
	        	<input type="submit" class="qx" value="取消" onclick="cancle();"/>
	            <input type="submit" class="qd" value="确认" onclick="doExecute();"/>
	        </div>
	    </div>
	</div>
</body>
</html>