<?php
error_reporting(0); 
include("../../config/ht.php");
include("../../config/wxlist.php");
session_start();
if(!isset($_SESSION['adminname'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/houtai/'</script>";exit;}
$adminname=$_SESSION['adminname'];
$type="where name='$adminname'";
$adminpd=queryall(admin,$type);
if(!$adminpd){echo "<script>alert('请重新登录!')</script><script>top.location.href='/houtai/'</script>";exit;}
if($adminpd[qx]=='超级管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/houtai/'</script>";exit;}
$qsj=ubo($_GET["qsj"]);
$esj=ubo($_GET["esj"]);
$jsj=date("Y-m-d",strtotime("+1days",strtotime($esj)));  
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>微信资料列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/layui/css/layui.css" media="all" />
<script src="/layui/layui.js"></script>
<link rel="stylesheet" href="/2019newui/houtai/css/font-awesome.min.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/admin.css" media="all">
<script src="/2019newui/js/jquery.min.js"></script>
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
<div class="layui-tab-content">
<div class="layui-field-box">
<form class="layui-form" action="" method="post" name="peizhi1" id="peizhi1">
<input type="hidden"  value="wxlist"   name='lx'>
<div class="layui-form-item" style="text-align:center;">
开启关闭:

<?php if($kg==1){?>
<input type="radio" name="kg" value="1" title="开启"  checked="">
<input type="radio" name="kg" value="0" title="关闭">
<?php }else{?>
<input type="radio" name="kg" value="1" title="开启">
<input type="radio" name="kg" value="0" title="关闭"  checked="">
<?php }?>

</div>
<div class="layui-form-item" style="text-align:center;">
微信appid:
<div class="layui-inline" style="width:570px;">
<input autocomplete="off" class="layui-input" placeholder="请输入微信appid" type="text" name="appid" value="<?php echo $appid?>"  required lay-verify="required" >
</div>
</div>
<div class="layui-form-item" style="text-align:center;">
微信appsecret:
<div class="layui-inline" style="width:570px;">
<input autocomplete="off" class="layui-input" placeholder="请输入微信appsecret" type="text" name="appsecret" value="<?php echo $appsecret?>"  required lay-verify="required" >
</div>
</div>
<div class="layui-form-item" style="text-align:center;">
微信授权域名:
<div class="layui-inline" style="width:570px;">
<input autocomplete="off" class="layui-input" placeholder="请输入微信授权域名" type="text" name="squrl" value="<?php echo $squrl?>"  required lay-verify="required" >
</div>
</div>
<div class="layui-form-item" style="text-align:center;">
<div class="layui-inline" style="width:570px;">
<button  class="layui-btn" lay-submit="" lay-filter="peizhi1" style="width:570px;">提交</button>
</div>
</div>
</form>
</div>
</div>
<form class="layui-form" action="">
<div class="layui-form-item" style="text-align:center;">
开始时间
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" name="qsj"  autocomplete="off"   placeholder="yyyy-MM-dd HH:mm:ss" class="layui-input"  lay-verify="required"  id='qsj'  value="<?php echo $qsj?>"  >
</div>
</div>
结束时间
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" name="esj"  autocomplete="off"   placeholder="yyyy-MM-dd HH:mm:ss" class="layui-input"  lay-verify="required"  id='esj'  value="<?php echo $esj?>"  >
</div>
</div>
<div class="layui-inline" style="text-align:left;">
<div class="layui-input-inline">
<button class="layui-btn"><i class="layui-icon">&#xe615;</i>查询</button>
</form>
</div>
</div>
</div>
<hr>
<table class="layui-table" id="data-row">
<button class="layui-btn" onclick="yjsc()" >一键清理数据</button>
<thead>
<tr>
<th style="text-align:center;">ID编号</th>
<th style="text-align:center;">代理ID</th>
<th style="text-align:center;">微信用户名</th>
<th style="text-align:center;width: 120px;">微信头像</th>
<th style="text-align:center;">微信CODE</th>
<th style="text-align:center;">微信OPENID</th>
<th style="text-align:center;">页面链接</th>
<th style="text-align:center;">时间</th>
<th style="text-align:center;width:34px;">操作</th>
</tr> 
</thead>
<tbody>
<?php 
$page_size=10; 
if($qsj or $esj){
$resultyttrt = mysql_query("select * from wxlist   WHERE  shijian   BETWEEN '$qsj' AND  '$jsj'");
}else{
$sql = "WHERE 1=1";
$resultyttrt = mysql_query("select id from wxlist    ".$sql."  ");
}
$count = mysql_num_rows($resultyttrt); 
if($count == 0){echo '<tr> <td  colspan=18  style="text-align:center;"><center>没有记录</center></td></tr>';}
$page_count = ceil($count/$page_size); 
$init=1; 
$page_len=7; 
$max_p=$page_count; 
$pages=$page_count; 
if(empty($_GET['page'])||$_GET['page']<0){ 
$page=1; 
}else { 
$page=$_GET['page']; 
} 
$offset=$page_size*($page-1); 
if($qsj or $esj){
$query = mysql_query("select * from  wxlist   WHERE   shijian    BETWEEN '$qsj' AND  '$jsj'    order  by id desc   limit $offset, $page_size");
}else{
$query = mysql_query("select * from  wxlist   ".$sql." order by id desc   limit $offset, $page_size");
}
while ($a=mysql_fetch_array($query)) { 
?> 	

<tr>
<td style="text-align:center;"><?php echo $a[id]?></td>
<td style="text-align:center;"><?php echo $a[userid]?></td>
<td style="text-align:center;"><?php echo $a[wxname]?></td>
<td style="text-align: center;"><img style="width: 120px; height: 80px; cursor: -webkit-zoom-in;" src="<?php echo $a[pic]?>" ></td>
<td style="text-align:center;"><?php echo $a[code]?></td>
<td style="text-align:center;"><?php echo $a[openid]?></td>
<td style="text-align:center;"><?php echo $a[link]?></td>
<td style="text-align:center;"><?php echo $a[shijian]?></td>
<td class="text-center"><div class="layui-btn-group"><button class="layui-btn layui-btn-xs layui-btn-danger"  onClick="sc('<?php echo $a[id]?>')"><i class="layui-icon">&#xe640;</i>删除</button></div></td>
</tr>

<?php 
} 
$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数 
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量 
if($page!=1){ 
if($qsj or $esj){
$keyt.="<a href=\""."/htwxlistpage/1/?qsj=$qsj&esj=$esj\">首页</a>"; //首页 
$keyt.="<a href=\""."/htwxlistpage/".($page-1)."/?qsj=$qsj&esj=$esj\">上一页 </a>"; //上一页 
}else{
$keyt.="<a href=\""."/htwxlistpage/1/\">首页</a>"; //首页 
$keyt.="<a href=\""."/htwxlistpage/".($page-1)."/\">上一页 </a>"; //上一页 
}
}else { 
$keyt.="<p>首页</p>"; //首页 
$keyt.="<p>上一页 </p>"; //上一页
} 
if($pages>$page_len){ 
//如果当前页小于等于左偏移 
if($page<=$pageoffset){ 
$init=1; 
$max_p = $page_len; 
}else{//如果当前页大于左偏移 
//如果当前页码右偏移超出最大分页数 
if($page+$pageoffset>=$pages+1){ 
$init = $pages-$page_len+1; 
}else{ 
//左右偏移都存在时的计算 
$init = $page-$pageoffset; 
$max_p = $page+$pageoffset; 
} 
} 
} 
for($i=$init;$i<=$max_p;$i++){ 
if($i==$page){ 
$keyt.='<a class="cur">'.$i.'</a>'; 
} else { 
if($qsj or $esj){
$keyt.="<a href=\""."/htwxlistpage/".$i."/?qsj=$qsj&esj=$esj\">".$i."</a>"; 
}else{
$keyt.="<a href=\""."/htwxlistpage/".$i."/\">".$i."</a>"; 
}
} 
} 
if($page!=$pages){ 
if($qsj or $esj){
$keyt.="<a href=\""."/htwxlistpage/".($page+1)."/?qsj=$qsj&esj=$esj\">下一页 </a> ";//下一页 
$keyt.="<a href=\""."/htwxlistpage/{$pages}/?qsj=$qsj&esj=$esj\">尾页</a> "; //最后一页 
}else{
$keyt.="<a href=\""."/htwxlistpage/".($page+1)."/\">下一页 </a> ";//下一页 
$keyt.="<a href=\""."/htwxlistpage/{$pages}/\">尾页</a> "; //最后一页 
}
}else { 
$keyt.="<p>下一页 </p>";//下一页 
$keyt.="<p>尾页</p>"; //最后一页 
}
$keyt.="<p class='pageRemark' >当前第 <b>$page</b> 页/共 <b>$pages</b> 页  共 <b>$count</b> 条数据 </p>"; //第几页,共几页 
?> 
</tbody>
</table>
<?php if($count =="0" or $count<$page_size){?>
<?php }else{?>
<div style="padding:0 20px;">
<div class="pagination">
<?php echo $keyt?>
</div>
</div>
<?php }?>
</div>
<div id="img-div" style="position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 999999; text-align: center; display: none; ">
<img id="big-img" style="position:relative;z-index:99999;cursor:-webkit-zoom-out;" src="">
<div style="position:fixed;left:0;right:0;bottom:0;top:0;background:#000000;opacity:0.4; z-index:111;">
</div>
</div>
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'upload', 'layer'], function(){
var form = layui.form
,layer   = layui.layer
,layedit = layui.layedit
,element = layui.element
,upload  = layui.upload
,$       = layui.jquery
,laydate = layui.laydate;
  laydate.render({
    elem: '#esj'
    ,type: 'date'
  });
  laydate.render({
    elem: '#qsj'
    ,type: 'date'
  });
form.on('submit(peizhi1)', function (data) {
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type:'POST',
url : "/htpost<?php echo $dshz?>",
data:$("#peizhi1").serialize(),
dataType:'json',
success:function(result){
if(result.status == 'true'){
layer.closeAll('loading');
layer.open({
type: 1
,offset: 'auto'
,id: 'layerMsg'
,content: '<div style="padding: 20px 100px;">修改成功</div>'
,btn: '确定'
,btnAlign: 'c'
,shade: 0
,closeBtn: 0
,yes: function(index){
location.reload();
}
});
}else{
layer.closeAll('loading');
layer.msg(result.msg);
location.reload();
}
}	
});
return false;
});
});
$(function () {
$("body").on('click', '#data-row img', function () {
$("#big-img").attr("src", this.src);
var tWidth = document.body.offsetWidth;
var tHeight = window.screen.availHeight;
var sw = this.width;
var sh = this.height;
var tRate = tWidth * 1.0 / tHeight;
var rate = sw * 1.0 / sh;
var rh;
if (tRate > rate) {
$("#big-img").css("height", (tHeight - 280) + 'px');
$("#big-img").css('width', 'auto');
rh = tHeight - 80;
} else {
$("#big-img").css("width", '80%');
$("#big-img").css('height', '60%');
rh = sh / sw * (tWidth * 0.8);
}
if (rh < tHeight - 100) {
$("#big-img").css('margin-top', (tHeight - rh) / 2 + 'px');
} else {
$("#big-img").css('margin-top', '6px');
}
$("#img-div").show();
});
$("#img-div").click(function () {
$("#img-div").hide();
});
});
function sc(id) {
layer.confirm("确定要删除吗？", { title: "确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id, lx: 'wxlistsc'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading'); 
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
});
}
function yjsc() {
layer.confirm("确定要一键删除数据吗？", { title: "确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {lx: 'yjscwxlist'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
});
}
</script>
</body>
</html>