westdc-zf1/application/admin/views/scripts/data/author-edit.phtml

130 lines
4.3 KiB
PHTML

<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('数据作者管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="rightPanel">
<div id="loading" class="info info-box"></div>
<div id="datalist">
<h2><?php echo $this->authors[0]['title']; ?></h2>
<span id="addauthor_<?php echo $this->authors[0]['id'];?>"><a href="javascript:;" onclick="AddAuthor(<?php echo $this->authors[0]['id']; ?>,'<?php echo $this->authors[0]['uuid']; ?>')">添加作者</a></span>
<ul>
<?php
if(isset($this->authors))
{
foreach($this->authors as $v)
{
?>
<li id="author_<?php echo $v['id'] ;?>">
<p><?php echo $v['realname']; ?> [ <?php echo $v['username']; ?> ]</p>
<p><span id="status_<?php echo $v['id'] ;?>"><?php if($v['status']==1) {echo "已认证";} if($v['status']==0) {echo "已申请";} if($v['status']==-1) {echo "已拒绝";} ?></span> |
<a href="javascript:;" onclick="remove(<?php echo $v['id'] ;?>)">移除该作者</a>
<span id="statusChange_<?php echo $v['id'] ;?>"><?php if($v['status']<1) {?> <a href="javascript:;" onclick="update(<?php echo $v['id'] ;?>)">认证该用户</a> <?php }?></span>
</p>
</li>
<?php } } ?>
</ul></div>
</div>
<!-- //页面内容 -->
<script>
function update(id){
$.ajax({
'type':"POST",
'url':'/admin/data/author/',
'data':'ac=update&id='+id,
'success':function(data){
if (data!=null)
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(data.msg!=null)
{Alert(data.msg);}
if(typeof(data.updated)!='undefined')
{$('#status_'+data.updated).html('已认证');$('#statusChange_'+data.updated).html('');}
}else{
Alert('处理中出现错误');
}
},
'timeout': 30000
});
}
function remove(id){
if(confirm('确实要删除吗?')==false)
{return false;}
$.ajax({
type:"POST",
url:'/admin/data/author',
data:'ac=del&id='+id,
success:function(data){
if (data!=null)
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(typeof(data.deleted)!='undefined')
{$('#author_'+data.deleted).fadeOut("slow",function(){$(this).remove();});}
}else{
Alert('处理中出现错误');
}
},
'timeout': 30000
});
}
function AddAuthor(id,uuid){
$('#addauthor_'+id).html('用户名:<input type="text" id="authorInp_'+id+'"/><button class="btn btn-green" onclick="addAuthor('+id+',\''+uuid+'\')">添加</button>');
}
function addAuthor(id,uuid){
$.ajax({
'type':"POST",
'url':'/admin/data/author',
'data':'ac=add&uuid='+uuid+'&username='+$('#authorInp_'+id).val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(typeof(data.msg)!='undefined')
{Alert(data.msg);}
if(typeof(data.added)!='undefined')
{$('#addauthor_'+id).html('<a href="javascript:;" onclick="AddAuthor('+id+',\''+uuid+'\')">添加作者</a>');}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
}
});
}
$('#loading').css("opacity","0.2");
$('#loading').ajaxComplete(function() {
$(this).css('display','none');
});
$('#loading').ajaxSend(function() {
$(this).css('display','block');
});
$("#loading").ajaxError(function() {
$(this).css('display','none');
Alert('请求超时或服务器开小差了,请刷新页面后重试');
});
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
}
</script>