{include "header.inc.html"}
{$linksLang = $lang.admin.links.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>QQ登录用户</strong><br />
		<span class="english">QQ Auth</span> </span> </div>
	</div>
<div class="tool">
{if $smarty.get.act=="list" || $smarty.get.act==""}
<a id="deleteChecked">删除所选</a>
{/if}
</div>
{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<div class="linksForm">
<form class="form" action="" method="post">
<input type="hidden" name="act" value="{$smarty.get.act}" />
{if $smarty.get.act=="edit"}
<input type="hidden" name="id" value="{$smarty.get.id}" />
{/if}
<div class="form-line"><label class="label">链接分类：</label><div class="element">
<select name="catId">{linkscat}<option value="{$item.id}"{if $linksInfo.catId==$item.id} selected{/if}>{$item.name}</option>{/linkscat}</select>
</div></div>
<div class="form-line"><label class="label">{$linksLang.name}：</label><div class="element"><input type="text" class="text w300" name="name" value="{$linksInfo.name}" /></div></div>
<div class="form-line"><label class="label">{$linksLang.title}：</label><div class="element"><input type="text" class="text w300" name="title" value="{$linksInfo.title}" /></div></div>
<div class="form-line"><label class="label">{$linksLang.url}：</label><div class="element"><input type="text" class="text w300" name="url" value="{$linksInfo.url}" /></div></div>
<div class="form-line"><label class="label">{$lang.form.iStatus}：</label><div class="element"><input type="checkbox" class="" name="iStatus" id="iStatus" value="1"{if $linksInfo.iStatus==1 || not isset($linksInfo)} checked{/if} /><label for="iStatus">有效</label></div></div>
<div class="form-line"><label class="label">{$lang.form.sort}：</label><div class="element"><input type="text" class="text w300" name="sortId" value="{$linksInfo.sortId}{if $smarty.get.act=='add'}50{/if}" /></div></div>
<div class="form-line">
<label class="label">图标：</label><div class="element"><input type="hidden" name="thumbId" id="thumbId" value="{$linksInfo.thumbId}" />
{if  $linksInfo.thumbId}
{attachment id=$linksInfo.thumbId limit=1}
<img id="img-thumb" src="{$item.url}" />
{/attachment}
{else}
<img id="img-thumb" src="/static/images/default.png" />
{/if}<br><span id="uploadBtn"></span>
</div>
</div>

<div class="form-line"><label class="label"></label><div class="element"><button class="correct_btn"><span>{$lang.form.submit}</span></button></div></div>
</form>

{else}
<table class="table-ca table_1" id="tInfo">
<tr>
<th class="w30"><input type="checkbox" value="1" name="allid" id="checkall" /></th><th class="w60">用户ID</th><th class="w100">昵称</th><th class="">openid</th><th class="">access_token</th><th class="w120">注册时间</th><th class="w40">{$lang.form.operate}</th>
</tr>
{qqauth limit=15}
<tr><td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.userId}</td><td>{$item.userInfo.nickname}</td><td>{$item.openid}</td><td>{$item.access_token}</td><td>{$item.posttime|date_format:"Y-m-d H:i:s"}</td><td><a href="javascript:void(0)" class="delBtn">{$lang.del}</a></td></tr>
{/qqauth}
</table>
<div class="page"><div class="pagin fr">{pager allCount=$allCount url='/qkadmin/links/page' number="false"}</div></div>

<script type="text/javascript">
$(function(){
	$("a#deleteChecked").button().click(function(){
		if(!confirm(lang[4])){ return false; }		
		var id = [];
		$("input[name='id[]']:checkbox:checked").each(function(index){
			id[index] = $(this).val();
			var sid = $(this).val();
			if(sid){
				var tr = $(this).parent("td").parent("tr");
				var sdata = "inajax=1&act=del&id="+sid;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}qqauth",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});			
			}
		});
		
	});
	$(".delBtn").click(function(){
		if(!confirm(lang[4])){ return false; }
			var tr = $(this).parent("td").parent("tr");
			var id = tr.find("td").eq(1).text();
			if(parseInt(id,10)){
				var sdata = "inajax=1&act=del&id="+id;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}qqauth",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});
			}
		return false;
	});
})
</script>

{/if}

{include "footer.inc.html"}