彩先知pc
This commit is contained in:
+929
@@ -0,0 +1,929 @@
|
||||
<!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>
|
||||
<link rel="stylesheet" href="../public/css/layui/css/layui.css" />
|
||||
<link rel="stylesheet" href="../public/css/public.css" />
|
||||
<link rel="stylesheet" href="../public/css/index.css" />
|
||||
<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>
|
||||
<script src="../public/js/qrcode.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="topbar" id="navbar">
|
||||
<div class="topbar__inner">
|
||||
<a href="./" 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 is-active">首页</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 class="page-shell">
|
||||
<section class="hero">
|
||||
<div class="hero__inner">
|
||||
<div class="hero__main">
|
||||
<!-- <div class="panel-head panel-head--hero">
|
||||
<div>
|
||||
<h1>彩先知 PC 预测首页</h1>
|
||||
</div>
|
||||
<button
|
||||
class="hero__history-btn"
|
||||
type="button"
|
||||
onclick="openHistoryModal()"
|
||||
>
|
||||
<img src="../images/home-icon-history.png" alt="" />
|
||||
<span>历史查询</span>
|
||||
</button>
|
||||
</div> -->
|
||||
<div class="hero__carousel-wrap">
|
||||
<div class="layui-carousel" id="bannerCarousel">
|
||||
<div carousel-item id="bannerBox"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="hero__side">
|
||||
<div class="hero-card hero-card--focus">
|
||||
<div class="hero-card__title">
|
||||
<img src="../images/home-icon-calendar.png" alt="" />
|
||||
<span>开奖焦点</span>
|
||||
</div>
|
||||
<div class="hero-focus-list" id="heroFocusList"></div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="section-divider section-divider--blue">
|
||||
<span>彩票分类导航</span>
|
||||
<!-- <p>八大彩种统一入口,快速进入对应文章与数据页</p> -->
|
||||
</div>
|
||||
|
||||
<section class="lottery-nav">
|
||||
<div class="lottery-nav__inner" id="lotteryNavGrid"></div>
|
||||
</section>
|
||||
|
||||
<div class="section-divider section-divider--gold">
|
||||
<span>最新开奖与免费文章</span>
|
||||
<!-- <p>开奖结果、开奖日期、专家推荐文章同步聚合展示</p> -->
|
||||
</div>
|
||||
|
||||
<section class="draw">
|
||||
<div class="draw__inner">
|
||||
<div class="draw__header">
|
||||
<div class="draw__title">
|
||||
<img src="../images/home-icon-history.png" alt="" />
|
||||
<div>
|
||||
<strong>最新开奖</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="draw__grid" id="resultsGrid"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<div class="content__inner">
|
||||
<aside class="content__rail">
|
||||
<div class="sidebar-card">
|
||||
<div class="sidebar-card__head sidebar-card__head--navy">
|
||||
<span>平台公告</span>
|
||||
<a href="gonggaolist.html" class="sidebar-card__more">更多</a>
|
||||
</div>
|
||||
<ul class="notice-list" id="noticeList"></ul>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-card">
|
||||
<div class="sidebar-card__head sidebar-card__head--gold">
|
||||
<span>APP下载</span>
|
||||
</div>
|
||||
<div class="qrcode-box">
|
||||
<img id="downloadQrImg" alt="二维码" />
|
||||
<p>打开手机浏览器扫描二维码</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-card">
|
||||
<div class="sidebar-card__head sidebar-card__head--teal">
|
||||
<span>走势图</span>
|
||||
</div>
|
||||
<div class="trend-grid" id="trendGrid"></div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-card combo-tool-card">
|
||||
<div class="sidebar-card__head sidebar-card__head--gold">
|
||||
<span>组合工具</span>
|
||||
</div>
|
||||
<div class="combo-tool-grid">
|
||||
<a href="duanzuhe.html" class="combo-tool-item">
|
||||
<img src="../images/icon-duanzuhe.png" alt="断组合" />
|
||||
<span>断组合</span>
|
||||
</a>
|
||||
<a href="shazuhe.html" class="combo-tool-item">
|
||||
<img src="../images/icon-shazuhe.png" alt="杀组合" />
|
||||
<span>杀组合</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="content__main">
|
||||
<div class="article-matrix" id="articleGroups"></div>
|
||||
</section>
|
||||
|
||||
<aside class="content__ads">
|
||||
<div id="sidebarAdContainer"></div>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="resource-section">
|
||||
<div class="resource-section__inner">
|
||||
<div class="resource-card">
|
||||
<div class="resource-card__head">
|
||||
<img src="../images/home-icon-article.png" alt="" />
|
||||
<h2>其它推荐</h2>
|
||||
</div>
|
||||
<div class="resource-card__body" id="otherRecommend"></div>
|
||||
</div>
|
||||
|
||||
<div class="resource-card">
|
||||
<div class="resource-card__head">
|
||||
<img src="../images/home-icon-link.png" alt="" />
|
||||
<h2>友情链接</h2>
|
||||
</div>
|
||||
<div class="resource-card__body" id="friendLinks"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="site-footer">
|
||||
<div class="site-footer__inner">
|
||||
<img
|
||||
src="../images/home-logo.png"
|
||||
alt="彩先知"
|
||||
class="site-footer__logo"
|
||||
/>
|
||||
<p id="copyright-info">
|
||||
彩先知以开奖数据、免费文章、资讯推荐为核心,提供清晰、密集、分层的 PC
|
||||
端彩票信息首页。
|
||||
</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,.5)">工信部:蜀ICP备2024044594号-4</a>
|
||||
<span id="additional-info">本站仅供数据分析参考,不构成任何投注建议</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="gotop"
|
||||
id="backTop"
|
||||
type="button"
|
||||
onclick="window.scrollTo({ top: 0, behavior: 'smooth' })"
|
||||
>
|
||||
↑
|
||||
</button>
|
||||
|
||||
<script>
|
||||
var $ = layui.$;
|
||||
var token = localStorage.getItem("token");
|
||||
var lotteryOrder = [
|
||||
"双色球",
|
||||
"大乐透",
|
||||
"福彩3D",
|
||||
"排列三",
|
||||
"排列五",
|
||||
"快乐8",
|
||||
"七乐彩",
|
||||
"七星彩",
|
||||
];
|
||||
var currentLotteryMenu = [];
|
||||
var lotteryAliasMap = {
|
||||
排列3: "排列三",
|
||||
排列三: "排列三",
|
||||
排列5: "排列五",
|
||||
排列五: "排列五",
|
||||
};
|
||||
var lotteryIconMap = {
|
||||
双色球: {
|
||||
icon: "../images/icon-ssq.png",
|
||||
color: "red",
|
||||
blueColor: "blue",
|
||||
code: "ssq",
|
||||
accent: "#ff5d6c",
|
||||
},
|
||||
大乐透: {
|
||||
icon: "../images/icon-dlt.png",
|
||||
color: "blue",
|
||||
blueColor: "gold",
|
||||
code: "cjdlt",
|
||||
accent: "#4f8cff",
|
||||
},
|
||||
福彩3D: {
|
||||
icon: "../images/icon-fc3d.png",
|
||||
color: "orange",
|
||||
blueColor: "orange",
|
||||
code: "fc3d",
|
||||
accent: "#ff9a3d",
|
||||
},
|
||||
排列三: {
|
||||
icon: "../images/icon-pl3.png",
|
||||
color: "green",
|
||||
blueColor: "green",
|
||||
code: "pl3",
|
||||
accent: "#37c28f",
|
||||
},
|
||||
排列五: {
|
||||
icon: "../images/icon-pl5.png",
|
||||
color: "purple",
|
||||
blueColor: "purple",
|
||||
code: "pl5",
|
||||
accent: "#8d62ff",
|
||||
},
|
||||
快乐8: {
|
||||
icon: "../images/icon-kl8.png",
|
||||
color: "gold",
|
||||
blueColor: "gold",
|
||||
code: "kl8",
|
||||
accent: "#fdb933",
|
||||
},
|
||||
七乐彩: {
|
||||
icon: "../images/icon-qlc.png",
|
||||
color: "teal",
|
||||
blueColor: "blue",
|
||||
code: "qlc",
|
||||
accent: "#29b6b0",
|
||||
},
|
||||
七星彩: {
|
||||
icon: "../images/icon-qxc.png",
|
||||
color: "violet",
|
||||
blueColor: "violet",
|
||||
code: "qxc",
|
||||
accent: "#b06dff",
|
||||
},
|
||||
};
|
||||
var fallbackAvatars = [
|
||||
"../images/home-avatar-1.png",
|
||||
"../images/home-avatar-2.png",
|
||||
"../images/home-avatar-3.png",
|
||||
"../images/home-avatar-4.png",
|
||||
"../images/home-avatar-5.png",
|
||||
"../images/home-avatar-6.png",
|
||||
"../images/home-avatar-7.png",
|
||||
"../images/home-avatar-8.png",
|
||||
];
|
||||
var historyCache = {};
|
||||
|
||||
function normalizeLotteryName(name) {
|
||||
return lotteryAliasMap[name] || name || "";
|
||||
}
|
||||
function escapeHtml(text) {
|
||||
return String(text || "").replace(/[&<>"']/g, function (char) {
|
||||
return {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
}[char];
|
||||
});
|
||||
}
|
||||
function formatDateValue(value) {
|
||||
if (!value) return "--";
|
||||
var date = new Date(value);
|
||||
if (isNaN(date.getTime()))
|
||||
return typeof value === "string" && value.length >= 10
|
||||
? value.substring(0, 10)
|
||||
: String(value);
|
||||
var year = date.getFullYear();
|
||||
var month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
var day = String(date.getDate()).padStart(2, "0");
|
||||
return year + "-" + month + "-" + day;
|
||||
}
|
||||
function formatDateLabel(value) {
|
||||
var date = new Date(value);
|
||||
if (isNaN(date.getTime())) return formatDateValue(value);
|
||||
return (
|
||||
date.getFullYear() +
|
||||
"年" +
|
||||
(date.getMonth() + 1) +
|
||||
"月" +
|
||||
date.getDate() +
|
||||
"日"
|
||||
);
|
||||
}
|
||||
function sortLotteries(menuList) {
|
||||
return (menuList || [])
|
||||
.slice()
|
||||
.map(function (item) {
|
||||
var copy = $.extend(true, {}, item);
|
||||
copy.name = normalizeLotteryName(copy.name);
|
||||
return copy;
|
||||
});
|
||||
}
|
||||
function getResultDate(item) {
|
||||
return item && item.lotteryResult
|
||||
? item.lotteryResult.time ||
|
||||
item.lotteryResult.createTime ||
|
||||
item.lotteryResult.date ||
|
||||
""
|
||||
: "";
|
||||
}
|
||||
function getResultPeriod(item) {
|
||||
return item && item.lotteryResult
|
||||
? item.lotteryResult.expect || item.lotteryResult.name || ""
|
||||
: "";
|
||||
}
|
||||
function buildBallHtml(openCode, cfg, compact) {
|
||||
if (!openCode) return '<span class="ball ball--empty">--</span>';
|
||||
var html = "";
|
||||
var parts = String(openCode).split("+");
|
||||
$.each(parts[0] ? parts[0].split(",") : [], function (_, ball) {
|
||||
html +=
|
||||
'<span class="ball ball--' +
|
||||
cfg.color +
|
||||
(compact ? " ball--compact" : "") +
|
||||
'">' +
|
||||
escapeHtml($.trim(ball)) +
|
||||
"</span>";
|
||||
});
|
||||
for (var i = 1; i < parts.length; i++) {
|
||||
$.each(parts[i].split(","), function (_, ball) {
|
||||
html +=
|
||||
'<span class="ball ball--' +
|
||||
cfg.blueColor +
|
||||
(compact ? " ball--compact" : "") +
|
||||
'">' +
|
||||
escapeHtml($.trim(ball)) +
|
||||
"</span>";
|
||||
});
|
||||
}
|
||||
return html || '<span class="ball ball--empty">--</span>';
|
||||
}
|
||||
function renderBannerImages(bannerData) {
|
||||
var $box = $("#bannerBox");
|
||||
$box.empty();
|
||||
if (!bannerData || !bannerData.length) {
|
||||
$box.append(
|
||||
'<div class="banner-fallback"><div class="banner-fallback__content"><span>暂无轮播数据</span><strong>彩先知 · 专注开奖与文章聚合</strong></div></div>',
|
||||
);
|
||||
} else {
|
||||
$.each(bannerData, function (_, item) {
|
||||
$box.append(
|
||||
'<div><a href="' +
|
||||
escapeHtml(item.link || "#") +
|
||||
'" target="_blank" rel="noopener noreferrer" class="banner-link"><img class="carousel-img" src="' +
|
||||
escapeHtml(item.touxiang || "") +
|
||||
'" alt="轮播图" loading="lazy" /></a></div>',
|
||||
);
|
||||
});
|
||||
}
|
||||
layui.use(["carousel"], function () {
|
||||
layui.carousel.render({
|
||||
elem: "#bannerCarousel",
|
||||
interval: 5000,
|
||||
anim: "fade",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
autoplay: true,
|
||||
indicator: "inside",
|
||||
});
|
||||
});
|
||||
}
|
||||
function renderHeroSummary(menuList, noticeList) {
|
||||
var articleCount = 0;
|
||||
$.each(menuList, function (_, item) {
|
||||
articleCount += (item.freeArticleList || []).slice(0, 5).length;
|
||||
});
|
||||
$("#heroLotteryCount").text(menuList.length);
|
||||
$("#heroArticleCount").text(articleCount);
|
||||
$("#heroNoticeCount").text((noticeList || []).length);
|
||||
$("#heroMetaGrid").html(
|
||||
[
|
||||
'<div class="hero-meta"><span>彩种排序</span><strong>8 组固定顺序</strong><em>双色球至七星彩</em></div>',
|
||||
'<div class="hero-meta"><span>免费文章</span><strong>' +
|
||||
articleCount +
|
||||
" 篇</strong><em>每组展示 5 篇以内</em></div>",
|
||||
'<div class="hero-meta"><span>数据来源</span><strong>/api/web/index</strong><em>首页主数据接口</em></div>',
|
||||
].join(""),
|
||||
);
|
||||
var $focus = $("#heroFocusList");
|
||||
$focus.empty();
|
||||
$.each(menuList.slice(0, 4), function (_, item) {
|
||||
var name = item.name || "";
|
||||
var cfg = lotteryIconMap[name] || lotteryIconMap["双色球"];
|
||||
$focus.append(
|
||||
'<a href="kaijiang.html?suoxie=' +
|
||||
cfg.code +
|
||||
'" class="hero-focus-item"><img src="' +
|
||||
cfg.icon +
|
||||
'" alt="' +
|
||||
escapeHtml(name) +
|
||||
'" /><div><strong>' +
|
||||
escapeHtml(name) +
|
||||
"</strong><span>第 " +
|
||||
escapeHtml(getResultPeriod(item) || "--") +
|
||||
" 期 · " +
|
||||
escapeHtml(formatDateValue(getResultDate(item))) +
|
||||
"</span></div></a>",
|
||||
);
|
||||
});
|
||||
if (!$focus.children().length)
|
||||
$focus.html('<div class="hero-focus-empty">暂无开奖焦点数据</div>');
|
||||
}
|
||||
function renderDynamicNav(menuList) {
|
||||
var sortedList = sortLotteries(menuList);
|
||||
var $nav = $("#navLotteryItems");
|
||||
var $grid = $("#lotteryNavGrid");
|
||||
var $trend = $("#trendGrid");
|
||||
$nav.find(".topbar__nav-link").not(":first").remove();
|
||||
$grid.empty();
|
||||
$trend.empty();
|
||||
$.each(sortedList, function (_, item) {
|
||||
var cfg = lotteryIconMap[item.name];
|
||||
if (!cfg) return;
|
||||
$nav.append(
|
||||
'<a href="cai.html?id=' +
|
||||
cfg.code +
|
||||
'" class="topbar__nav-link">' +
|
||||
escapeHtml(item.name) +
|
||||
"</a>",
|
||||
);
|
||||
$grid.append(
|
||||
'<a href="cai.html?id=' +
|
||||
cfg.code +
|
||||
'" class="lottery-nav__card" style="--accent:' +
|
||||
cfg.accent +
|
||||
'"><div class="lottery-nav__icon"><img src="' +
|
||||
cfg.icon +
|
||||
'" alt="' +
|
||||
escapeHtml(item.name) +
|
||||
'" /></div><div class="lottery-nav__text"><strong>' +
|
||||
escapeHtml(item.name) +
|
||||
"</strong><span>进入预测文章</span></div><em>查看</em></a>",
|
||||
);
|
||||
$trend.append(
|
||||
'<a href="' +
|
||||
cfg.code +
|
||||
'.html" class="trend-item"><img src="' +
|
||||
cfg.icon +
|
||||
'" alt="' +
|
||||
escapeHtml(item.name) +
|
||||
'" /><span>' +
|
||||
escapeHtml(item.name) +
|
||||
"</span></a>",
|
||||
);
|
||||
});
|
||||
}
|
||||
function updateResultsGrid(menuList) {
|
||||
var $grid = $("#resultsGrid");
|
||||
$grid.empty();
|
||||
$.each(sortLotteries(menuList), function (_, item) {
|
||||
var cfg = lotteryIconMap[item.name] || lotteryIconMap["双色球"];
|
||||
var result = item.lotteryResult || {};
|
||||
var compact = item.name === "快乐8";
|
||||
$grid.append(
|
||||
'<div class="draw-card" style="--accent:' +
|
||||
cfg.accent +
|
||||
'"><div class="draw-card__head"><div class="draw-card__title"><img src="' +
|
||||
cfg.icon +
|
||||
'" alt="' +
|
||||
escapeHtml(item.name) +
|
||||
'" /><div><strong>' +
|
||||
escapeHtml(item.name) +
|
||||
"</strong><span>第 " +
|
||||
escapeHtml(result.expect || result.name || "--") +
|
||||
' 期</span></div></div><a class="draw-card__link" href="kaijiang.html?suoxie=' +
|
||||
cfg.code +
|
||||
'">历史开奖</a></div><div class="draw-card__balls' +
|
||||
(compact ? " draw-card__balls--compact" : "") +
|
||||
'">' +
|
||||
buildBallHtml(result.openCode || "", cfg, compact) +
|
||||
'</div><div class="draw-card__foot"><span>开奖日期</span><strong>' +
|
||||
escapeHtml(
|
||||
formatDateLabel(
|
||||
result.time || result.createTime || result.date || "",
|
||||
),
|
||||
) +
|
||||
"</strong></div></div>",
|
||||
);
|
||||
});
|
||||
}
|
||||
function renderNoticeList(noticeData) {
|
||||
var $container = $("#noticeList");
|
||||
$container.empty();
|
||||
$.each((noticeData || []).slice(0, 6), function (_, notice) {
|
||||
$container.append(
|
||||
'<li class="notice-item"><a href="gonggao.html?id=' +
|
||||
escapeHtml(notice.id || "") +
|
||||
'" target="_blank">' +
|
||||
escapeHtml(notice.noticeTitle || notice.content || "公告信息") +
|
||||
"</a></li>",
|
||||
);
|
||||
});
|
||||
if (!$container.children().length)
|
||||
$container.html(
|
||||
'<li class="notice-item notice-item--empty">暂无公告</li>',
|
||||
);
|
||||
}
|
||||
function renderChannelSections(menuList) {
|
||||
var $container = $("#articleGroups");
|
||||
$container.empty();
|
||||
$.each(sortLotteries(menuList), function (index, lottery) {
|
||||
var articles = (lottery.freeArticleList || []).slice(0, 5);
|
||||
var cfg = lotteryIconMap[lottery.name] || lotteryIconMap["双色球"];
|
||||
var listHtml = "";
|
||||
$.each(articles, function (_, article) {
|
||||
listHtml +=
|
||||
`<li class="article-item"><img src="${article.accountAvatar || article.expertAvatar}" alt="" class="article-item__icon" /><a class="article-item__link" href="` +
|
||||
CommonUtil.freeArticleHref(article.id || "") +
|
||||
'" target="_blank">' +
|
||||
escapeHtml(article.title || "文章标题") +
|
||||
"</a></li>";
|
||||
});
|
||||
if (!listHtml)
|
||||
listHtml =
|
||||
'<li class="article-item article-item--empty"><span>暂无免费文章</span></li>';
|
||||
$container.append(
|
||||
'<section class="article-cluster" style="--accent:' +
|
||||
cfg.accent +
|
||||
'"><div class="article-cluster__head"><div class="article-cluster__title"><img src="' +
|
||||
cfg.icon +
|
||||
'" alt="' +
|
||||
escapeHtml(lottery.name) +
|
||||
'" /><div><strong>' +
|
||||
escapeHtml(lottery.name) +
|
||||
'</strong></div></div><a class="article-cluster__more" href="mianfeilist.html?id=' +
|
||||
escapeHtml(lottery.id || "") +
|
||||
'">更多文章</a></div><ul class="article-cluster__list">' +
|
||||
listHtml +
|
||||
"</ul></section>",
|
||||
);
|
||||
});
|
||||
}
|
||||
function renderResourceLinks($container, list) {
|
||||
$container.empty();
|
||||
if (!list.length) {
|
||||
$container.html('<span class="resource-empty">暂无数据</span>');
|
||||
return;
|
||||
}
|
||||
$.each(list, function (_, item) {
|
||||
$container.append(
|
||||
'<a class="resource-link" href="' +
|
||||
escapeHtml(item.url || "#") +
|
||||
'" target="_blank" rel="noopener noreferrer"><img src="../images/home-icon-link.png" alt="" /><span>' +
|
||||
escapeHtml(item.name || "链接标题") +
|
||||
"</span></a>",
|
||||
);
|
||||
});
|
||||
}
|
||||
function renderCompatLinks($container, list) {
|
||||
$container.empty();
|
||||
$.each(list, function (_, item) {
|
||||
$container.append(
|
||||
'<li class="link-listLi"><a href="' +
|
||||
escapeHtml(item.url || "#") +
|
||||
'" target="_blank"><div class="link-listLiText">' +
|
||||
escapeHtml(item.name || "链接标题") +
|
||||
"</div></a></li>",
|
||||
);
|
||||
});
|
||||
}
|
||||
function renderRecommendGrid(linkList) {
|
||||
var list = (linkList || []).filter(function (item) {
|
||||
return item.type === 1;
|
||||
});
|
||||
renderResourceLinks($("#otherRecommend"), list);
|
||||
renderCompatLinks($("#otherRecommendCompat"), list);
|
||||
}
|
||||
function renderLinksGrid(linkList) {
|
||||
var list = (linkList || []).filter(function (item) {
|
||||
return item.type === 2;
|
||||
});
|
||||
renderResourceLinks($("#friendLinks"), list);
|
||||
renderCompatLinks($("#friendLinksCompat"), list);
|
||||
}
|
||||
function renderAdGroups(adList) {
|
||||
var $container = $("#sidebarAdContainer");
|
||||
$container.empty();
|
||||
var validAds = CommonUtil.filterValidAds(adList || []);
|
||||
if (!validAds.length) {
|
||||
$container.html(
|
||||
'<div class="ad-group ad-group--empty">暂无广告数据</div>',
|
||||
);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < validAds.length; i += 8) {
|
||||
var html = "";
|
||||
$.each(validAds.slice(i, i + 8), function (_, ad) {
|
||||
html +=
|
||||
'<a href="' +
|
||||
escapeHtml(ad.link || "#") +
|
||||
'" target="_blank" rel="noopener noreferrer" class="ad-item"><img src="' +
|
||||
escapeHtml(ad.touxiang || "") +
|
||||
'" alt="' +
|
||||
escapeHtml(ad.title || "广告") +
|
||||
'" loading="lazy" /></a>';
|
||||
});
|
||||
$container.append(
|
||||
'<section class="ad-group">' +
|
||||
'<div class="ad-group__grid">' +
|
||||
html +
|
||||
"</div></section>",
|
||||
);
|
||||
}
|
||||
}
|
||||
function getDefaultHistoryRange() {
|
||||
var end = new Date();
|
||||
var start = new Date();
|
||||
start.setDate(end.getDate() - 30);
|
||||
return { start: formatDateValue(start), end: formatDateValue(end) };
|
||||
}
|
||||
function openHistoryModal() {
|
||||
var options = "";
|
||||
var sourceList = currentLotteryMenu.length
|
||||
? currentLotteryMenu
|
||||
: lotteryOrder.map(function (name) {
|
||||
return { name: name };
|
||||
});
|
||||
$.each(sourceList, function (_, item) {
|
||||
var name = normalizeLotteryName(item.name);
|
||||
var code =
|
||||
item.suoxie ||
|
||||
item.code ||
|
||||
(lotteryIconMap[name] ? lotteryIconMap[name].code : "");
|
||||
if (!code || !lotteryIconMap[name]) return;
|
||||
options +=
|
||||
'<option value="' +
|
||||
code +
|
||||
'">' +
|
||||
name +
|
||||
"</option>";
|
||||
});
|
||||
$("#historyLotterySelect").html(options);
|
||||
var range = getDefaultHistoryRange();
|
||||
$("#historyStartDate").val(range.start);
|
||||
$("#historyEndDate").val(range.end);
|
||||
$("#historyModal").addClass("is-open");
|
||||
searchHistory();
|
||||
}
|
||||
function closeHistoryModal() {
|
||||
$("#historyModal").removeClass("is-open");
|
||||
}
|
||||
function resolveLotteryNameByCode(code) {
|
||||
var found = "";
|
||||
$.each(lotteryIconMap, function (name, cfg) {
|
||||
if (cfg.code === code) found = name;
|
||||
});
|
||||
return found || code;
|
||||
}
|
||||
function renderHistoryRows(code, list) {
|
||||
var $body = $("#historyTableBody");
|
||||
$body.empty();
|
||||
if (!list.length) {
|
||||
$body.html(
|
||||
'<tr><td colspan="4" class="is-empty">暂无历史开奖数据</td></tr>',
|
||||
);
|
||||
return;
|
||||
}
|
||||
$.each(list.slice(0, 50), function (_, item) {
|
||||
$body.append(
|
||||
"<tr><td>" +
|
||||
escapeHtml(resolveLotteryNameByCode(code)) +
|
||||
"</td><td>" +
|
||||
escapeHtml(item.expect || item.name || "--") +
|
||||
'</td><td class="history-code">' +
|
||||
escapeHtml(item.openCode || "--") +
|
||||
"</td><td>" +
|
||||
escapeHtml(
|
||||
formatDateValue(
|
||||
item.date || item.time || item.createTime || "",
|
||||
),
|
||||
) +
|
||||
"</td></tr>",
|
||||
);
|
||||
});
|
||||
}
|
||||
function searchHistory() {
|
||||
var code = $("#historyLotterySelect").val();
|
||||
var startDate = $("#historyStartDate").val();
|
||||
var endDate = $("#historyEndDate").val();
|
||||
if (!code) return;
|
||||
function applyFilter(list) {
|
||||
var filtered = (list || []).filter(function (item) {
|
||||
var current = formatDateValue(
|
||||
item.date || item.time || item.createTime || "",
|
||||
);
|
||||
if (startDate && current < startDate) return false;
|
||||
if (endDate && current > endDate) return false;
|
||||
return true;
|
||||
});
|
||||
renderHistoryRows(code, filtered);
|
||||
}
|
||||
if (historyCache[code]) {
|
||||
applyFilter(historyCache[code]);
|
||||
return;
|
||||
}
|
||||
$("#historyTableBody").html(
|
||||
'<tr><td colspan="4" class="is-empty">正在加载历史开奖数据...</td></tr>',
|
||||
);
|
||||
ApiClient.post("/api/web/lotteryResult/getList", { suoxie: code })
|
||||
.then(function (res) {
|
||||
if (res.code === 0 && res.data) {
|
||||
historyCache[code] = res.data.records || res.data || [];
|
||||
applyFilter(historyCache[code]);
|
||||
} else {
|
||||
$("#historyTableBody").html(
|
||||
'<tr><td colspan="4" class="is-empty">历史开奖数据加载失败</td></tr>',
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
$("#historyTableBody").html(
|
||||
'<tr><td colspan="4" class="is-empty">历史开奖数据加载失败</td></tr>',
|
||||
);
|
||||
});
|
||||
}
|
||||
function logout() {
|
||||
localStorage.removeItem("token");
|
||||
window.location.reload();
|
||||
}
|
||||
function checkLoginStatus() {
|
||||
if (!token) return;
|
||||
$("#notLoggedInBox").hide();
|
||||
$("#loggedInBox").css("display", "flex");
|
||||
CommonUtil.getCurrentUserDetail(
|
||||
function (data) {
|
||||
$("#userName").text(data.nickName || "用户");
|
||||
$("#userLevel").text(
|
||||
String(data.isExpert) === "1" ? "专家" : "会员",
|
||||
);
|
||||
if (data.avatar) $("#userAvatar").attr("src", data.avatar);
|
||||
},
|
||||
function () {
|
||||
$("#notLoggedInBox").show();
|
||||
$("#loggedInBox").hide();
|
||||
},
|
||||
);
|
||||
}
|
||||
function bindStaticEvents() {
|
||||
$("#historyModal").on("click", function (event) {
|
||||
if ($(event.target).is("#historyModal")) closeHistoryModal();
|
||||
});
|
||||
$(document).on("change", "#historyLotterySelect", searchHistory);
|
||||
$(window).on("scroll", function () {
|
||||
$(window).scrollTop() > 320
|
||||
? $("#backTop").addClass("is-visible")
|
||||
: $("#backTop").removeClass("is-visible");
|
||||
});
|
||||
$(document).on("click", ".topbar__nav-link", function () {
|
||||
$(".topbar__nav-link").removeClass("is-active");
|
||||
$(this).addClass("is-active");
|
||||
});
|
||||
}
|
||||
function hydrateHome(result) {
|
||||
var data = result.data || {};
|
||||
var sortedMenu = sortLotteries(data.menuList || []);
|
||||
currentLotteryMenu = sortedMenu;
|
||||
$("#currentDate").text(formatDateLabel(new Date()));
|
||||
renderBannerImages(data.bannerList || []);
|
||||
renderDynamicNav(sortedMenu);
|
||||
updateResultsGrid(sortedMenu);
|
||||
renderChannelSections(sortedMenu);
|
||||
renderHeroSummary(sortedMenu, data.noticeList || []);
|
||||
renderNoticeList(data.noticeList || []);
|
||||
renderAdGroups(data.adList || []);
|
||||
renderRecommendGrid(data.linkList || []);
|
||||
renderLinksGrid(data.linkList || []);
|
||||
ApiClient.post("/api/web/QRCode").then(function (res) {
|
||||
if (res.code === 0 && res.data)
|
||||
CommonUtil.generateQRCode(res.data, "downloadQrImg");
|
||||
});
|
||||
}
|
||||
$(function () {
|
||||
bindStaticEvents();
|
||||
checkLoginStatus();
|
||||
CommonUtil.loadPageConfig({
|
||||
ads: false,
|
||||
links: false,
|
||||
onSuccess: hydrateHome,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- Code injected by live-server -->
|
||||
<script>
|
||||
// <![CDATA[ <-- For SVG support
|
||||
if ('WebSocket' in window) {
|
||||
(function () {
|
||||
function refreshCSS() {
|
||||
var sheets = [].slice.call(document.getElementsByTagName("link"));
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
for (var i = 0; i < sheets.length; ++i) {
|
||||
var elem = sheets[i];
|
||||
var parent = elem.parentElement || head;
|
||||
parent.removeChild(elem);
|
||||
var rel = elem.rel;
|
||||
if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
|
||||
var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
|
||||
elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
|
||||
}
|
||||
parent.appendChild(elem);
|
||||
}
|
||||
}
|
||||
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
|
||||
var address = protocol + window.location.host + window.location.pathname + '/ws';
|
||||
var socket = new WebSocket(address);
|
||||
socket.onmessage = function (msg) {
|
||||
if (msg.data == 'reload') window.location.reload();
|
||||
else if (msg.data == 'refreshcss') refreshCSS();
|
||||
};
|
||||
if (sessionStorage && !sessionStorage.getItem('IsThisFirstTime_Log_From_LiveServer')) {
|
||||
console.log('Live reload enabled.');
|
||||
sessionStorage.setItem('IsThisFirstTime_Log_From_LiveServer', true);
|
||||
}
|
||||
})();
|
||||
}
|
||||
else {
|
||||
console.error('Upgrade your browser. This Browser is NOT supported WebSocket for Live-Reloading.');
|
||||
}
|
||||
// ]]>
|
||||
</script>
|
||||
<!-- Code injected by live-server -->
|
||||
<script>
|
||||
// <![CDATA[ <-- For SVG support
|
||||
if ('WebSocket' in window) {
|
||||
(function () {
|
||||
function refreshCSS() {
|
||||
var sheets = [].slice.call(document.getElementsByTagName("link"));
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
for (var i = 0; i < sheets.length; ++i) {
|
||||
var elem = sheets[i];
|
||||
var parent = elem.parentElement || head;
|
||||
parent.removeChild(elem);
|
||||
var rel = elem.rel;
|
||||
if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
|
||||
var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
|
||||
elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
|
||||
}
|
||||
parent.appendChild(elem);
|
||||
}
|
||||
}
|
||||
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
|
||||
var address = protocol + window.location.host + window.location.pathname + '/ws';
|
||||
var socket = new WebSocket(address);
|
||||
socket.onmessage = function (msg) {
|
||||
if (msg.data == 'reload') window.location.reload();
|
||||
else if (msg.data == 'refreshcss') refreshCSS();
|
||||
};
|
||||
if (sessionStorage && !sessionStorage.getItem('IsThisFirstTime_Log_From_LiveServer')) {
|
||||
console.log('Live reload enabled.');
|
||||
sessionStorage.setItem('IsThisFirstTime_Log_From_LiveServer', true);
|
||||
}
|
||||
})();
|
||||
}
|
||||
else {
|
||||
console.error('Upgrade your browser. This Browser is NOT supported WebSocket for Live-Reloading.');
|
||||
}
|
||||
// ]]>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user