update:限报&积分
This commit is contained in:
parent
67457daef6
commit
14bd9c29f3
@ -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,
|
||||
|
||||
@ -67,10 +67,19 @@
|
||||
<text class="notice-strong">参与积分:</text>
|
||||
<text class="notice-text">{{participationPointsLabel}}</text>
|
||||
</view>
|
||||
<view class="notice-ranking" wx:if="{{rankingPointsLines.length}}">
|
||||
<view class="notice-ranking" wx:if="{{rankingPointsTableRows.length}}">
|
||||
<text class="notice-strong">名次积分:</text>
|
||||
<view class="ranking-lines">
|
||||
<text class="notice-text ranking-line" wx:for="{{rankingPointsLines}}" wx:for-index="ri" wx:key="ri">{{item}}</text>
|
||||
<view class="table-wrap rank-table-wrap">
|
||||
<view class="table-head table-head--light">
|
||||
<text class="th th-rank">名次</text>
|
||||
<text class="th th-points">积分</text>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view class="tr" wx:for="{{rankingPointsTableRows}}" wx:key="rowKey">
|
||||
<text class="td td-rank">{{item.rankText}}</text>
|
||||
<text class="td td-points">{{item.pointsText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -91,9 +100,29 @@
|
||||
<text class="card-head-title">报名限制</text>
|
||||
</view>
|
||||
<view class="limit-list">
|
||||
<view class="limit-item" wx:for="{{registrationLimitLines}}" wx:for-index="idx" wx:key="idx">
|
||||
<text class="limit-num">({{idx + 1}})</text>
|
||||
<text class="limit-text">{{item}}</text>
|
||||
<view class="limit-item">
|
||||
<text class="limit-num">1.</text>
|
||||
<text class="limit-text">运动员限报({{athleteLimitText}})</text>
|
||||
</view>
|
||||
<view class="limit-item">
|
||||
<text class="limit-num">2.</text>
|
||||
<view class="limit-text">
|
||||
<text class="limit-text">项目限报(每个单位针对项目下的各组别可报名x个人/队)</text>
|
||||
<view class="table-wrap project-limit-table" wx:if="{{projectLimitTableRows.length}}">
|
||||
<view class="table-head table-head--light">
|
||||
<text class="th th-limit-proj">项目</text>
|
||||
<text class="th th-limit-group">组别</text>
|
||||
<text class="th th-limit-count">限报</text>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view class="tr" wx:for="{{projectLimitTableRows}}" wx:key="rowKey">
|
||||
<text class="td td-limit-proj">{{item.projectName}}</text>
|
||||
<text class="td td-limit-group">{{item.groupName}}</text>
|
||||
<text class="td td-limit-count">{{item.limitText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user