修改样式、功能完成,待测试
This commit is contained in:
+1
-1
@@ -704,7 +704,7 @@ const ApiClient = {
|
||||
|
||||
shouldLoadMenuChildren() {
|
||||
if (typeof window === 'undefined') return true;
|
||||
return /\/(?:cai|fufei)\.html(?:$|\?)/.test(
|
||||
return /\/(?:cai|caiinfo|fufei)\.html(?:$|\?)/.test(
|
||||
window.location.pathname + window.location.search
|
||||
);
|
||||
},
|
||||
|
||||
+276
-142
@@ -876,7 +876,16 @@ const CommonUtil = {
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
const escapeJs = (value) => escapeHtml(value).replace(/\\/g, '\\\\');
|
||||
const isMasked = (value) => /\*/.test(String(value || ''));
|
||||
const isMasked = (value) => {
|
||||
const text = String(value || '').trim();
|
||||
return (
|
||||
!text ||
|
||||
/\*/.test(text) ||
|
||||
text.indexOf('购买后可见') >= 0 ||
|
||||
text.indexOf('登录后购买可见') >= 0 ||
|
||||
text.indexOf('待发布') >= 0
|
||||
);
|
||||
};
|
||||
const normalizeRecommend = (value) =>
|
||||
String(value || '')
|
||||
.replace(/[,、]/g, ',')
|
||||
@@ -886,6 +895,10 @@ const CommonUtil = {
|
||||
.replace(/\+,/g, '+')
|
||||
.replace(/,\+/g, '+')
|
||||
.replace(/^,|,$/g, '');
|
||||
const formatIssueText = (issue) => {
|
||||
const value = String(issue || '').trim();
|
||||
return /^\d{7,}$/.test(value) ? value.slice(-3) : value;
|
||||
};
|
||||
const splitNumbers = (value) => {
|
||||
const text = normalizeRecommend(value);
|
||||
if (!text || isMasked(text)) return [];
|
||||
@@ -898,73 +911,106 @@ const CommonUtil = {
|
||||
const text = String(value || '').trim();
|
||||
return /^\d+$/.test(text) ? String(Number(text)) : text;
|
||||
};
|
||||
const getWrongNumbers = (item) => {
|
||||
const codeResultWrong = (typeof ApiClient !== 'undefined' ? ApiClient.asArray(item && item.codeResults) : [])
|
||||
.filter((result) => result && typeof result === 'object' && result.correct === false)
|
||||
.map((result) => result.code || result.value || result.number || result.result || '')
|
||||
.filter(Boolean);
|
||||
const raw =
|
||||
item.wrongNumbers ||
|
||||
item.wrongCode ||
|
||||
item.errorNumbers ||
|
||||
item.errorCode ||
|
||||
item.missNumbers ||
|
||||
item.missCode ||
|
||||
item.reverseNumbers ||
|
||||
item.reverseCode ||
|
||||
item.falseNumbers ||
|
||||
item.falseCode ||
|
||||
item.fanZhi ||
|
||||
item.fanzhi ||
|
||||
codeResultWrong.join(',');
|
||||
const groups = splitNumbers(Array.isArray(raw) ? raw.join(',') : raw);
|
||||
const values = groups.flat();
|
||||
return new Set(
|
||||
const toNumberSet = (values) =>
|
||||
new Set(
|
||||
values.flatMap((num) => {
|
||||
const text = String(num);
|
||||
return [text, text.padStart(2, '0'), normalizeNumberKey(text)];
|
||||
})
|
||||
);
|
||||
};
|
||||
const getHitNumbers = (item) => {
|
||||
const codeResultHit = (typeof ApiClient !== 'undefined' ? ApiClient.asArray(item && item.codeResults) : [])
|
||||
.filter((result) => result && typeof result === 'object' && result.correct === true)
|
||||
.map((result) => result.code || result.value || result.number || result.result || '')
|
||||
.filter(Boolean);
|
||||
const raw =
|
||||
item.hitNumbers ||
|
||||
item.hitCode ||
|
||||
item.hitCodes ||
|
||||
item.correctNumbers ||
|
||||
item.correctCode ||
|
||||
item.correctCodes ||
|
||||
item.winNumbers ||
|
||||
item.winCode ||
|
||||
item.winCodes ||
|
||||
codeResultHit.join(',');
|
||||
const groups = splitNumbers(Array.isArray(raw) ? raw.join(',') : raw);
|
||||
const values = groups.flat();
|
||||
return new Set(
|
||||
values.flatMap((num) => {
|
||||
const text = String(num);
|
||||
return [text, text.padStart(2, '0'), normalizeNumberKey(text)];
|
||||
})
|
||||
const getRecommendGroupSeparator = (value) => (String(value || '').includes('|') ? '|' : '+');
|
||||
const splitRecommendValues = (value) => splitNumbers(value).flat();
|
||||
const getArticleRecommendValue = (item) =>
|
||||
(item && (item.predictedCode || item.recommendCode || item.latestRecommend || item.recommend || item.content)) || '';
|
||||
const getArticleIssueValue = (item) =>
|
||||
(item && (item.issue || item.latestIssue || item.expect || item.period)) || '';
|
||||
const isMaskedRecommendText = (value) => isMasked(value);
|
||||
const isTruthyFlag = (value) =>
|
||||
value === true || value === 1 || value === '1' || String(value).toLowerCase() === 'true';
|
||||
const isArticlePrePurchased = (item) =>
|
||||
Boolean(
|
||||
item &&
|
||||
(isTruthyFlag(item.prePurchased) ||
|
||||
isTruthyFlag(item.pre_purchased) ||
|
||||
isTruthyFlag(item.prepaid) ||
|
||||
isTruthyFlag(item.prepaidArticle))
|
||||
);
|
||||
const isArticlePrePurchase = (item) =>
|
||||
Boolean(
|
||||
item &&
|
||||
(isTruthyFlag(item.prePurchase) ||
|
||||
isTruthyFlag(item.pre_purchase) ||
|
||||
isTruthyFlag(item.canPrePurchase) ||
|
||||
isTruthyFlag(item.preOrder))
|
||||
);
|
||||
const getArticleCodeNumbers = (item, fields) => {
|
||||
let value = '';
|
||||
fields.some((field) => {
|
||||
if (item && item[field] !== undefined && item[field] !== null && item[field] !== '') {
|
||||
value = item[field];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (Array.isArray(value)) {
|
||||
return value.flatMap((entry) =>
|
||||
splitRecommendValues(
|
||||
entry && typeof entry === 'object'
|
||||
? entry.code || entry.value || entry.number || entry.result || ''
|
||||
: entry
|
||||
)
|
||||
);
|
||||
}
|
||||
return splitRecommendValues(value);
|
||||
};
|
||||
const getCodeResultMarks = (item, recommend) => {
|
||||
const recommendGroups = splitNumbers(recommend);
|
||||
const codeResults =
|
||||
typeof ApiClient !== 'undefined' ? ApiClient.asArray(item && item.codeResults) : [];
|
||||
if (!recommendGroups.length || !codeResults.length) return null;
|
||||
|
||||
const flatCount = recommendGroups.reduce((total, group) => total + group.length, 0);
|
||||
const getCodeResultNumbers = (item, correctValue) =>
|
||||
(typeof ApiClient !== 'undefined' ? ApiClient.asArray(item && item.codeResults) : [])
|
||||
.filter((result) => result && typeof result === 'object' && result.correct === correctValue)
|
||||
.flatMap((result) => splitRecommendValues(result.code || result.value || result.number || result.result || ''));
|
||||
const getArticleHitNumbers = (item) => {
|
||||
const fields = [
|
||||
'hitCodes',
|
||||
'hitCode',
|
||||
'hitNumbers',
|
||||
'hits',
|
||||
'rightCodes',
|
||||
'rightCode',
|
||||
'rightNumbers',
|
||||
'correctCodes',
|
||||
'correctCode',
|
||||
'correctNumbers',
|
||||
];
|
||||
const hitNumbers = getArticleCodeNumbers(item, fields);
|
||||
return hitNumbers.length ? hitNumbers : getCodeResultNumbers(item, true);
|
||||
};
|
||||
const getArticleMissedNumbers = (item) => {
|
||||
const fields = [
|
||||
'missCodes',
|
||||
'missCode',
|
||||
'missNumbers',
|
||||
'missedCodes',
|
||||
'missedCode',
|
||||
'missedNumbers',
|
||||
'wrongCodes',
|
||||
'wrongCode',
|
||||
'wrongNumbers',
|
||||
'errorCodes',
|
||||
'errorCode',
|
||||
'errorNumbers',
|
||||
];
|
||||
const missedNumbers = getArticleCodeNumbers(item, fields);
|
||||
return missedNumbers.length ? missedNumbers : getCodeResultNumbers(item, false);
|
||||
};
|
||||
const getCodeResultCorrectGroups = (item, recommendGroups) => {
|
||||
const codeResults = typeof ApiClient !== 'undefined' ? ApiClient.asArray(item && item.codeResults) : [];
|
||||
if (!codeResults.length || !recommendGroups || !recommendGroups.length) return [];
|
||||
const marks = codeResults.map((result) => {
|
||||
if (!result || typeof result !== 'object') return null;
|
||||
return result.correct === true ? true : result.correct === false ? false : null;
|
||||
});
|
||||
if (!marks.some((mark) => mark === true || mark === false)) return null;
|
||||
if (marks.length < flatCount) return null;
|
||||
|
||||
if (!marks.some((mark) => mark === true || mark === false)) return [];
|
||||
const recommendCount = recommendGroups.reduce((total, group) => total + group.length, 0);
|
||||
if (marks.length < recommendCount) return [];
|
||||
let offset = 0;
|
||||
return recommendGroups.map((group) => {
|
||||
const groupMarks = marks.slice(offset, offset + group.length);
|
||||
@@ -972,67 +1018,121 @@ const CommonUtil = {
|
||||
return groupMarks;
|
||||
});
|
||||
};
|
||||
const getPositionMarkerSets = (item, recommend) => {
|
||||
const recommendGroups = splitNumbers(recommend);
|
||||
if (!recommendGroups.length) return null;
|
||||
|
||||
const getCodeResultMarkerGroups = (item, correctValue) => {
|
||||
const codeResults = typeof ApiClient !== 'undefined' ? ApiClient.asArray(item && item.codeResults) : [];
|
||||
if (codeResults.length === recommendGroups.length) {
|
||||
return codeResults.map((result) => {
|
||||
if (result && typeof result === 'object' && result.correct !== false) {
|
||||
return new Set();
|
||||
}
|
||||
if (!codeResults.length) return [];
|
||||
return codeResults
|
||||
.map((result) => {
|
||||
if (Array.isArray(result)) return [];
|
||||
if (result && typeof result === 'object' && result.correct !== correctValue) return [];
|
||||
const value =
|
||||
result && typeof result === 'object'
|
||||
? result.code || result.value || result.number || result.result || ''
|
||||
: result;
|
||||
const values = splitNumbers(value).flat();
|
||||
return new Set(
|
||||
values.flatMap((num) => {
|
||||
const text = String(num);
|
||||
return [text, text.padStart(2, '0'), normalizeNumberKey(text)];
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
return String(value || '').trim() ? [String(value).trim()] : [];
|
||||
})
|
||||
.filter((group) => group.length > 0);
|
||||
};
|
||||
const getArticleHitMarkerGroups = (item, recommendGroups) => {
|
||||
if (!recommendGroups || !recommendGroups.length) return [];
|
||||
const hitNumbers = getArticleHitNumbers(item);
|
||||
if (hitNumbers.length === recommendGroups.length) return hitNumbers.map((num) => splitRecommendValues(num));
|
||||
const codeResultGroups = getCodeResultMarkerGroups(item, true);
|
||||
return codeResultGroups.length === recommendGroups.length ? codeResultGroups : [];
|
||||
};
|
||||
const getArticleMissedMarkerGroups = (item, recommendGroups) => {
|
||||
if (!recommendGroups || recommendGroups.length <= 1) return [];
|
||||
const missedNumbers = getArticleMissedNumbers(item);
|
||||
if (missedNumbers.length === recommendGroups.length) return missedNumbers.map((num) => splitRecommendValues(num));
|
||||
const codeResultGroups = getCodeResultMarkerGroups(item, false);
|
||||
return codeResultGroups.length === recommendGroups.length ? codeResultGroups : [];
|
||||
};
|
||||
const isWinStatusText = (value) => /全对|正确|命中|中奖|中/.test(String(value || ''));
|
||||
const isLoseStatusText = (value) => /全错|错误|错/.test(String(value || ''));
|
||||
const isArticleDrawn = (item, openCode) => {
|
||||
if (openCode && String(openCode).trim()) return true;
|
||||
const text = getExplicitStatusText(item);
|
||||
if (/正确|错误|已开奖|开奖号|开奖/.test(text) && !/未开奖|待开奖/.test(text)) return true;
|
||||
if (isWinStatusText(text) || isLoseStatusText(text)) return true;
|
||||
return Boolean(
|
||||
item &&
|
||||
(item.isDrawn === true ||
|
||||
item.drawn === true ||
|
||||
item.opened === true ||
|
||||
item.openStatus === 1 ||
|
||||
item.openStatus === '1' ||
|
||||
item.drawStatus === 1 ||
|
||||
item.drawStatus === '1')
|
||||
);
|
||||
};
|
||||
const isLatestArticle = (item, list) => {
|
||||
if (item && isTruthyFlag(item.isLatest)) return true;
|
||||
const currentId = getArticleId(item);
|
||||
const firstId = getArticleId(Array.isArray(list) ? list[0] : null);
|
||||
if (currentId && firstId) return String(currentId) === String(firstId);
|
||||
const currentIssue = Number(getArticleIssueValue(item));
|
||||
const issues = (Array.isArray(list) ? list : [])
|
||||
.map((row) => Number(getArticleIssueValue(row)))
|
||||
.filter((issue) => Number.isFinite(issue));
|
||||
return issues.length > 0 && Number.isFinite(currentIssue) && currentIssue === Math.max(...issues);
|
||||
};
|
||||
const isArticleMasked = (item, recommend) =>
|
||||
Boolean(
|
||||
item &&
|
||||
(item.masked === true ||
|
||||
item.masked === 1 ||
|
||||
item.masked === '1' ||
|
||||
item.masked === 'true' ||
|
||||
isMaskedRecommendText(recommend))
|
||||
);
|
||||
const canShowArticleRecommend = (item, isLatestIssue, hasDrawResult, unlockedByVisibleRecommend, recommend) => {
|
||||
if (!isArticleMasked(item, recommend)) return true;
|
||||
if (hasDrawResult) return true;
|
||||
if (!isLatestIssue) return true;
|
||||
return Boolean((ApiClient.getToken ? ApiClient.getToken() : this.getToken()) && (isPurchased(item) || unlockedByVisibleRecommend));
|
||||
};
|
||||
const shouldShowBuyButton = (item, isLatestIssue, hasDrawResult, purchased, recommend) =>
|
||||
Boolean(isLatestIssue && !hasDrawResult && isArticleMasked(item, recommend) && !purchased);
|
||||
const shouldShowPrePurchaseButton = (item, purchased) =>
|
||||
Boolean(
|
||||
!purchased &&
|
||||
!isArticlePrePurchased(item) &&
|
||||
(isArticlePrePurchase(item) || (!getArticleId(item) && getExplicitStatusText(item) === '待发布'))
|
||||
);
|
||||
const getRecommendLockedText = () =>
|
||||
ApiClient.getToken && ApiClient.getToken() ? '购买后可见' : '登录后购买可见';
|
||||
const applyRecommendHitOptions = (options, item, statusText) => {
|
||||
const recommendGroups = splitNumbers(getArticleRecommendValue(item));
|
||||
const codeResultGroupMarks = getCodeResultCorrectGroups(item, recommendGroups);
|
||||
const hitGroups = getArticleHitMarkerGroups(item, recommendGroups);
|
||||
const missedGroups = getArticleMissedMarkerGroups(item, recommendGroups);
|
||||
const hitNumbers = hitGroups.length ? hitGroups.flat() : getArticleHitNumbers(item);
|
||||
const missedNumbers = missedGroups.length ? missedGroups.flat() : getArticleMissedNumbers(item);
|
||||
const isFinalStatus = isWinStatusText(statusText) || isLoseStatusText(statusText);
|
||||
|
||||
const rawStatus = String(
|
||||
item.status ||
|
||||
item.resultText ||
|
||||
item.statusText ||
|
||||
item.drawStatusText ||
|
||||
item.openStatusText ||
|
||||
(typeof item.result === 'string' ? item.result : '')
|
||||
).trim();
|
||||
const resultValue = item.result ?? item.winStatus;
|
||||
const isMissResult =
|
||||
/全错|错误|未中|错/.test(rawStatus) ||
|
||||
resultValue === 0 ||
|
||||
resultValue === '0' ||
|
||||
resultValue === false;
|
||||
if (!isMissResult) return null;
|
||||
|
||||
const openGroups = splitNumbers(item.openCode || item.lotteryResult || item.resultCode || item.openResult || '');
|
||||
const openValues = openGroups.flat();
|
||||
if (openValues.length === recommendGroups.length) {
|
||||
return openValues.map((num) => {
|
||||
const text = String(num);
|
||||
return new Set([text, text.padStart(2, '0'), normalizeNumberKey(text)]);
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
options.codeResultMarks = codeResultGroupMarks.length ? codeResultGroupMarks : null;
|
||||
options.hitSet = codeResultGroupMarks.length || (hitNumbers.length > 0 && isFinalStatus) ? toNumberSet(hitNumbers) : new Set();
|
||||
options.hitGroupSets =
|
||||
hitGroups.length === recommendGroups.length ? hitGroups.map((group) => toNumberSet(group)) : null;
|
||||
options.wrongSet = !codeResultGroupMarks.length && missedNumbers.length > 0 && isFinalStatus ? toNumberSet(missedNumbers) : new Set();
|
||||
options.wrongGroupSets =
|
||||
!codeResultGroupMarks.length && missedGroups.length === recommendGroups.length
|
||||
? missedGroups.map((group) => toNumberSet(group))
|
||||
: null;
|
||||
return options;
|
||||
};
|
||||
const renderBalls = (value, options = {}) => {
|
||||
const groups = splitNumbers(value);
|
||||
if (!groups.length) return '<span class="cxz-number-empty">--</span>';
|
||||
const wrongSet = options.wrongSet || new Set();
|
||||
const hitSet = options.hitSet || new Set();
|
||||
const markerSets = options.markerSets || null;
|
||||
const markerSets = options.wrongGroupSets || null;
|
||||
const hitGroupSets = options.hitGroupSets || null;
|
||||
const codeResultMarks = options.codeResultMarks || null;
|
||||
const isRecommend = options.type === 'recommend';
|
||||
const isOpen = options.type === 'open';
|
||||
const count = groups.reduce((total, group) => total + group.length, 0);
|
||||
const groupSeparator = getRecommendGroupSeparator(value);
|
||||
const buildBody = (limit) => {
|
||||
let rendered = 0;
|
||||
return groups
|
||||
@@ -1046,6 +1146,7 @@ const CommonUtil = {
|
||||
const isTextToken = /[^\d]/.test(String(num));
|
||||
const normalized = String(num).padStart(2, '0');
|
||||
const markerSet = Array.isArray(markerSets) ? markerSets[groupIndex] : null;
|
||||
const hitGroupSet = Array.isArray(hitGroupSets) ? hitGroupSets[groupIndex] : null;
|
||||
const codeResultMark =
|
||||
Array.isArray(codeResultMarks) &&
|
||||
codeResultMarks[groupIndex] &&
|
||||
@@ -1053,7 +1154,9 @@ const CommonUtil = {
|
||||
? codeResultMarks[groupIndex][numberIndex]
|
||||
: null;
|
||||
const isExplicitHit =
|
||||
hitSet.has(normalized) || hitSet.has(String(num)) || hitSet.has(normalizeNumberKey(num));
|
||||
(hitGroupSet
|
||||
? hitGroupSet.has(normalized) || hitGroupSet.has(String(num)) || hitGroupSet.has(normalizeNumberKey(num))
|
||||
: hitSet.has(normalized) || hitSet.has(String(num)) || hitSet.has(normalizeNumberKey(num)));
|
||||
const isHit = codeResultMark === true || isExplicitHit;
|
||||
const isWrong = isHit
|
||||
? false
|
||||
@@ -1065,24 +1168,34 @@ const CommonUtil = {
|
||||
const isBlueGroup =
|
||||
(isOpen && groupIndex > 0) ||
|
||||
(Number.isInteger(options.blueStartGroupIndex) && groupIndex >= options.blueStartGroupIndex);
|
||||
const classes = [
|
||||
isTextToken ? 'cxz-number-text' : isBlueGroup ? 'bule-q' : 'red-q',
|
||||
isTextToken ? '' : 'cxz-number-ball',
|
||||
isWrong ? 'cxz-number-ball--wrong' : '',
|
||||
isHit ? 'cxz-number-ball--hit' : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
const classes = isRecommend
|
||||
? [
|
||||
'recommend-number-text',
|
||||
isBlueGroup ? 'recommend-number-blue' : '',
|
||||
isWrong ? 'recommend-number-missed' : '',
|
||||
isHit ? 'recommend-number-hit' : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
: [
|
||||
isTextToken ? 'cxz-number-text' : isBlueGroup ? 'bule-q' : 'red-q',
|
||||
isTextToken ? '' : 'cxz-number-ball',
|
||||
isWrong ? 'cxz-number-ball--wrong' : '',
|
||||
isHit ? 'cxz-number-ball--hit' : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
const title = isWrong ? '标记号码' : options.type === 'open' ? '开奖号码' : '推荐号码';
|
||||
return `<span class="${classes}" title="${title}">${escapeHtml(num)}</span>`;
|
||||
})
|
||||
.join('');
|
||||
.join(isRecommend ? '<span class="recommend-separator">,</span>' : '');
|
||||
return `<span class="cxz-number-group">${balls}</span>`;
|
||||
})
|
||||
.join('');
|
||||
.filter(Boolean)
|
||||
.join(isRecommend ? `<span class="recommend-separator">${escapeHtml(groupSeparator)}</span>` : '');
|
||||
};
|
||||
const fullBody = buildBody();
|
||||
const shortBody = buildBody(5);
|
||||
const shortBody = buildBody(4);
|
||||
const body = isRecommend ? fullBody : buildBody();
|
||||
const classes = [
|
||||
'cxz-number-wrap',
|
||||
@@ -1098,8 +1211,8 @@ const CommonUtil = {
|
||||
if (isRecommend && count > 4) {
|
||||
window.__cxzNumberPopups = window.__cxzNumberPopups || {};
|
||||
const popupId = `cxz-number-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
||||
window.__cxzNumberPopups[popupId] = `<div class="cxz-number-popup"><div class="cxz-number-popup-title">推荐号码 · 共${count}码</div><div class="cxz-number-wrap cxz-number-wrap--open cxz-number-wrap--popup">${fullBody}</div></div>`;
|
||||
meta += '<span class="cxz-number-more">查看更多</span>';
|
||||
window.__cxzNumberPopups[popupId] = `<div class="cxz-number-popup"><div class="cxz-number-popup-title">完整推荐号码 · 共${count}码</div><div class="cxz-number-wrap cxz-number-wrap--popup cxz-number-wrap--recommend-full">${fullBody}</div></div>`;
|
||||
meta += '<span class="cxz-number-more">点击查看全部</span>';
|
||||
return `<button type="button" class="${classes}" data-cxz-popup="${escapeHtml(popupId)}" onclick="if (this.classList.contains('cxz-number-wrap--overflow')) showCaiinfoNumbers('${escapeJs(popupId)}')"><span class="cxz-number-preview cxz-number-preview--full">${body}</span><span class="cxz-number-preview cxz-number-preview--short">${shortBody}</span>${meta}</button>`;
|
||||
}
|
||||
return `<div class="${classes}">${body}${meta}</div>`;
|
||||
@@ -1133,7 +1246,8 @@ const CommonUtil = {
|
||||
}
|
||||
alert($(content).text());
|
||||
};
|
||||
const getArticleId = (item) => item.id || item.articleId || item.payArticleId || item.latestArticleId || '';
|
||||
const getArticleId = (item) =>
|
||||
item.id || item.articleId || item.payArticleId || item.latestArticleId || item.contentId || item.recordId || '';
|
||||
const isCollected = (value) => value === 1 || value === 2 || value === true || value === '1' || value === '2';
|
||||
const isPurchased = (item) =>
|
||||
item.isBuy === 1 ||
|
||||
@@ -1346,7 +1460,7 @@ const CommonUtil = {
|
||||
return;
|
||||
}
|
||||
|
||||
list.forEach((item) => {
|
||||
list.forEach((item, index) => {
|
||||
const menuMeta = window.__cxzCaiinfoMenuMeta || {};
|
||||
const metaLottery = menuMeta.lottery || {};
|
||||
const metaPlay = menuMeta.current || {};
|
||||
@@ -1372,35 +1486,55 @@ const CommonUtil = {
|
||||
const openCode = item.openCode || item.lotteryResult || item.resultCode || item.openResult || '';
|
||||
const recommend = item.predictedCode || item.recommendCode || item.latestRecommend || item.recommend || '';
|
||||
const openRows = /快乐8|kl8/i.test(`${lotteryName}${currentCode}`) ? 2 : 1;
|
||||
const locked = isMasked(recommend);
|
||||
const canCopy = recommend && !locked;
|
||||
const status = getStatus(item, openCode, playName);
|
||||
const price = Number(item.price || item.amount || item.points || 0);
|
||||
const articleId = getArticleId(item);
|
||||
const blueStartGroupIndex = /大乐透|双色球|dlt|ssq/i.test(`${lotteryName}${currentCode}`) ? 1 : undefined;
|
||||
const unlockedByVisibleRecommend = !openCode && price > 0 && !locked && !!recommend;
|
||||
const hasDrawResult = isArticleDrawn(item, openCode);
|
||||
const isLatestIssue = isLatestArticle(item, list);
|
||||
const hasVisibleRecommend = Boolean(recommend && !isMaskedRecommendText(recommend));
|
||||
const unlockedByVisibleRecommend =
|
||||
isLatestIssue && !hasDrawResult && price > 0 && !isArticleMasked(item, recommend) && hasVisibleRecommend;
|
||||
const purchased = isPurchased(item) || unlockedByVisibleRecommend;
|
||||
const prePurchased = isArticlePrePurchased(item);
|
||||
const canShowRecommend = canShowArticleRecommend(
|
||||
item,
|
||||
isLatestIssue,
|
||||
hasDrawResult,
|
||||
unlockedByVisibleRecommend,
|
||||
recommend
|
||||
);
|
||||
const canCopy = canShowRecommend && hasVisibleRecommend;
|
||||
const collectText = isCollected(item.isCollect) ? '已收藏' : '收藏';
|
||||
const collectClass = isCollected(item.isCollect) ? ' collected' : '';
|
||||
const buyButton =
|
||||
locked && !openCode && !purchased && articleId
|
||||
? `<button class="cxz-btn-buy" onclick="openBuyDialog('${escapeJs(articleId)}')">购买</button> `
|
||||
: '';
|
||||
const purchasedBadge = purchased ? '<span class="cxz-purchased-badge">已购买</span> ' : '';
|
||||
const wrongSet = getWrongNumbers(item);
|
||||
const hitSet = getHitNumbers(item);
|
||||
const codeResultMarks = getCodeResultMarks(item, recommend);
|
||||
const markerSets = getPositionMarkerSets(item, recommend);
|
||||
const recommendHtml = locked
|
||||
? '<span class="cxz-recommend-locked">购买后可见</span>'
|
||||
: renderBalls(recommend, {
|
||||
type: 'recommend',
|
||||
wrongSet,
|
||||
hitSet,
|
||||
markerSets: codeResultMarks ? null : markerSets,
|
||||
codeResultMarks,
|
||||
blueStartGroupIndex,
|
||||
});
|
||||
let actionPrefix = '';
|
||||
if (prePurchased) {
|
||||
actionPrefix = '<span class="cxz-prebuy-badge">已预购</span> ';
|
||||
} else if (shouldShowPrePurchaseButton(item, purchased) && typeof window.openPrePurchaseDialog === 'function') {
|
||||
actionPrefix = `<button class="cxz-btn-buy" onclick="openPrePurchaseDialog(${index})">购买</button> `;
|
||||
} else if (shouldShowBuyButton(item, isLatestIssue, hasDrawResult, purchased, recommend) && articleId) {
|
||||
actionPrefix = `<button class="cxz-btn-buy" onclick="openBuyDialog('${escapeJs(articleId)}')">购买</button> `;
|
||||
} else if (purchased) {
|
||||
actionPrefix = '<span class="cxz-purchased-badge">已购买</span> ';
|
||||
}
|
||||
const recommendOptions = applyRecommendHitOptions(
|
||||
{
|
||||
type: 'recommend',
|
||||
blueStartGroupIndex,
|
||||
},
|
||||
item,
|
||||
status.text
|
||||
);
|
||||
let recommendHtml = '';
|
||||
if (String(recommend || '').trim() === '待发布') {
|
||||
recommendHtml = '<span class="cxz-recommend-locked">待发布</span>';
|
||||
} else if (canCopy) {
|
||||
recommendHtml = renderBalls(recommend, recommendOptions);
|
||||
} else if (recommend) {
|
||||
recommendHtml = `<span class="cxz-recommend-locked">${escapeHtml(getRecommendLockedText())}</span>`;
|
||||
} else {
|
||||
recommendHtml = '<span class="cxz-recommend-locked">暂无</span>';
|
||||
}
|
||||
const copyHtml = canCopy
|
||||
? `<button class="cxz-btn-copy" onclick="copyCode('${escapeJs(normalizeRecommend(recommend))}')">复制</button>`
|
||||
: '-';
|
||||
@@ -1409,13 +1543,13 @@ const CommonUtil = {
|
||||
`<tr>
|
||||
<td>${escapeHtml(nameText)}</td>
|
||||
<td>${escapeHtml(playName)}</td>
|
||||
<td>${escapeHtml(issue)}</td>
|
||||
<td>${escapeHtml(formatIssueText(issue))}</td>
|
||||
<td>${renderBalls(openCode, { type: 'open', openRows })}</td>
|
||||
<td>${recommendHtml}</td>
|
||||
<td>${copyHtml}</td>
|
||||
<td><span class="${status.className}">${status.html || escapeHtml(status.text)}</span></td>
|
||||
<td>${Number.isFinite(price) ? price.toFixed(2) : '0.00'}</td>
|
||||
<td>${purchasedBadge}${buyButton}<button class="cxz-btn-article-collect${collectClass}" data-id="${escapeHtml(articleId)}" onclick="toggleArticleCollect(this, '${escapeJs(articleId)}')">${collectText}</button></td>
|
||||
<td>${actionPrefix}<button class="cxz-btn-article-collect${collectClass}" data-id="${escapeHtml(articleId)}" onclick="toggleArticleCollect(this, '${escapeJs(articleId)}')">${collectText}</button></td>
|
||||
</tr>`
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user