修改样式、功能完成,待测试
This commit is contained in:
+228
-24
@@ -11,6 +11,7 @@
|
||||
<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/layout-fix.css" />
|
||||
<link rel="stylesheet" href="../public/css/caiinfo.css" />
|
||||
</head>
|
||||
<body>
|
||||
@@ -58,10 +59,16 @@
|
||||
<!-- Main -->
|
||||
<main class="cxz-main">
|
||||
<div class="cxz-breadcrumb">
|
||||
<a href="index.html">首页</a><span class="sep">></span>
|
||||
<a href="cai.html?id=" id="breadcrumbCai">预测推荐</a
|
||||
><span class="sep">></span>
|
||||
<span id="breadcrumbExpert">专家详情</span>
|
||||
<a href="javascript:history.back();" class="cxz-breadcrumb-back" id="breadcrumbBack">
|
||||
<i class="layui-icon layui-icon-left"></i>
|
||||
<span>返回上一页</span>
|
||||
</a>
|
||||
<div class="cxz-breadcrumb-trail" id="breadcrumbTrail">
|
||||
<a href="index.html">首页</a><span class="sep">></span>
|
||||
<a href="cai.html?id=" id="breadcrumbCai">预测推荐</a
|
||||
><span class="sep">></span>
|
||||
<span id="breadcrumbExpert">专家详情</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Expert Card -->
|
||||
@@ -279,6 +286,7 @@
|
||||
let currentWalletOverview = {};
|
||||
let expertCollected = false;
|
||||
let currentArticleList = [];
|
||||
let currentMenuMeta = { lottery: null, parent: null, current: null };
|
||||
const purchasedArticleIds = new Set();
|
||||
const purchasedArticleKeys = new Set();
|
||||
|
||||
@@ -344,6 +352,94 @@
|
||||
});
|
||||
}
|
||||
|
||||
function findMenuMeta(menus) {
|
||||
let lottery = null;
|
||||
let parent = null;
|
||||
let current = null;
|
||||
const targetCode = String(code || "").toLowerCase();
|
||||
const targetMenuId = String(parentId || "");
|
||||
|
||||
function walk(items, parentNode, rootNode) {
|
||||
$.each(items || [], function (_, item) {
|
||||
const root = rootNode || item;
|
||||
const itemCode = String(item.code || item.suoxie || "").toLowerCase();
|
||||
const itemId = String(item.id || item.menuId || "");
|
||||
|
||||
if (targetCode && itemCode === targetCode) {
|
||||
lottery = root;
|
||||
}
|
||||
|
||||
if (targetMenuId && itemId === targetMenuId) {
|
||||
lottery = root;
|
||||
current = item;
|
||||
parent = parentNode && parentNode !== root ? parentNode : null;
|
||||
}
|
||||
|
||||
if (item.children && item.children.length) {
|
||||
walk(item.children, item, root);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
walk(menus || [], null, null);
|
||||
return { lottery: lottery, parent: parent, current: current };
|
||||
}
|
||||
|
||||
function loadBreadcrumbMenuMeta() {
|
||||
return ApiClient.loadMenuCompat()
|
||||
.then(function (res) {
|
||||
const menus = ApiClient.asArray(ApiClient.pickData(res, []));
|
||||
currentMenuMeta = findMenuMeta(menus);
|
||||
return currentMenuMeta;
|
||||
})
|
||||
.catch(function () {
|
||||
currentMenuMeta = { lottery: null, parent: null, current: null };
|
||||
return currentMenuMeta;
|
||||
});
|
||||
}
|
||||
|
||||
function getReturnListHref() {
|
||||
const referrer = document.referrer || "";
|
||||
if (referrer && referrer.indexOf(location.origin) === 0) {
|
||||
return referrer;
|
||||
}
|
||||
return buildCaiListUrl();
|
||||
}
|
||||
|
||||
function updateBreadcrumb(expertName) {
|
||||
const lottery = currentMenuMeta.lottery || {};
|
||||
const parent = currentMenuMeta.parent || {};
|
||||
const current = currentMenuMeta.current || {};
|
||||
const lotteryName = lottery.name || lottery.title || code || "预测推荐";
|
||||
const lotteryCode = lottery.code || lottery.suoxie || code || "";
|
||||
const listHref = buildCaiListUrl(lotteryCode);
|
||||
const items = [
|
||||
{ text: "首页", href: "index.html" },
|
||||
{ text: lotteryName, href: listHref },
|
||||
];
|
||||
|
||||
if (parent.name) {
|
||||
items.push({ text: parent.name, href: listHref });
|
||||
}
|
||||
if (current.name && current.name !== parent.name) {
|
||||
items.push({ text: current.name, href: listHref });
|
||||
}
|
||||
items.push({ text: expertName || "专家详情" });
|
||||
|
||||
const html = items
|
||||
.map(function (item, index) {
|
||||
const text = CommonUtil.escapeHtml(item.text || "");
|
||||
const node = item.href
|
||||
? '<a href="' + CommonUtil.escapeHtml(item.href) + '">' + text + "</a>"
|
||||
: '<span id="breadcrumbExpert">' + text + "</span>";
|
||||
return index === 0 ? node : '<span class="sep">></span>' + node;
|
||||
})
|
||||
.join("");
|
||||
|
||||
$("#breadcrumbTrail").html(html);
|
||||
$("#breadcrumbBack").attr("href", getReturnListHref());
|
||||
}
|
||||
|
||||
function getArticleId(item) {
|
||||
return String(
|
||||
(item &&
|
||||
@@ -388,6 +484,11 @@
|
||||
);
|
||||
}
|
||||
|
||||
function formatIssueText(issue) {
|
||||
const value = String(issue || "").trim();
|
||||
return /^\d{7,}$/.test(value) ? value.slice(-3) : value;
|
||||
}
|
||||
|
||||
function getArticleExpertId(item) {
|
||||
return String((item && (item.expertId || item.createBy || item.accountId)) || createBy || "");
|
||||
}
|
||||
@@ -529,6 +630,7 @@
|
||||
return { code: 500, msg: error.message || "获取专家预测详情失败", data: [] };
|
||||
}),
|
||||
loadPurchasedRecordsForCurrentExpert(),
|
||||
loadBreadcrumbMenuMeta(),
|
||||
]).then(function ([profileRes, listRes]) {
|
||||
const profile = ApiClient.pickData(profileRes, {}) || {};
|
||||
const listData = ApiClient.pickData(listRes, []) || [];
|
||||
@@ -583,7 +685,7 @@
|
||||
"专家";
|
||||
if (avatar) $("#expertAvatar").attr("src", avatar);
|
||||
$("#expertName").text(name);
|
||||
$("#breadcrumbExpert").text(name || "专家详情");
|
||||
updateBreadcrumb(name || "专家详情");
|
||||
expertCollected = isExpertCollected(data);
|
||||
applyExpertCollectState(expertCollected);
|
||||
}
|
||||
@@ -611,9 +713,15 @@
|
||||
const predictedCode = getArticleRecommend(item);
|
||||
const hasDrawResult = isArticleDrawn(item, openCode);
|
||||
const isLatestIssue = isLatestArticle(item, list);
|
||||
const price = Number(getArticlePrice(item));
|
||||
const unlockedByVisibleRecommend =
|
||||
predictedCode && !isMaskedRecommendText(predictedCode);
|
||||
const purchased = isArticlePurchased(item);
|
||||
isLatestIssue &&
|
||||
!hasDrawResult &&
|
||||
price > 0 &&
|
||||
!isArticleMasked(item) &&
|
||||
predictedCode &&
|
||||
!isMaskedRecommendText(predictedCode);
|
||||
const purchased = isArticlePurchased(item) || unlockedByVisibleRecommend;
|
||||
const canShowRecommend = canShowArticleRecommend(
|
||||
item,
|
||||
isLatestIssue,
|
||||
@@ -621,17 +729,21 @@
|
||||
unlockedByVisibleRecommend,
|
||||
);
|
||||
const articleStatus = getArticleStatus(item);
|
||||
let recommendOptions = null;
|
||||
let recommendText = "";
|
||||
let openCodeHtml = renderOpenCodeBalls(openCode, item);
|
||||
let predictHtml = "";
|
||||
if (isPendingPublishText(predictedCode)) {
|
||||
predictHtml = '<span style="color:var(--text-muted);">待发布</span>';
|
||||
const pendingPublish = isPendingPublishArticle(item, articleStatus, predictedCode);
|
||||
if (pendingPublish) {
|
||||
predictHtml = '<span class="cxz-pending-publish-text">' + getPendingPublishText() + '</span>';
|
||||
} else if (canShowRecommend && predictedCode) {
|
||||
const recommendOptions = getRecommendRenderOptions(item, articleStatus.text);
|
||||
recommendOptions = getRecommendRenderOptions(item, articleStatus.text);
|
||||
recommendText = formatRecommendText(predictedCode, Infinity, recommendOptions);
|
||||
predictHtml =
|
||||
buildRecommendHtml(predictedCode, Infinity, recommendOptions) +
|
||||
' <button class="cxz-btn-copy" onclick="copyCode(\'' +
|
||||
escapeJs(predictedCode) +
|
||||
"')\">复制</button>";
|
||||
'<span class="cxz-recommend-wrap"><span class="cxz-recommend-content"></span>' +
|
||||
'<button class="cxz-btn-copy" onclick="event.stopPropagation(); copyCode(\'' +
|
||||
escapeJs(recommendText) +
|
||||
"')\">复制</button></span>";
|
||||
} else if (predictedCode) {
|
||||
predictHtml =
|
||||
'<span style="color:var(--text-muted);">' +
|
||||
@@ -654,7 +766,7 @@
|
||||
actionHtml =
|
||||
'<button class="cxz-btn-prebuy" onclick="openPrePurchaseDialog(' +
|
||||
i +
|
||||
')">预购</button> ';
|
||||
')">购买</button> ';
|
||||
} else if (shouldShowBuyButton(item, isLatestIssue, hasDrawResult, purchased) && articleId) {
|
||||
actionHtml =
|
||||
'<button class="cxz-btn-buy" onclick="openBuyDialog(\'' +
|
||||
@@ -678,7 +790,7 @@
|
||||
$body.append(
|
||||
"<tr>" +
|
||||
"<td>" +
|
||||
CommonUtil.escapeHtml(getArticleIssue(item) || "--") +
|
||||
CommonUtil.escapeHtml(formatIssueText(getArticleIssue(item)) || "--") +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
openCodeHtml +
|
||||
@@ -694,6 +806,17 @@
|
||||
"</td>" +
|
||||
"</tr>",
|
||||
);
|
||||
if (canShowRecommend && predictedCode && recommendOptions) {
|
||||
const $recommendCell = $body.children("tr").last().find(".cxz-recommend-content");
|
||||
const isFolded = fitRecommendCell($recommendCell, predictedCode, recommendOptions);
|
||||
if (isFolded) {
|
||||
$recommendCell
|
||||
.addClass("recommend-clickable")
|
||||
.on("click", function () {
|
||||
showFullRecommend(predictedCode, recommendOptions);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -764,7 +887,25 @@
|
||||
}
|
||||
|
||||
function isPendingPublishText(value) {
|
||||
return String(value || "").trim() === "待发布";
|
||||
const text = String(value || "").trim();
|
||||
return text === "待发布" || text === getPendingPublishText() || text.indexOf("发布中") >= 0;
|
||||
}
|
||||
|
||||
function getPendingPublishText() {
|
||||
return "号码发布中请稍等";
|
||||
}
|
||||
|
||||
function isPendingPublishArticle(item, articleStatus, recommend) {
|
||||
const statusText = String(
|
||||
getExplicitStatusText(item) ||
|
||||
(articleStatus && articleStatus.text) ||
|
||||
"",
|
||||
).trim();
|
||||
return Boolean(
|
||||
isPendingPublishText(recommend) ||
|
||||
isPendingPublishText(statusText) ||
|
||||
(isArticlePrePurchase(item) && !getArticleRecommend(item)),
|
||||
);
|
||||
}
|
||||
|
||||
function isCodeResultsAllCorrect(item) {
|
||||
@@ -914,7 +1055,6 @@
|
||||
isLatestIssue &&
|
||||
!hasDrawResult &&
|
||||
isArticleMasked(item) &&
|
||||
!isArticlePrePurchase(item) &&
|
||||
!purchased,
|
||||
);
|
||||
}
|
||||
@@ -923,8 +1063,8 @@
|
||||
return Boolean(
|
||||
!purchased &&
|
||||
!isArticlePrePurchased(item) &&
|
||||
!getArticleId(item) &&
|
||||
getArticleStatus(item).text === "待发布",
|
||||
(isArticlePrePurchase(item) ||
|
||||
(!getArticleId(item) && isPendingPublishArticle(item))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -942,7 +1082,21 @@
|
||||
}
|
||||
|
||||
function buildRecommendHtml(recommend, limit, options) {
|
||||
const nums = splitRecommendValues(recommend);
|
||||
const contentHtml = buildRecommendContentHtml(recommend, limit, options || {});
|
||||
const more =
|
||||
Number.isFinite(limit) && nums.length > limit
|
||||
? '<span class="recommend-view-all">点击查看全部</span>'
|
||||
: "";
|
||||
if (more) {
|
||||
return (
|
||||
'<span class="fushi234item"><span class="recommend-preview-text">' +
|
||||
contentHtml +
|
||||
"</span>" +
|
||||
more +
|
||||
"</span>"
|
||||
);
|
||||
}
|
||||
return (
|
||||
'<span class="fushi234item">' +
|
||||
(contentHtml || CommonUtil.escapeHtml(formatRecommendText(recommend, limit, options || {}))) +
|
||||
@@ -950,6 +1104,52 @@
|
||||
);
|
||||
}
|
||||
|
||||
function fitRecommendCell($cell, recommend, options) {
|
||||
const nums = splitRecommendValues(recommend);
|
||||
const previewLimit = 4;
|
||||
if (nums.length <= previewLimit) {
|
||||
$cell.html(buildRecommendHtml(recommend, Infinity, options || {}));
|
||||
return false;
|
||||
}
|
||||
|
||||
$cell.html(buildRecommendHtml(recommend, Infinity, options || {}));
|
||||
const cellEl = $cell.get(0);
|
||||
const contentEl = $cell.find(".fushi234item").get(0);
|
||||
if (cellEl && contentEl && contentEl.scrollWidth <= cellEl.clientWidth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cell.html(buildRecommendHtml(recommend, previewLimit, options || {}));
|
||||
return true;
|
||||
}
|
||||
|
||||
function showFullRecommend(recommend, options) {
|
||||
const fullText = formatRecommendText(recommend, Infinity, options || {});
|
||||
if (!fullText) return;
|
||||
layui.layer.open({
|
||||
title: "完整推荐号码",
|
||||
area: ["520px", "auto"],
|
||||
skin: "recommend-number-layer",
|
||||
btn: ["确定"],
|
||||
content:
|
||||
'<div class="recommend-number-dialog">' +
|
||||
'<div class="recommend-number-content">' +
|
||||
buildRecommendHtml(recommend, Infinity, options || {}) +
|
||||
"</div>" +
|
||||
'<div class="recommend-number-actions">' +
|
||||
'<button class="recommend-dialog-copy" type="button">复制全部</button>' +
|
||||
"</div>" +
|
||||
"</div>",
|
||||
});
|
||||
setTimeout(function () {
|
||||
$(".recommend-dialog-copy")
|
||||
.off("click")
|
||||
.on("click", function () {
|
||||
copyCode(fullText);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function buildRecommendContentHtml(recommend, limit, options) {
|
||||
const groups = parseRecommendGroups(recommend);
|
||||
if (!groups.length) return "";
|
||||
@@ -1332,6 +1532,10 @@
|
||||
let text = statusText || "待开奖";
|
||||
let style = "color:#8c8c8c;";
|
||||
|
||||
if (isPendingPublishText(text)) {
|
||||
text = "待开奖";
|
||||
}
|
||||
|
||||
if (isWinStatusText(text)) {
|
||||
style = "color:#de2103;";
|
||||
}
|
||||
@@ -1885,7 +2089,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
ApiClient.get(ApiClient.API.walletPrepurchasePayArticle, params, {
|
||||
ApiClient.post(ApiClient.API.walletPrepurchasePayArticle, params, {
|
||||
headers: CommonUtil.authHeaders(),
|
||||
}).then(function (res) {
|
||||
if (ApiClient.isSuccess(res)) {
|
||||
@@ -1899,15 +2103,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
function buildCaiListUrl() {
|
||||
function buildCaiListUrl(lotteryCode) {
|
||||
const params = new URLSearchParams();
|
||||
params.set("id", code || "ssq");
|
||||
params.set("id", lotteryCode || code || "ssq");
|
||||
if (parentId) params.set("parentId", parentId);
|
||||
return "cai.html?" + params.toString();
|
||||
}
|
||||
|
||||
// Breadcrumb
|
||||
$("#breadcrumbCai").attr("href", buildCaiListUrl());
|
||||
updateBreadcrumb("专家详情");
|
||||
|
||||
// Init
|
||||
$(function () {
|
||||
|
||||
Reference in New Issue
Block a user