修改功能,现已测试注册登录忘记密码

This commit is contained in:
rain
2026-06-12 11:42:49 +08:00
parent 0bf2f573ed
commit cfc64c69e5
26 changed files with 2238 additions and 898 deletions
+57 -9
View File
@@ -114,6 +114,7 @@
let currentPage = 1;
const pageSize = 15;
let lotteryMenus = [];
let freeArticleGroups = [];
function logout() {
localStorage.removeItem("token");
@@ -155,7 +156,7 @@
if (
menuId &&
lotteryMenus.some(function (item) {
return String(item.id) === String(menuId);
return sameLotteryKey(item, menuId);
})
) {
return;
@@ -165,14 +166,24 @@
}
function renderLotteryTabs() {
return ApiClient.get(ApiClient.API.homeNav)
.then(function (res) {
return Promise.all([
ApiClient.get(ApiClient.API.homeNav).catch(function () {
return { data: [] };
}),
ApiClient.get(ApiClient.API.freeArticleRecommend, { articleCount: pageSize }).catch(function () {
return { data: [] };
}),
])
.then(function (results) {
const res = results[0];
const recommendRes = results[1];
lotteryMenus = normalizeLotteryMenus(ApiClient.pickData(res, []));
freeArticleGroups = ApiClient.asArray(ApiClient.pickData(recommendRes, []));
resolveCurrentMenuId();
const $tabs = $("#lotteryTabs");
$tabs.empty();
$.each(lotteryMenus, function (_, item) {
const id = item.id || "";
const id = item.id || item.menuId || item.code || item.suoxie || "";
$tabs.append(
'<a href="mianfeilist.html?id=' +
encodeURIComponent(id) +
@@ -198,13 +209,41 @@
$(".cxz-lottery-tab").removeClass("active");
$('.cxz-lottery-tab[data-id="' + menuId + '"]').addClass("active");
const currentMenu = lotteryMenus.find(function (item) {
return String(item.id) === String(menuId);
return sameLotteryKey(item, menuId);
});
const name = (currentMenu && currentMenu.name) || "免费推荐";
$("#listTitle").text(name + " - 免费推荐");
document.title = "彩先知 - " + name + "免费推荐";
}
function sameLotteryKey(item, value) {
const key = String(value || "").toLowerCase();
if (!key || !item) return false;
return (
String(item.id || "").toLowerCase() === key ||
String(item.menuId || "").toLowerCase() === key ||
String(item.code || "").toLowerCase() === key ||
String(item.suoxie || "").toLowerCase() === key ||
String(item.lotteryCode || "").toLowerCase() === key ||
String(item.name || "").toLowerCase() === key
);
}
function currentMenuInfo() {
return lotteryMenus.find(function (item) {
return sameLotteryKey(item, menuId);
});
}
function currentFallbackGroup() {
const menu = currentMenuInfo();
return (
freeArticleGroups.find(function (group) {
return sameLotteryKey(group, menuId) || sameLotteryKey(group, menu && (menu.code || menu.suoxie || menu.id));
}) || null
);
}
// Load articles
function loadArticles() {
if (!menuId) {
@@ -214,7 +253,7 @@
renderPagination(0);
return;
}
ApiClient.get("/api/web/free-article/list", {
ApiClient.get(ApiClient.API.freeArticleList, {
menuId: menuId,
pageNum: currentPage,
pageSize: pageSize,
@@ -225,13 +264,22 @@
renderArticles(list);
renderPagination(data.totalRow || data.total || data.count || list.length || 0);
} else {
$("#articleList").html(
'<div class="cxz-article-item"><span style="color:var(--text-muted);">暂无数据</span></div>',
);
renderFallbackArticles();
}
}).catch(function () {
renderFallbackArticles();
});
}
function renderFallbackArticles() {
const group = currentFallbackGroup();
const allArticles = ApiClient.asArray(group && group.articles);
const startIndex = (currentPage - 1) * pageSize;
const records = allArticles.slice(startIndex, startIndex + pageSize);
renderArticles(records);
renderPagination(allArticles.length);
}
function renderArticles(list) {
const $container = $("#articleList");
$container.empty();