feat: 更新版权接口与彩票列表展示
This commit is contained in:
+56
-2
@@ -178,6 +178,51 @@
|
||||
let currentPage = 1;
|
||||
let menuData = [];
|
||||
let currentLottery = null;
|
||||
// 付费文章专家展示上限:未列出的彩种/玩法保持接口返回的完整分页。
|
||||
const paidExpertDisplayLimits = [
|
||||
{ lotteries: ["fc3d", "福彩3d"], plays: ["独胆"], total: 10 },
|
||||
{
|
||||
lotteries: ["fc3d", "福彩3d"],
|
||||
plays: ["杀1码", "杀码"],
|
||||
total: 20,
|
||||
},
|
||||
{ lotteries: ["pl3", "排列三"], plays: ["独胆"], total: 10 },
|
||||
{
|
||||
lotteries: ["pl3", "排列三"],
|
||||
plays: ["杀1码", "杀码"],
|
||||
total: 20,
|
||||
},
|
||||
{
|
||||
lotteries: ["ssq", "双色球"],
|
||||
plays: ["1码定胆", "一码定胆"],
|
||||
total: 10,
|
||||
},
|
||||
{ lotteries: ["qlc", "七乐彩"], plays: ["独胆"], total: 20 },
|
||||
];
|
||||
|
||||
function normalizeDisplayLimitKey(value) {
|
||||
return String(value || "").replace(/\s/g, "").toLowerCase();
|
||||
}
|
||||
|
||||
function getPaidExpertDisplayLimit(playName) {
|
||||
const lotteryKeys = [
|
||||
currentLottery && currentLottery.code,
|
||||
currentLottery && currentLottery.suoxie,
|
||||
currentLottery && currentLottery.name,
|
||||
currentCode,
|
||||
].map(normalizeDisplayLimitKey);
|
||||
const playKey = normalizeDisplayLimitKey(playName);
|
||||
const matchedLimit = paidExpertDisplayLimits.find((item) => {
|
||||
const lotteryMatched = item.lotteries.some((lottery) =>
|
||||
lotteryKeys.includes(normalizeDisplayLimitKey(lottery)),
|
||||
);
|
||||
const playMatched = item.plays.some(
|
||||
(name) => playKey === normalizeDisplayLimitKey(name),
|
||||
);
|
||||
return lotteryMatched && playMatched;
|
||||
});
|
||||
return matchedLimit ? matchedLimit.total : null;
|
||||
}
|
||||
|
||||
// Login status
|
||||
function logout() {
|
||||
@@ -523,6 +568,11 @@
|
||||
return;
|
||||
}
|
||||
currentTypeId = typeId;
|
||||
const displayLimit = getPaidExpertDisplayLimit(getCurrentTypeName());
|
||||
const maxPage = displayLimit
|
||||
? Math.ceil(displayLimit / currentRowPageSize)
|
||||
: Infinity;
|
||||
currentPage = Math.min(Math.max(1, Number(currentPage) || 1), maxPage);
|
||||
ApiClient.get(ApiClient.API.payArticleExpertRank, {
|
||||
menuId: typeId,
|
||||
issueCount: currentPageSize,
|
||||
@@ -532,8 +582,12 @@
|
||||
if (ApiClient.isSuccess(res) && ApiClient.pickData(res, null)) {
|
||||
const data = ApiClient.pickData(res, {}) || {};
|
||||
const list = data.records || data.rows || ApiClient.asArray(data);
|
||||
renderArticles(list);
|
||||
renderPagination(data.totalRow || data.total || data.count || list.length || 0);
|
||||
const total = data.totalRow || data.total || data.count || list.length || 0;
|
||||
const visibleTotal = displayLimit
|
||||
? Math.min(total, displayLimit)
|
||||
: total;
|
||||
renderArticles(ApiClient.asArray(list).slice(0, currentRowPageSize));
|
||||
renderPagination(visibleTotal);
|
||||
} else {
|
||||
$("#articleBody").html(
|
||||
'<tr><td colspan="5" style="text-align:center;color:var(--text-muted);padding:40px;">暂无数据</td></tr>',
|
||||
|
||||
+5
-1
@@ -319,13 +319,17 @@
|
||||
ApiClient.get(ApiClient.API.webConfig).catch(function () {
|
||||
return { data: {} };
|
||||
}),
|
||||
ApiClient.get(ApiClient.API.configCopyright).catch(function () {
|
||||
return { data: [] };
|
||||
}),
|
||||
ApiClient.get(ApiClient.API.configSite).catch(function () {
|
||||
return { data: {} };
|
||||
}),
|
||||
]).then(function (results) {
|
||||
if (!CommonUtil.applyWebConfigs) return;
|
||||
CommonUtil.applyWebConfigs(ApiClient.pickData(results[0], {}) || {});
|
||||
CommonUtil.applyWebConfigs(ApiClient.pickData(results[1], {}) || {});
|
||||
CommonUtil.applyCopyrightConfigs(ApiClient.pickData(results[1], []) || []);
|
||||
CommonUtil.applyWebConfigs(ApiClient.pickData(results[2], {}) || {});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -34,6 +34,7 @@ const ApiClient = {
|
||||
webConfig: '/api/web/config',
|
||||
configList: '/api/web/config/list',
|
||||
configSite: '/api/web/config/site',
|
||||
configCopyright: '/api/web/config/copyright',
|
||||
bannerList: '/api/web/banner/list',
|
||||
adList: '/api/web/ad/list',
|
||||
freeArticleRecommend: '/api/web/free-article/recommend',
|
||||
@@ -911,9 +912,10 @@ const ApiClient = {
|
||||
},
|
||||
|
||||
async loadHomeIndexCompat() {
|
||||
const [configList, config, siteConfig, menus, banners, notices, ads, freeArticles, links, latest] = await Promise.all([
|
||||
const [configList, config, copyright, siteConfig, menus, banners, notices, ads, freeArticles, links, latest] = await Promise.all([
|
||||
this.get('/api/web/config/list').catch(() => ({ data: [] })),
|
||||
this.get('/api/web/config').catch(() => ({ data: {} })),
|
||||
this.get(this.API.configCopyright).catch(() => ({ data: [] })),
|
||||
this.get('/api/web/config/site').catch(() => ({ data: {} })),
|
||||
this.loadHomeMenusCompat().catch(() => ({ data: [] })),
|
||||
this.get('/api/web/banner/list').catch(() => ({ data: [] })),
|
||||
@@ -977,6 +979,7 @@ const ApiClient = {
|
||||
webConfigs: this.asArray(this.pickData(configList, [])).length
|
||||
? this.asArray(this.pickData(configList, []))
|
||||
: this.configObjectToList(config.data || {}),
|
||||
copyrightConfigs: this.asArray(this.pickData(copyright, [])),
|
||||
siteConfig: siteConfig.data || {},
|
||||
menuList,
|
||||
navList: menuList,
|
||||
|
||||
+19
-6
@@ -725,7 +725,6 @@ const CommonUtil = {
|
||||
sort: item.sort === undefined || item.sort === null ? index : Number(item.sort),
|
||||
}));
|
||||
|
||||
const copyrightItems = [];
|
||||
const footerContactItems = [];
|
||||
configs.forEach((item) => {
|
||||
const isFooterContact = this.isFooterContactConfig(item);
|
||||
@@ -740,15 +739,24 @@ const CommonUtil = {
|
||||
this.setMeta('description', item.content || '');
|
||||
} else if (item.type === 'web_icon') {
|
||||
this.setIcon(item.content || '');
|
||||
} else if (item.type === 'web_copyright' && !isFooterContact) {
|
||||
copyrightItems.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
this.applyFooterCopyright(copyrightItems);
|
||||
this.renderFooterContact(footerContactItems);
|
||||
},
|
||||
|
||||
applyCopyrightConfigs(configs) {
|
||||
const copyrightItems = this.asArray(configs)
|
||||
.filter((item) => item && (item.content || item.value) && item.isEnabled !== '0' && item.isEnabled !== 0 && item.isEnabled !== false)
|
||||
.map((item, index) => ({
|
||||
...item,
|
||||
content: item.content || item.value || '',
|
||||
sort: item.sort === undefined || item.sort === null ? index : Number(item.sort),
|
||||
}));
|
||||
|
||||
this.applyFooterCopyright(copyrightItems);
|
||||
},
|
||||
|
||||
ensureGlobalFooterLayout() {
|
||||
if (typeof document === 'undefined') return;
|
||||
const $ = this.$;
|
||||
@@ -1098,6 +1106,7 @@ const CommonUtil = {
|
||||
else if (data.siteConfig) this.applyWebConfigs(data.siteConfig);
|
||||
else if (data.config) this.applyWebConfigs(data.config);
|
||||
else if (result.data) this.applyWebConfigs(result.data);
|
||||
this.applyCopyrightConfigs(data.copyrightConfigs);
|
||||
|
||||
if (!loadHomeData && options.ads !== false && data.adList) {
|
||||
this.processAndRenderAds(data.adList, options.adPositions);
|
||||
@@ -2161,9 +2170,10 @@ const CommonUtil = {
|
||||
},
|
||||
|
||||
async loadBasePageData(options = {}) {
|
||||
const [configList, config, siteConfig, ads] = await Promise.all([
|
||||
const [configList, config, copyright, siteConfig, ads] = await Promise.all([
|
||||
ApiClient.get('/api/web/config/list').catch(() => ({ data: [] })),
|
||||
ApiClient.get('/api/web/config').catch(() => ({ data: {} })),
|
||||
ApiClient.get(ApiClient.API.configCopyright).catch(() => ({ data: [] })),
|
||||
ApiClient.get('/api/web/config/site').catch(() => ({ data: {} })),
|
||||
options.ads === false
|
||||
? Promise.resolve({ data: [] })
|
||||
@@ -2181,6 +2191,7 @@ const CommonUtil = {
|
||||
: ApiClient.configObjectToList
|
||||
? ApiClient.configObjectToList(config.data || {})
|
||||
: config.data || {},
|
||||
copyrightConfigs: this.asArray(this.pickData(copyright, [])),
|
||||
adList: this.asArray(this.pickData(ads, [])),
|
||||
},
|
||||
};
|
||||
@@ -2191,10 +2202,11 @@ const CommonUtil = {
|
||||
return ApiClient.loadHomeIndexCompat();
|
||||
}
|
||||
|
||||
const [configList, config, siteConfig, menus, banners, notices, ads, freeArticles, latest] =
|
||||
const [configList, config, copyright, siteConfig, menus, banners, notices, ads, freeArticles, latest] =
|
||||
await Promise.all([
|
||||
ApiClient.get('/api/web/config/list').catch(() => ({ data: [] })),
|
||||
ApiClient.get('/api/web/config').catch(() => ({ data: {} })),
|
||||
ApiClient.get(ApiClient.API.configCopyright).catch(() => ({ data: [] })),
|
||||
ApiClient.get('/api/web/config/site').catch(() => ({ data: {} })),
|
||||
ApiClient.get('/api/web/menu/home-nav').catch(() => ({ data: [] })),
|
||||
ApiClient.get('/api/web/banner/list').catch(() => ({ data: [] })),
|
||||
@@ -2266,6 +2278,7 @@ const CommonUtil = {
|
||||
: ApiClient.configObjectToList
|
||||
? ApiClient.configObjectToList(config.data || {})
|
||||
: config.data || {},
|
||||
copyrightConfigs: this.asArray(this.pickData(copyright, [])),
|
||||
siteConfig: siteConfig.data || {},
|
||||
bannerList: this.asArray(this.pickData(banners, [])),
|
||||
noticeList: this.asArray(this.pickData(notices, [])),
|
||||
|
||||
Reference in New Issue
Block a user