2023-01-29 10:26:52 +08:00

99 lines
2.9 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{extend name="public/base" /}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>通知公告</h2>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="60%">标题</th>
<th width="30%">添加时间</th>
</tr>
</thead>
<tbody>
{if condition="empty($list)"}
<tr>
<td colspan="3" align="center">暂无数据!</td>
</tr>
{else/}
{volist name="list" id="item"}
<tr>
<td><a href="{:url('agent/articleview',array('id'=>$item.id))}" data-toggle="view-notice" data-id="{$item.id}" data-created-at="{$item.create_time}" class="notice-title">{$item.title}</a></td>
<td >{$item.create_time|date='Y-m-d H:i',###}</td>
</tr>
{/volist}
{/if}
</tbody>
</table>
</div>
{$page}
</div>
</div>
</div>
<div class="modal" id="mymodal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">{$new.title}</h4>
</div>
<div class="modal-body">
<p>{$new.content}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
{/block}
{block name="script"}
<script>
$(function () {
var isAdmin = {$is_administrator==true?"true":"false"};
// 检查是否已读过最新通知
var lastReadNoticeCookieKey = 'last_read_notice_id_{$new.id}';
var lastReadNoticeId = Cookies.get(lastReadNoticeCookieKey) || 0;
//var id = collectUnreadNoticeIds(lastReadNoticeId);
var id = {$new.id};
if (!isAdmin && id > lastReadNoticeId) {
$("#mymodal").modal("toggle");
Cookies.set(lastReadNoticeCookieKey, id, { expires: 10 * 365 * 24 * 60 * 60 });
}
function collectUnreadNoticeIds(lastReadNoticeId) {
var noticeIds = [];
$('[data-toggle="view-notice"]').each(function () {
var noticeId = parseInt($(this).data('id'), 10);
var createdAt = parseInt($(this).data('created-at'));
var now = Math.round(new Date().getTime() / 1000);
var within10days = (now - createdAt) < 1 * 24 * 60 * 60;
// 对于用户未读且在10天内新发布的通知将强制显示给用户
if (noticeId > lastReadNoticeId && within10days) {
noticeIds.push(noticeId);
}
});
return noticeIds;
}
})
</script>
{/block}