<%@page trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="gen" uri="http://help.jspgen.com/taglib/jstl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1" />
<title>微信公众号</title>
<!-- 当前页面 -->
<link type="text/css" href="${config.statie}ui/admin/images/admin.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
  <div class="push">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr appid="${wechat.appid}">
        <td align="left"><a href="javascript:void(0);" class="button tiny gray blue-hover fanslist"><i></i>粉丝列表</a>
        <a href="javascript:void(0);" class="button tiny blue blue-hover templist"><i></i>模板列表</a>
        <a href="javascript:void(0);" class="button tiny gray blue-hover sendlist"><i></i>群发信息</a></td>
        <td align="right"><a href="javascript:void(0);" class="button tiny orange synch"><i></i>同步公众号模板</a></td>
      </tr>
    </table>
  </div>
  <div class="area">
    <h2>
      <i>${wechat.name} 模板列表<a href="javascript:void(0);" style="color:#5F5F5F;cursor:default;">最后同步时间：${gen:dateTime(wechat.templast, 'yyyy-MM-dd HH:mm:ss', config.timezoneid)}</a></i>
    </h2>
    <div class="area-content">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
        <tr>
          <th width="30%">模板Id</th>
          <th width="25%" class="border-left">标题</th>
          <th width="20%" class="border-left">所属行业</th>
          <th width="15%" class="border-left">时间</th>
          <th width="10%" class="border-left">操作</th>
        </tr>
        <gen:if test="${not empty pager.results}">
        <c:forEach items="${pager.results}" var="map">
        <tr class="border-top" id="${map.id}" appid="${map.appid}" tempid="${map.tempid}">
          <td align="center">${map.tempid}</td>
          <td class="border-left">&nbsp;${map.title}</td>
          <td align="center" class="border-left">${map.prima}<!--${map.deput}--></td>
          <td align="center" class="border-left">${gen:dateTime(map.time, 'yyyy-MM-dd HH:mm:ss', config.timezoneid)}</td>
          <td align="center" class="border-left"><a href="javascript:void(0);" class="send" title="模板群发">模板群发</a></td>
        </tr>
        </c:forEach>
        <gen:else />
        <tr class="border-top">
        	<td colspan="7" align="center" class="ignore">暂无数据</td>
        </tr>
        </gen:if>
        <tr class="border-top">
          <th colspan="7"><div class="th-left"></div>
            <div class="pages th-right">${pager.pageBar}</div></th>
        </tr>
      </table>
    </div>
  </div>
  <div class="area">
    <h2><i>查询</i></h2>
    <div class="area-content">
      <form name="search" id="search" method="POST" action="?">
      	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
          <tr>
            <td width="30%" align="right">关键字：</td>
            <td><input type="hidden" name="find" value="title,tempid" /><input type="text" name="keyword" class="text small" title="关键字" value="${param.keyword}" placeholder="请输入标题或模板Id" size="50"/>&nbsp;&nbsp;
            <input type="hidden" name="appid" value="${wechat.appid}" /><input name="submit" class="button blue small" type="submit" value="确 定" /></td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</div>
<!-- 必备插件 -->
<script type="text/javascript" src="${config.statie}js/jquery.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.form.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.grapes.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.timers.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.tablecolor.js"></script>
<!-- 弹窗插件 -->
<script type="text/javascript" src="${config.statie}js/dialog/jquery.dialog.js?self=true"></script>
<script type="text/javascript" src="${config.statie}js/dialog/jquery.dialog.plugins.js"></script>
<!-- UI界面必备 -->
<script type="text/javascript" src="${config.statie}ui/js/jspgen.js"></script>
<script type="text/javascript" src="${config.statie}ui/js/jspgen.ajax.js"></script>
<script type="text/javascript" src="${config.statie}ui/js/jspgen.ready.js"></script>
<!-- 当前页面 -->

<script type="text/javascript">
// document.domain = "jspgen.com";// 调用
$(document).ready(function(){
	// 变量
	var $aclick = true; // 禁用点击事件标识，为同步数据服务
	var $fanslist = $('.push a.fanslist'), $templist = $('.push a.templist'), $sendlist = $('.push a.sendlist'), $synch = $('.push a.synch');
	// 粉丝列表
	$fanslist.bind('click', function () {
		if(!$aclick) return ;
		var $tr = $(this).closest('tr');
		var id = $tr.attr('id'), appid = $tr.attr('appid');
		window.location.href = 'wechat_fans!list.gen?appid='+appid;
	});
	// 模板列表
	$templist.bind('click', function () {
		if(!$aclick) return ;
		var $tr = $(this).closest('tr');
		var id = $tr.attr('id'), appid = $tr.attr('appid');
		window.location.href = 'wechat_temp!list.gen?appid='+appid;
	});
	// 群发情况
	$sendlist.bind('click', function () {
		if(!$aclick) return ;
		var $tr = $(this).closest('tr');
		var id = $tr.attr('id'), appid = $tr.attr('appid');
		window.location.href = 'wechat_send!list.gen?appid='+appid;
		
	});
	// 数据同步
	$synch.bind('click', function () {
		if(!$aclick) return ; $aclick = false;
		$synch.removeClass('orange').addClass('disabled');
		var appid = $(this).closest('tr').attr('appid');
		$.ajax({
			url: 'wechat_temp!synch.gen', data: {appid: appid},
			success: function(result) {
				// {'status':false, 'message':'message'}
				if (result) {
					// $aclick = true;
					if (result.status) {
						$dialog.success(result.message, function(){reflesh();});
					}else{
						$dialog.error(result.message);
					}
				}
			}
		});
	});
	
	// 群发消息
	var $send = $('.table a.send');
	$send.bind('click', function () {
		if(!$aclick) return ;
		var $tr = $(this).closest('tr');
		var id = $tr.attr('id'), appid = $tr.attr('appid'), tempid = $tr.attr('tempid');
		return addTab($(this).attr('title'), 'wechat_send!add.gen?tempid='+tempid, 'wechat_send_add_'+id);
	});
});
</script>
</body>
</html>