{template 'common/header'}
<ul class="we7-page-tab hidden">
	<li {if $do == 'base'}class="active"{/if}><a href="{php echo url('user/profile')}">我的账户</a></li>
	<li {if $do == 'bind'}class="active"{/if}><a href="{php echo url('user/profile/bind')}">账号绑定</a></li>
</ul>

<!--账号绑定-->
<div class="bind-account" ng-controller="userBindCtrl" ng-cloak>
<table class="table we7-table table-hover table-form" >
	<col width="140px " />
	<col />
	<col width="160px" />
	<tr>
		<th class="text-left" colspan="3">账号绑定</th>
	</tr>
	<tr>
		<td class="table-label"><span class="wi wi-iphone color-default" style="font-size: 32px;"></span></td>
		<td>{{bindmobile.third_nickname}}</td>
		<td>
			<div class="link-group">
				<a href="javascript:;"  data-toggle="modal" data-target="#myModal" ng-if="bindmobile.third_type == 3">解绑手机</a>
				<a href="javascript:;"  data-toggle="modal" data-target="#myModal" ng-if="bindmobile.third_type != 3">绑定手机</a>
				{if $_W['isadmin']}
				<a href="javascript:;"  data-toggle="modal" data-target="#founderModal" ng-if="bindmobile.third_type == 3">更换手机</a>
				{else}
				<a href="{php echo url('user/profile/change_mobile')}" ng-if="bindmobile.third_type == 3">更换手机</a>
				{/if}
			</div>
		</td>
	</tr>
	<tr>
		<td class="table-label"><span class="wi wi-qq color-default" style="font-size: 32px;"></span></td>
		<td>{{bindqq.third_nickname}}</td>
		<td>
			<div class="link-group">
				<a href="javascript:;" ng-if="bindqq.third_type == 1" ng-click="unbind(bindqq.third_type)">解除绑定</a>
				<a href="{{login_urls.qq}}" ng-if="bindqq.third_type != 1 && thirdlogin.qq.authstate == 1">绑定QQ</a>
			</div>
		</td>
	</tr>
	<tr>
		<td class="table-label"><span class="wi wi-account" style="font-size: 32px; color: #00bb00;"></span></td>
		<td>{{bindwechat.third_nickname}}</td>
		<td>
			<div class="link-group">
				<a href="javascript:;" ng-if="bindwechat.third_type == 2" ng-click="unbind(bindwechat.third_type)">解除绑定</a>
				<a href="{{login_urls.wechat}}" ng-if="bindwechat.third_type != 2 && thirdlogin.wechat.authstate == 1">绑定微信</a>
			</div>
		</td>
	</tr>
	<div class="modal fade basic" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel">
						<span ng-if="bindmobile.third_type != 3">绑定手机号</span>
						<span ng-if="bindmobile.third_type == 3">解绑手机号</span>
					</h4>
				</div>
				<div class="modal-body material-content clearfix">
					<div class="form-group input-group">
						<input type="text" class="form-control" placeholder="输入手机号" ng-model="mobile">
						<span class="input-group-btn">
							<button class="btn btn-primary send-code" ng-disabled="isDisable" ng-click="sendMessage(bindmobile.third_nickname)">{{text}}</button>
						</span>
					</div>
					<div class="form-group input-group">
						<input type="text" ng-model='imagecode' class="form-control" placeholder="输入图形验证码">
						<a href="javascript:;" class="input-group-btn imgverify" style="" ng-click="changeVerify()"><img ng-src="{{image}}" style="width: 127px; height: 32px;"/></a>
					</div>
					<div class="form-group">
						<input type="text" ng-model='smscode' class="form-control" placeholder="输入手机验证码">
					</div>
					{if empty($bind_mobile)}
					<div class="form-group">
						<input type="password" ng-model='password' class="form-control" placeholder="输入密码">
					</div>
					<div class="form-group">
						<input type="password" ng-model='repassword' class="form-control" placeholder="再次输入密码">
					</div>
					{/if}
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" ng-click="mobileBind(bindmobile.third_nickname, 3)">确定</button>
					<button type="button" class="btn smscodebtn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
	{if $_W['isadmin']}
	<div class="modal fade basic" id="founderModal" tabindex="-1" role="dialog" aria-labelledby="founderModalLabel">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="founderModalLabel">
						<span>选择验证方式</span>
					</h4>
				</div>
				<div class="modal-body">
					<div class="sms-change-tip">
						<p >创始人绑定的原始手机<span class="color-default">{{bindmobile.third_nickname | mobile}}</span>是否还在使用</p>
						<p class="color-gray">如果手机号还能用，发送短信即可完成验证</p>
					</div>
					<a href="javascript:;" class="sms-change-type" style="display: none"　data-dismiss="modal" aria-label="Close">
						手机号已停用
					</a>
					<a href="{php echo url('user/profile/change_mobile')}" class="sms-change-type">
						手机号可以正常使用
					</a>
				</div>
			</div>
		</div>
	</div>
	{/if}
	<!--end  账号绑定-->
</table>
</div>
<script>
	angular.module('userProfile').value('config',{
		'bindqq': {php echo !empty($bind_qq) ? json_encode($bind_qq) : 'null'},
		'bindwechat': {php echo !empty($bind_wechat) ? json_encode($bind_wechat) : 'null'},
		'bindmobile': {php echo !empty($bind_mobile) ? json_encode($bind_mobile) : 'null'},
		'login_urls': {php echo !empty($support_login_urls) ? json_encode($support_login_urls) : 'null'},
		'thirdlogin' : {php echo !empty($_W['setting']['thirdlogin']) ? json_encode($_W['setting']['thirdlogin']) : 'null'},
		'bind_sign': "{php echo !empty($bind_sign) ? $bind_sign : 'null'}",
		'image' : "{php echo url('utility/code')}",
		'links':{
			'img_verify_link': "{php echo url('utility/code')}",
			'send_code_link': "{php echo url('utility/verifycode')}",
			'valid_mobile_link' : "{php echo url('user/profile/validate_mobile')}",
			'bind_mobile_link' : "{php echo url('user/profile/bind_mobile')}",
			'unbind_third_link' : "{php echo url('user/profile/unbind')}",
		},
	});
	angular.bootstrap($('.bind-account'), ['userProfile']);
</script>
{template 'common/footer'}