彩先知pc
This commit is contained in:
@@ -0,0 +1,389 @@
|
||||
<!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/kaijiang.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 id="breadcrumbLottery">开奖公告</span>
|
||||
</div>
|
||||
|
||||
<!-- Lottery Tabs -->
|
||||
<div class="cxz-lottery-tabs" id="lotteryTabs"></div>
|
||||
|
||||
<!-- Latest Result Card -->
|
||||
<div class="cxz-latest-card" id="latestCard" style="display: none">
|
||||
<div class="cxz-latest-header">
|
||||
<div>
|
||||
<div class="cxz-latest-label">最新开奖</div>
|
||||
<div class="cxz-latest-period" id="latestPeriod">--</div>
|
||||
</div>
|
||||
<div class="cxz-latest-date" id="latestDate">--</div>
|
||||
</div>
|
||||
<div class="cxz-latest-balls" id="latestBalls"></div>
|
||||
</div>
|
||||
|
||||
<!-- Results Table -->
|
||||
<div class="cxz-section-header">
|
||||
<div class="cxz-section-title" id="tableTitle">历史开奖</div>
|
||||
</div>
|
||||
<div class="cxz-table-box">
|
||||
<table class="cxz-data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>期号</th>
|
||||
<th>开奖日期</th>
|
||||
<th>开奖号码</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="resultBody">
|
||||
<tr>
|
||||
<td
|
||||
colspan="3"
|
||||
style="
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
padding: 40px;
|
||||
"
|
||||
>
|
||||
加载中...
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</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.$;
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let currentSuoxie = urlParams.get("suoxie") || urlParams.get("code") || "";
|
||||
let currentMenuId = urlParams.get("id") || "";
|
||||
let lotteryMenus = [];
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem("token");
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function checkLogin() {
|
||||
var 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 escapeHtml(str) {
|
||||
if (!str) return "";
|
||||
return String(str)
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function normalizeLotteryMenus(list) {
|
||||
return ApiClient.asArray(list).filter(function (item) {
|
||||
return item && (!item.type || item.type === "lottery");
|
||||
});
|
||||
}
|
||||
|
||||
function menuCode(item) {
|
||||
return item && (item.suoxie || item.code || "");
|
||||
}
|
||||
|
||||
function currentMenu() {
|
||||
return (
|
||||
lotteryMenus.find(function (item) {
|
||||
return String(item.id) === String(currentMenuId);
|
||||
}) ||
|
||||
lotteryMenus.find(function (item) {
|
||||
return menuCode(item) && String(menuCode(item)) === String(currentSuoxie);
|
||||
}) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
function resolveCurrentMenu() {
|
||||
if (!lotteryMenus.length) return null;
|
||||
let selected = currentMenu();
|
||||
if (!selected) selected = lotteryMenus[0];
|
||||
currentMenuId = String(selected.id || "");
|
||||
currentSuoxie = menuCode(selected);
|
||||
return selected;
|
||||
}
|
||||
|
||||
function renderNavFromMenus() {
|
||||
var $nav = $("#navLotteryItems");
|
||||
$nav.empty();
|
||||
$.each(lotteryMenus, function (_, item) {
|
||||
var code = menuCode(item);
|
||||
$nav.append(
|
||||
'<a href="cai.html?id=' +
|
||||
encodeURIComponent(code || item.id || "") +
|
||||
'" class="topbar__nav-link">' +
|
||||
escapeHtml(item.name || "") +
|
||||
"</a>",
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function renderLotteryTabs() {
|
||||
return ApiClient.get(ApiClient.API.homeNav)
|
||||
.then(function (res) {
|
||||
lotteryMenus = normalizeLotteryMenus(ApiClient.pickData(res, []));
|
||||
resolveCurrentMenu();
|
||||
renderNavFromMenus();
|
||||
var $tabs = $("#lotteryTabs");
|
||||
$tabs.empty();
|
||||
$.each(lotteryMenus, function (_, item) {
|
||||
var code = menuCode(item);
|
||||
$tabs.append(
|
||||
'<a href="kaijiang.html?suoxie=' +
|
||||
encodeURIComponent(code || "") +
|
||||
'" class="cxz-lottery-tab" data-code="' +
|
||||
escapeHtml(code) +
|
||||
'" data-id="' +
|
||||
escapeHtml(item.id || "") +
|
||||
'">' +
|
||||
escapeHtml(item.name || "") +
|
||||
"</a>",
|
||||
);
|
||||
});
|
||||
highlightTab();
|
||||
})
|
||||
.catch(function () {
|
||||
lotteryMenus = [];
|
||||
$("#navLotteryItems").empty();
|
||||
$("#lotteryTabs").empty();
|
||||
$("#breadcrumbLottery").text("开奖公告");
|
||||
$("#tableTitle").text("历史开奖");
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on("scroll", function () {
|
||||
$(window).scrollTop() > 320
|
||||
? $("#backTop").addClass("is-visible")
|
||||
: $("#backTop").removeClass("is-visible");
|
||||
});
|
||||
|
||||
// Highlight tab
|
||||
function highlightTab() {
|
||||
const selected = resolveCurrentMenu();
|
||||
$(".cxz-lottery-tab").removeClass("active");
|
||||
$('.cxz-lottery-tab[data-id="' + currentMenuId + '"]').addClass("active");
|
||||
const name = (selected && selected.name) || "开奖公告";
|
||||
$("#breadcrumbLottery").text(name + " - 开奖公告");
|
||||
$("#tableTitle").text(name + " 历史开奖");
|
||||
document.title = "彩先知 - " + name + "开奖公告";
|
||||
}
|
||||
|
||||
// Load results
|
||||
function loadResults() {
|
||||
if (!currentMenuId) {
|
||||
$("#resultBody").html(
|
||||
'<tr><td colspan="3" style="text-align:center;color:var(--text-muted);padding:40px;">暂无数据</td></tr>',
|
||||
);
|
||||
return;
|
||||
}
|
||||
ApiClient.get("/api/web/lottery/result/list", {
|
||||
menuId: currentMenuId,
|
||||
pageNum: 1,
|
||||
pageSize: 50,
|
||||
}).then(function (res) {
|
||||
if (ApiClient.isSuccess(res) && ApiClient.pickData(res, null)) {
|
||||
const data = ApiClient.pickData(res, {}) || {};
|
||||
const list = data.records || data.rows || data.list || ApiClient.asArray(data);
|
||||
renderResults(list);
|
||||
} else {
|
||||
$("#resultBody").html(
|
||||
'<tr><td colspan="3" style="text-align:center;color:var(--text-muted);padding:40px;">暂无数据</td></tr>',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderResults(list) {
|
||||
const $body = $("#resultBody");
|
||||
$body.empty();
|
||||
if (!list || list.length === 0) {
|
||||
$body.html(
|
||||
'<tr><td colspan="3" style="text-align:center;color:var(--text-muted);padding:40px;">暂无数据</td></tr>',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Latest result card
|
||||
if (list.length > 0) {
|
||||
const latest = list[0];
|
||||
$("#latestCard").show();
|
||||
$("#latestPeriod").text(
|
||||
(latest.name || "") + " 第" + (latest.expect || "") + "期",
|
||||
);
|
||||
$("#latestDate").text(
|
||||
latest.date ||
|
||||
(latest.createTime ? latest.createTime.substring(0, 10) : ""),
|
||||
);
|
||||
$("#latestBalls").html(parseOpenCode(latest.openCode, true));
|
||||
}
|
||||
|
||||
$.each(list, function (i, item) {
|
||||
const ballsHtml = parseOpenCode(item.openCode, false);
|
||||
const date =
|
||||
item.date ||
|
||||
(item.createTime ? item.createTime.substring(0, 10) : "--");
|
||||
$body.append(
|
||||
"<tr>" +
|
||||
"<td>" +
|
||||
(item.expect || "") +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
date +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
ballsHtml +
|
||||
"</td>" +
|
||||
"</tr>",
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Parse openCode format "01,02,03+07" to display red/blue balls.
|
||||
// Red/blue splitting follows the API data itself: numbers after "+" are blue.
|
||||
function parseOpenCode(openCode, isLarge) {
|
||||
if (!openCode)
|
||||
return '<span style="color:var(--text-muted);">--</span>';
|
||||
|
||||
const parts = String(openCode).split("+");
|
||||
const reds = splitCodes(parts[0]);
|
||||
let blues = [];
|
||||
for (let p = 1; p < parts.length; p++) {
|
||||
blues = blues.concat(splitCodes(parts[p]));
|
||||
}
|
||||
|
||||
let html = "";
|
||||
const sizeStyle = isLarge
|
||||
? ' style="width:40px;height:40px;font-size:16px;"'
|
||||
: "";
|
||||
$.each(reds, function (i, num) {
|
||||
html += '<span class="red-q"' + sizeStyle + ">" + escapeHtml(num) + "</span>";
|
||||
});
|
||||
$.each(blues, function (i, num) {
|
||||
html += '<span class="bule-q"' + sizeStyle + ">" + escapeHtml(num) + "</span>";
|
||||
});
|
||||
return html || '<span style="color:var(--text-muted);">--</span>';
|
||||
}
|
||||
|
||||
function splitCodes(value) {
|
||||
return String(value || "")
|
||||
.split(/[,,\s]+/)
|
||||
.map(function (s) {
|
||||
return s.trim();
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
checkLogin();
|
||||
renderLotteryTabs().then(loadResults);
|
||||
CommonUtil.loadPageConfig();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user