<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<%@include file="/WEB-INF/page/header.jsp"%>
<script>
	changeMenu(5, '');//左边菜单active
</script>

<div class="row wrapper border-bottom white-bg page-heading">
	<div class="col-lg-12">
		<h2>我的帐户</h2>
	</div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-8">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<div class="row">
						<div class="col-sm-6">
							<h5>帐号信息</h5>
						</div>
						<div class="col-sm-6">
							<a class="btn btn-sm btn-primary pull-right m-t-n-xs" href="${contextPath}/account/areaAccount">
								<strong>地区帐号</strong>
							</a>
						</div>
					</div>
				</div>
				<div class="ibox-content">
					<div class="row">
						<div class="col-sm-6 b-r">
						<h3>
							<p class="text-center">
								<br><br><br>
								累计收入：<font color="red">${sessionScope.SESSION_COMPANY.totalBF}</font>元
								<br><br><br><br><br><br>
							</p></h3>
						</div>
						<div class="col-sm-6">
								<br>
								<div class="form-group">
									<label>开户名：</label> ${sessionScope.SESSION_COMPANY.accountName}
								</div>
								<div class="form-group">
									<label>开户行：</label> ${sessionScope.SESSION_COMPANY.accountBank}
								</div>
								<div class="form-group">
									<label>帐&nbsp;&nbsp;&nbsp;&nbsp;号：</label> ${sessionScope.SESSION_COMPANY.accountNum}
								</div>
								<br>
								<div>
									<button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="button" onclick="edit()">
										<strong>修改</strong>
									</button>
								</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>

</div>

<div id="mod-account" class="modal fade" tabindex="-1">
	  <div class="modal-dialog" style="max-width: 400px;">
	      <div class="modal-content">
	      	<div class="modal-header">
      			<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					修改账户信息
				</div>
	      	</div>
	        <div class="modal-body">
                 <form role="form">
					<div class="form-group">
						<label>开户名</label> <input type="text" id="accountName" 
							value="${sessionScope.SESSION_COMPANY.accountName}" class="form-control">
					</div>
					<div class="form-group">
						<label>开户行</label> <input type="text" id="accountBank" 
							value="${sessionScope.SESSION_COMPANY.accountBank}" class="form-control">
					</div>
					<div class="form-group">
						<label>帐    号</label> <input type="text" id="accountNum" 
							value="${sessionScope.SESSION_COMPANY.accountNum}" class="form-control">
					</div>
					<div class="form-group">
					
						<label>验证码</label>
						<div class="input-group"> <input type="text" id="checkCode" class="form-control"> <span class="input-group-btn"> <button class="btn btn-white" type="button" id="mod-account-check">发送</button> </span></div>
                                        
						
					</div>
				</form>
	      	</div>
	      	<div class="modal-footer">
	      		<button class="btn btn-primary" type="button" id="mod-account-submit"><strong><i class="fa fa-floppy-o bigger-160"></i> 修改</strong></button>
                <button class="btn" data-dismiss="modal"><i class="fa fa-share bigger-160"></i> 取消</button>
			</div>
	      </div>
	  </div>
</div>
	
<%@include file="/WEB-INF/page/footer.jsp" %>

<script>
function edit(){
	$("#checkCode").val('');
	$("#mod-account").modal("toggle");
}

	jQuery(function($) {
		//初始化
		$('#mod-account-submit').on('click', function() {
	   		if($("#accountName").val()==''||$("#accountBank").val()==''||$("#accountNum").val()==''){
	   			alert('请输入有效信息');
	   			return;
	   		}
	   		if($("#checkCode").val()==''){
	   			alert('请输入验证码');
	   			return;
	   		}
			$.ajax({
				url : "${contextPath}/user/saveAccount",
				data : {
					accountName : $("#accountName").val(),
					accountBank : $("#accountBank").val(),
					accountNum : $("#accountNum").val(),
					code:$("#checkCode").val(),
				},
				type : 'POST',
				dataType : 'json',
				success : function(data) {
					if(data.success){
						alert('修改成功');
						$("#mod-account").modal("toggle");
						location.reload();
					}else{
						alert(data.message);
					}
				},
			});
		});
		
		$('#mod-account-check').on('click', function() {
	   		
			$.ajax({
				url : "${contextPath}/user/accountSendCode",
				type : 'POST',
				dataType : 'json',
				success : function(data) {
					if(data.success){
						alert('已经向${sessionScope.SESSION_COMPANY.tel}发送验证码');
					}else{
						alert(data.message);
					}
				},
			});
		});
	});
</script>


