<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>提现</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
<script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script src="/js/common/common.js"></script>
<link href="/css/common/common.css" rel="stylesheet" type="text/css">
<style type="text/css">
.withdraw-form {
	padding-left: 1rem;
	padding-right: 1rem;
	padding-top: 3rem;
}

.withdraw-form .row {
	padding-bottom: 1rem;
}

.withdraw-form-item label {
	text-align: end;
	width: 5rem;
	margin-right: 1rem;
}

.withdraw-form-item input {
	border: 0;
	outline: none;
	border-bottom: 1px solid #35a79c;
}
</style>
</head>

<body>
	<div th:replace="common/header::html"></div>
	<div id="withdraw" v-cloak>
		<div class="page-body">
			<div class="withdraw-form">
				<div class="row">
					<div class="col-sm-9 offset-sm-3 withdraw-form-item">
						<label>开户银行</label> <span>{{bankInfo.openAccountBank}}</span>
					</div>
				</div>
				<div class="row">
					<div class="col-sm-9 offset-sm-3 withdraw-form-item withdraw-form-highlight-item">
						<label>开户人姓名</label> <span>{{bankInfo.accountHolder}}</span>
					</div>
				</div>
				<div class="row">
					<div class="col-sm-9 offset-sm-3 withdraw-form-item withdraw-form-highlight-item">
						<label>银行卡账号</label> <span>{{bankInfo.bankCardAccount}}</span>
					</div>
				</div>
				<div class="row">
					<div class="col-sm-9 offset-sm-3 withdraw-form-item withdraw-form-highlight-item">
						<label>保证金</label> <span>{{cashDeposit}}</span>元
					</div>
				</div>
				<div class="row">
					<div class="col-sm-9 offset-sm-3 withdraw-form-item">
						<label>提现金额</label> <span><input type="number" class="withdraw-amount-input-item" v-model="withdrawAmount"></span>元
					</div>
				</div>
				<div class="row">
					<div class="col-sm-9 offset-sm-3 withdraw-form-item">
						<label>资金密码</label> <span><input type="password" class="withdraw-amount-input-item" v-model="moneyPwd"></span>
					</div>
				</div>
				<div class="row">
					<div class="col-sm-9 offset-sm-3">
						<div class="alert alert-light" style="font-size: 14px; padding-top: 0px;">提款下限，10元/次;单笔上限999999999999999元，单日限额1000000元，单日提现次数限制5次</div>
					</div>
				</div>
				<div class="row">
					<div class="col-sm-12">
						<button type="button" class="btn btn-success btn-lg btn-block" v-on:click="confirmWithdraw">确认提现</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		var withdrawVM = new Vue({
			el : '#withdraw',
			data : {
				bankInfo : '',
				cashDeposit : '',
				withdrawAmount : '',
				moneyPwd : ''
			},
			computed : {},
			created : function() {
			},
			mounted : function() {
				headerVM.title = '提现';
				headerVM.showBackFlag = true;
				this.loadBankInfo();
				this.getUserAccountInfo();

			},
			methods : {
				loadBankInfo : function() {
					var that = this;
					that.$http.get('/userAccount/getBankInfo').then(function(res) {
						that.bankInfo = res.body.data;
					});
				},

				/**
				 * 获取用户账号信息
				 */
				getUserAccountInfo : function() {
					var that = this;
					that.$http.get('/userAccount/getUserAccountInfo').then(function(res) {
						if (res.body.data != null) {
							that.cashDeposit = res.body.data.cashDeposit;
						}
					});
				},

				confirmWithdraw : function() {
					var that = this;
					if (that.withdrawAmount == null || that.withdrawAmount == '') {
						layer.alert('请输入提现金额');
						return;
					}
					if (that.withdrawAmount > that.cashDeposit) {
						layer.alert('提现金额不足');
						return;
					}
					if (that.moneyPwd == null || that.moneyPwd == '') {
						layer.alert('请输入资金密码');
						return;
					}
					that.$http.post('/withdraw/startWithdraw', {
						withdrawAmount : that.withdrawAmount,
						moneyPwd : that.moneyPwd
					}, {
						emulateJSON : true
					}).then(function(res) {
						layer.open({
							title : '提示',
							icon : '1',
							closeBtn : 0,
							btn : [],
							content : '已发起提现请求,系统审核通过后会马上为您出款!',
							time : 2000,
							end : function() {
								window.location.reload();
							}
						});
					});
				}
			}
		});
	</script>
</body>
</html>