diff --git a/pages/detail/detail.js b/pages/detail/detail.js index a2fb4f2..c87513b 100644 --- a/pages/detail/detail.js +++ b/pages/detail/detail.js @@ -34,6 +34,12 @@ var DEMO_PROJECT_TABLE_ROWS = [ { rowKey: 'fb-4', typeName: '团队', projectName: '成年组', groupName: '12', fee: '12' } ]; +var DEMO_PROJECT_LIMIT_TABLE_ROWS = [ + { rowKey: 'pl-1', projectName: '30秒单摇', groupName: '少年组', limitText: '2人/队' }, + { rowKey: 'pl-2', projectName: '2*30秒双摇接力', groupName: '少年组', limitText: '1人/队' }, + { rowKey: 'pl-3', projectName: '4*30秒交互绳接力', groupName: '青年组', limitText: '1人/队' } +]; + function isEmptyDisplayTime(s) { return s == null || String(s).trim() === '' || String(s).trim() === '-'; } @@ -200,6 +206,38 @@ function buildRegistrationLimitLines(detail, projects, registrationType) { return lines; } +function buildProjectLimitTableRows(projects) { + if (!Array.isArray(projects) || !projects.length) return []; + const rows = []; + projects.forEach((p, pi) => { + const projectName = p && (p.name || p.Name) ? (p.name || p.Name) : '-'; + const projectLimit = toNonNegInt(pick(p, ['projectLimitCount', 'ProjectLimitCount'])); + if (projectLimit == null) return; + + const rawGroups = Array.isArray(p.groups) ? p.groups : Array.isArray(p.Groups) ? p.Groups : []; + if (!rawGroups.length) { + rows.push({ + rowKey: `limit-${pi}-0`, + projectName, + groupName: '-', + limitText: `${projectLimit}人/队` + }); + return; + } + + rawGroups.forEach((g, gi) => { + const groupName = g && (g.groupName || g.GroupName || g.groupId || g.GroupId || '-'); + rows.push({ + rowKey: `limit-${pi}-${gi}`, + projectName, + groupName, + limitText: `${projectLimit}人/队` + }); + }); + }); + return rows; +} + function flattenProjectTableRows(projects, chargeMode) { if (!Array.isArray(projects)) return []; const rows = []; @@ -306,21 +344,25 @@ function normalizeEventDetail(raw) { 'RankingPoints' ]); let rankingPointsLines = []; + let rankingPointsTableRows = []; if (Array.isArray(rankingPointsRaw) && rankingPointsRaw.length && typeof rankingPointsRaw[0] === 'object') { - rankingPointsLines = rankingPointsRaw + rankingPointsTableRows = rankingPointsRaw .map((it) => { const sr = toNonNegInt(pick(it, ['startRank', 'StartRank'])); const er = toNonNegInt(pick(it, ['endRank', 'EndRank'])); const pts = toNonNegInt(pick(it, ['points', 'Points'])); - if (pts == null) return null; + if (pts == null || (sr == null && er == null)) return null; const a = sr != null ? sr : er; const b = er != null ? er : sr; - if (a == null && b == null) return `${pts}积分`; - if (a != null && b != null && a === b) return `${a} ${pts}积分`; - if (a != null && b != null) return `${a}--${b} ${pts}积分`; - return `${a != null ? a : b} ${pts}积分`; + const rankText = a != null && b != null && a !== b ? `${a}-${b}` : `${a != null ? a : b}`; + return { + rowKey: `rank-${rankText}-${pts}`, + rankText, + pointsText: `${pts}积分` + }; }) .filter(Boolean); + rankingPointsLines = rankingPointsTableRows.map((row) => `${row.rankText} ${row.pointsText}`); } else if (typeof rankingPointsRaw === 'string') { rankingPointsLines = splitLines(rankingPointsRaw); } else if (Array.isArray(rankingPointsRaw)) { @@ -329,6 +371,25 @@ function normalizeEventDetail(raw) { rankingPointsLines = [String(rankingPointsRaw)]; } + if (!rankingPointsTableRows.length && rankingPointsLines.length) { + rankingPointsTableRows = rankingPointsLines.map((line, idx) => { + const txt = String(line || '').trim(); + const m = txt.match(/(\d+(?:\s*[-~—]\s*\d+)?)\s*(.*)/); + if (!m) { + return { + rowKey: `rank-line-${idx}`, + rankText: txt || '-', + pointsText: '-' + }; + } + return { + rowKey: `rank-line-${idx}`, + rankText: (m[1] || '-').replace(/[~—]/g, '-').replace(/\s+/g, ''), + pointsText: (m[2] || '').trim() || '-' + }; + }); + } + const registrationLimitRaw = pick(d, [ 'registrationLimitText', 'RegistrationLimitText', @@ -352,6 +413,13 @@ function normalizeEventDetail(raw) { registrationLimitLines = buildRegistrationLimitLines(d, projects, registrationType); } + const individualProjectLimit = toNonNegInt(pick(d, ['individualProjectLimit', 'IndividualProjectLimit'])); + const teamProjectLimit = toNonNegInt(pick(d, ['teamProjectLimit', 'TeamProjectLimit'])); + const athleteLimitText = + `每位运动员可同时报名${individualProjectLimit != null ? individualProjectLimit : 'x'}个个人项目,` + + `${teamProjectLimit != null ? teamProjectLimit : 'x'}个团队项目`; + const projectLimitTableRows = buildProjectLimitTableRows(projects); + const participationPointsLabel = pick(d, ['participationPointsText', 'ParticipationPointsText']) || (participationPoints != null && participationPoints !== '' @@ -372,10 +440,13 @@ function normalizeEventDetail(raw) { refundRulesText, participationPointsLabel, rankingPointsLines, + rankingPointsTableRows, registrationLimitLines, + athleteLimitText, + projectLimitTableRows, introImage, hasNoticeBlock: Boolean(refundRulesText || participationPointsLabel || rankingPointsLines.length), - hasRegistrationLimit: registrationLimitLines.length > 0, + hasRegistrationLimit: registrationLimitLines.length > 0 || projectLimitTableRows.length > 0, chargeMode, projectTableRows: flattenProjectTableRows(projects, chargeMode) }; @@ -401,7 +472,10 @@ Page({ refundRulesText: '', participationPointsLabel: '', rankingPointsLines: [], + rankingPointsTableRows: [], registrationLimitLines: [], + athleteLimitText: '', + projectLimitTableRows: [], introImage: '', introductionText: '', uploadMaterialRemark: '', @@ -530,10 +604,22 @@ Page({ var participationPointsLabel = n.participationPointsLabel || fb.participationPointsLabel; var rankingPointsLines = n.rankingPointsLines && n.rankingPointsLines.length ? n.rankingPointsLines : fb.rankingPointsLines; + var rankingPointsTableRows = + n.rankingPointsTableRows && n.rankingPointsTableRows.length + ? n.rankingPointsTableRows + : [ + { rowKey: 'fb-rank-1', rankText: '1-8', pointsText: '15积分' }, + { rowKey: 'fb-rank-2', rankText: '9-20', pointsText: '10积分' } + ]; var registrationLimitLines = n.registrationLimitLines && n.registrationLimitLines.length ? n.registrationLimitLines : fb.registrationLimitLines; + var athleteLimitText = n.athleteLimitText || '每位运动员可同时报名x个个人项目,x个团队项目'; + var projectLimitTableRows = + n.projectLimitTableRows && n.projectLimitTableRows.length + ? n.projectLimitTableRows + : DEMO_PROJECT_LIMIT_TABLE_ROWS; var projectTableRows = n.projectTableRows && n.projectTableRows.length ? n.projectTableRows : DEMO_PROJECT_TABLE_ROWS; @@ -543,6 +629,9 @@ Page({ refundRulesText || participationPointsLabel || rankingPointsLines.length ); var hasRegistrationLimit = registrationLimitLines.length > 0; + if (projectLimitTableRows.length) { + hasRegistrationLimit = true; + } // 解析 units 数组,保持后端原始顺序并分组 const UNIT_TYPE_LABELS = ['主办单位', '承办单位', '协办单位', '赞助单位']; @@ -649,7 +738,10 @@ Page({ refundRulesText, participationPointsLabel, rankingPointsLines, + rankingPointsTableRows, registrationLimitLines, + athleteLimitText, + projectLimitTableRows, introImage: n.introImage || '', hasNoticeBlock, hasRegistrationLimit, diff --git a/pages/detail/detail.wxml b/pages/detail/detail.wxml index e7707bc..f4544ac 100644 --- a/pages/detail/detail.wxml +++ b/pages/detail/detail.wxml @@ -67,10 +67,19 @@ 参与积分: {{participationPointsLabel}} - + 名次积分: - - {{item}} + + + 名次 + 积分 + + + + {{item.rankText}} + {{item.pointsText}} + + @@ -91,9 +100,29 @@ 报名限制 - - ({{idx + 1}}) - {{item}} + + 1. + 运动员限报({{athleteLimitText}}) + + + 2. + + 项目限报(每个单位针对项目下的各组别可报名x个人/队) + + + 项目 + 组别 + 限报 + + + + {{item.projectName}} + {{item.groupName}} + {{item.limitText}} + + + + diff --git a/pages/detail/detail.wxss b/pages/detail/detail.wxss index 374c917..601e541 100644 --- a/pages/detail/detail.wxss +++ b/pages/detail/detail.wxss @@ -209,6 +209,15 @@ page { display: flex; } +.notice-ranking { + display: block; +} + +.notice-ranking .notice-strong { + display: block; + margin-bottom: 12rpx; +} + .notice-p:last-child, .notice-row:last-child, .notice-ranking:last-child { @@ -235,6 +244,25 @@ page { margin-top: 8rpx; } +.rank-table-wrap { + margin-top: 0; +} + +.table-head--light { + background: #e9f0ff; + color: #1a57b2; +} + +.th-rank, +.td-rank { + flex: 1; +} + +.th-points, +.td-points { + flex: 1; +} + .ranking-line { display: block; } @@ -317,6 +345,25 @@ page { flex: 1; } +.project-limit-table { + margin-top: 12rpx; +} + +.th-limit-proj, +.td-limit-proj { + flex: 1.2; +} + +.th-limit-group, +.td-limit-group { + flex: 1; +} + +.th-limit-count, +.td-limit-count { + flex: 0.9; +} + .table-wrap { overflow: hidden; border-radius: 16rpx;