You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
6.2 KiB
HTML

2 years ago
<extend name="Public/base"/>
<block name="body">
<div class="tabcon1711">
<form action="{:U('edit',array('id'=>I('id')))}" onsubmit = "check();" method="post" class="form-horizontal form_info_ml">
<input type="hidden" name="id" class="uuuid" value="{$id}">
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">绑定微信</h3>
<p class="description_text"></p>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l">管理员账号</td>
<td class="r">
<input name="username" value="{$list.username}" disabled="" style="background: #e7e7e7; " type="text" class=""><input type="hidden" class="" name="username" value="{$list.username}" >
<span class="notice-text">管理员账号用于管理后台登录</span>
</td>
</tr>
<tr>
<td class="l">关联微信账号</td>
<td class="r">
<label>绑定微信:<input type="radio" id="bind_wx" name="bind_wx"></label>
<label>解绑微信:<input type="radio" id="unbind_wx" name="bind_wx" value="unbind_wx">
<span class="notice-text">用于管理后台微信扫码登录</span>
</td>
</tr>
<tr>
<td class="l">绑定状态</td>
<td class="r">
<label><if condition="$list.admin_openid neq ''">已绑定<else/>未绑定</if></label>
</td>
</tr>
</tbody>
</table>
<div class="form-item" style="display: none;" id="wx_pic">
<img src="" width="150" class="wx_qrcode" style="margin-left: 75px">
</div>
</form>
</div>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
</block>
<block name="script">
<script>
$bind_wx=$("#bind_wx").prop('checked');
if($bind_wx){
cpsw=check(1);
}
if($bind_wx==false){
$('#wx_pic').attr('style','display:none');
}
$('#bind_wx').click(function(){
$bind_wxx=$("#bind_wx").prop('checked');
if($bind_wxx){
$('#wx_pic').attr('style','display:none');
cpsw=check(1);
}
if($bind_wxx==false){
$('#wx_pic').attr('style','display:none');
}
});
$unbind_wx=$("#unbind_wx").prop('checked');
if($unbind_wx){
$('#wx_pic').attr('style','');
unbindcheck(2);
}
$('#unbind_wx').click(function(){
$unbind_wx=$("#unbind_wx").prop('checked');
if($unbind_wx){
unbindcheck(2);
}
});
function get_openid(pwd,id,type){
var index = layer.load(0, {shade: false}); //0代表加载的风格支持0-2
$.ajax({
type:"POST",
data:{pwd:pwd,id:id,type:type},
url:"{:U('get_openid')}",
dataType:"json",
success:function(res){
if(res.status){
layer.close(index);
$('.wx_qrcode').attr('src',res.data);
$('#wx_pic').attr('style','');
$("#bind_wx").val('');
checkstatus(id);
}else{
updateAlert(res.msg,'tip_error');
}
},
error:function(){
}
})
};
function checkstatus(id,type){
$.ajax({
type:"POST",
url:"{:U('checkOpenidpic')}",
data:{id:id,type:type},
dataType:"json",
success:function(ress){
if(ress.status){
layer.msg("{:L('_OPERATION_SUCCESS_')}");
window.location.href="{:U('bdwx')}";
}else{
checkstatus(id);
}
},
error:function(){
}
})
}
function check($type){
var $id=$('.uuuid').val();
layer.prompt(
{
formType: 1,
title:"请输入密码",
value: '',
cancel: function(index){
$('#bind_wx').removeAttr("checked");
}
}
,function(val,index){
$.ajax({
url: '{:U("checkpwd")}',
type: 'post',
dataType: 'json',
data: {'pwd': val,'id':$id},
success:function(data){
if(data.data){
layer.close(index);
get_openid(val,$id,$type);
}else{
updateAlert("密码错误,请重新输入",'tip_error');
setTimeout(function(){$('#tip').find('.tipclose').click();},1000);
layer.close(index);
$('#bind_wx').removeAttr("checked");
}
},
error:function(){
alert("服务器故障!");
}
});
});
};
function unbindcheck(type){
var $id=$('.uuuid').val();
$('#wx_pic').attr('style','display:none');
layer.prompt(
{
formType: 1,
title:"请输入密码",
value: '',
cancel: function(index){
$('#unbind_wx').removeAttr("checked");
}
}
,function(val,index){
$.ajax({
url: '{:U("checkpwd")}',
type: 'post',
dataType: 'json',
data: {'pwd': val,'id':$id},
success:function(data){
if(data.data){
layer.close(index);
get_openid(val,$id,type);
}else{
updateAlert("密码错误,请重新输入",'tip_error');
setTimeout(function(){$('#tip').find('.tipclose').click();},1000);
layer.close(index);
$('#unbind_wx').removeAttr("checked");
}
},
error:function(){
alert("L('Server_failure')");
}
});
});
};
Think.setValue("auth", {$authid|default = 0});
//导航高亮
highlight_subnav('{:U('User/bdwx')}');
</script>
</block>