彩先知pc
This commit is contained in:
@@ -0,0 +1,230 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title id="page-title">彩先知 - 网站公告</title>
|
||||
<script src="../public/css/layui/layui.js"></script>
|
||||
<script src="../config.js"></script>
|
||||
<script src="../utils/ApiClient.js"></script>
|
||||
<script src="../utils/DateUtil.js"></script>
|
||||
<script src="../utils/CommonUtil.js"></script>
|
||||
<link rel="stylesheet" href="../public/css/layui/css/layui.css" />
|
||||
<link rel="stylesheet" href="../public/css/public.css" />
|
||||
<link rel="stylesheet" href="../public/css/gonggao.css" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<nav class="topbar" id="navbar">
|
||||
<div class="topbar__inner">
|
||||
<a href="index.html" class="topbar__brand">
|
||||
<img
|
||||
src="../images/home-logo.png"
|
||||
alt="彩先知"
|
||||
class="topbar__logo"
|
||||
/>
|
||||
</a>
|
||||
<div class="topbar__nav" id="navLotteryItems">
|
||||
<!-- <a href="index.html" class="topbar__nav-link">首页</a> -->
|
||||
</div>
|
||||
<div class="topbar__user">
|
||||
<div id="notLoggedInBox" class="topbar__guest">
|
||||
<a href="login.html" class="topbar__btn topbar__btn--ghost">登录</a>
|
||||
<a href="reg.html" class="topbar__btn topbar__btn--primary"
|
||||
>免费注册</a
|
||||
>
|
||||
</div>
|
||||
<div id="loggedInBox" class="topbar__logged" style="display: none">
|
||||
<a href="usercenter.html" class="topbar__profile">
|
||||
<img
|
||||
id="userAvatar"
|
||||
src="../public/img/userimg.png"
|
||||
alt=""
|
||||
class="topbar__avatar"
|
||||
/>
|
||||
<div class="topbar__meta">
|
||||
<span id="userName" class="topbar__uname">用户</span>
|
||||
<span id="userLevel" class="topbar__ubadge">会员</span>
|
||||
</div>
|
||||
</a>
|
||||
<button class="topbar__btn topbar__btn--logout" onclick="logout()">
|
||||
退出登录
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main -->
|
||||
<main class="cxz-main">
|
||||
<div class="cxz-breadcrumb">
|
||||
<a href="index.html">首页</a><span class="sep">></span>
|
||||
<span>网站公告</span>
|
||||
</div>
|
||||
|
||||
<div class="cxz-section-header">
|
||||
<div class="cxz-section-title">网站公告</div>
|
||||
</div>
|
||||
|
||||
<div class="cxz-notice-list" id="noticeList">
|
||||
<div class="cxz-notice-item">
|
||||
<span style="color: var(--text-muted)">加载中...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cxz-pagination" id="pagination"></div>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="site-footer">
|
||||
<div class="site-footer__inner">
|
||||
<img
|
||||
src="../images/home-logo.png"
|
||||
alt="彩先知"
|
||||
class="site-footer__logo"
|
||||
/>
|
||||
<p id="copyright-info">彩先知以开奖数据、免费文章、资讯推荐为核心</p>
|
||||
<div class="site-footer__meta">
|
||||
<a
|
||||
id="beian"
|
||||
href="https://beian.miit.gov.cn/"
|
||||
target="_blank"
|
||||
style="font-size: 12px; color: rgba(255, 255, 255, 0.5)"
|
||||
>工信部备案号</a
|
||||
>
|
||||
<span id="additional-info">本站仅供数据分析参考</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<button
|
||||
class="gotop"
|
||||
id="backTop"
|
||||
type="button"
|
||||
onclick="window.scrollTo({ top: 0, behavior: 'smooth' })"
|
||||
>
|
||||
↑
|
||||
</button>
|
||||
|
||||
<script>
|
||||
const $ = layui.$;
|
||||
let currentPage = 1;
|
||||
const pageSize = 20;
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem("token");
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function checkLogin() {
|
||||
const token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
$("#notLoggedInBox").hide();
|
||||
$("#loggedInBox").css("display", "flex");
|
||||
CommonUtil.getCurrentUserDetail(
|
||||
function (data) {
|
||||
$("#userName").text(data.nickName || "用户");
|
||||
$("#userLevel").text(data.isExpert === "1" ? "专家" : "会员");
|
||||
if (data.avatar) $("#userAvatar").attr("src", data.avatar);
|
||||
},
|
||||
function () {
|
||||
$("#notLoggedInBox").show();
|
||||
$("#loggedInBox").hide();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function renderNav() {
|
||||
ApiClient.post("/api/web/menu/getFormatList", {}).then(function (res) {
|
||||
if (res.code !== 0 || !res.data) return;
|
||||
var $nav = $("#navLotteryItems");
|
||||
$nav.find(".topbar__nav-link").not(":first").remove();
|
||||
$.each(res.data, function (i, item) {
|
||||
$nav.append(
|
||||
'<a href="cai.html?id=' +
|
||||
item.suoxie +
|
||||
'" class="topbar__nav-link">' +
|
||||
item.name +
|
||||
"</a>",
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on("scroll", function () {
|
||||
$(window).scrollTop() > 320
|
||||
? $("#backTop").addClass("is-visible")
|
||||
: $("#backTop").removeClass("is-visible");
|
||||
});
|
||||
|
||||
// Load notice list
|
||||
function loadNotices() {
|
||||
ApiClient.post("/api/web/notice/getPageList", {
|
||||
pageNum: currentPage,
|
||||
pageSize: pageSize,
|
||||
}).then(function (res) {
|
||||
if (res.code === 0 && res.data) {
|
||||
renderNotices(res.data.records || []);
|
||||
renderPagination(res.data.totalRow || 0);
|
||||
} else {
|
||||
$("#noticeList").html(
|
||||
'<div class="cxz-notice-item"><span style="color:var(--text-muted);">暂无公告</span></div>',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderNotices(list) {
|
||||
const $container = $("#noticeList");
|
||||
$container.empty();
|
||||
if (!list || list.length === 0) {
|
||||
$container.html(
|
||||
'<div class="cxz-notice-item"><span style="color:var(--text-muted);">暂无公告</span></div>',
|
||||
);
|
||||
return;
|
||||
}
|
||||
$.each(list, function (i, item) {
|
||||
let displayDate = "";
|
||||
if (item.createTime) displayDate = item.createTime.substring(0, 10);
|
||||
else if (item.date) displayDate = item.date.substring(0, 10);
|
||||
|
||||
$container.append(
|
||||
'<div class="cxz-notice-item">' +
|
||||
'<a href="gonggao.html?id=' +
|
||||
(item.id || "") +
|
||||
'">' +
|
||||
'<span class="cxz-notice-dot"></span>' +
|
||||
(item.noticeTitle || "无标题") +
|
||||
"</a>" +
|
||||
'<span class="cxz-notice-date">' +
|
||||
displayDate +
|
||||
"</span>" +
|
||||
"</div>",
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function renderPagination(total) {
|
||||
layui.laypage.render({
|
||||
elem: "pagination",
|
||||
count: total,
|
||||
limit: pageSize,
|
||||
curr: currentPage,
|
||||
jump: function (obj, first) {
|
||||
if (!first) {
|
||||
currentPage = obj.curr;
|
||||
loadNotices();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
checkLogin();
|
||||
loadNotices();
|
||||
CommonUtil.loadPageConfig();
|
||||
renderNav();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user