完善活动运营域与联调标准化
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { loadBackendAuthTokens, loadBackendBaseUrl } from '../../utils/backendAuth'
|
||||
import { getSessionResult } from '../../utils/backendApi'
|
||||
import type { MapEngineResultSnapshot } from '../../engine/map/mapEngine'
|
||||
import type { GameLaunchEnvelope } from '../../utils/gameLaunch'
|
||||
|
||||
type ResultPageData = {
|
||||
sessionId: string
|
||||
@@ -41,6 +42,56 @@ function formatRouteSummary(input: {
|
||||
return '默认赛道'
|
||||
}
|
||||
|
||||
function formatRuntimeValue(...candidates: Array<string | null | undefined>): string {
|
||||
for (let index = 0; index < candidates.length; index += 1) {
|
||||
const value = candidates[index]
|
||||
if (typeof value === 'string' && value.trim().length > 0) {
|
||||
return value.trim()
|
||||
}
|
||||
}
|
||||
return '--'
|
||||
}
|
||||
|
||||
function appendRuntimeRows(
|
||||
rows: Array<{ label: string; value: string }>,
|
||||
options: {
|
||||
runtime?: {
|
||||
runtimeBindingId?: string | null
|
||||
placeId?: string | null
|
||||
placeName?: string | null
|
||||
mapId?: string | null
|
||||
mapName?: string | null
|
||||
tileReleaseId?: string | null
|
||||
courseSetId?: string | null
|
||||
courseVariantId?: string | null
|
||||
routeCode?: string | null
|
||||
} | null
|
||||
variantName?: string | null
|
||||
routeCode?: string | null
|
||||
},
|
||||
) {
|
||||
if (!options.runtime) {
|
||||
return rows
|
||||
}
|
||||
|
||||
return rows.concat([
|
||||
{ label: '运行绑定', value: formatRuntimeValue(options.runtime.runtimeBindingId) },
|
||||
{ label: '地点', value: formatRuntimeValue(options.runtime.placeName, options.runtime.placeId) },
|
||||
{ label: '地图', value: formatRuntimeValue(options.runtime.mapName, options.runtime.mapId) },
|
||||
{ label: '赛道集', value: formatRuntimeValue(options.runtime.courseSetId) },
|
||||
{ label: '赛道版本', value: formatRuntimeValue(options.runtime.courseVariantId, options.variantName) },
|
||||
{ label: 'RouteCode', value: formatRuntimeValue(options.runtime.routeCode, options.routeCode) },
|
||||
{ label: '瓦片版本', value: formatRuntimeValue(options.runtime.tileReleaseId) },
|
||||
])
|
||||
}
|
||||
|
||||
function loadPendingResultLaunchEnvelope(): GameLaunchEnvelope | null {
|
||||
const app = getApp<IAppOption>()
|
||||
return app.globalData && app.globalData.pendingResultLaunchEnvelope
|
||||
? app.globalData.pendingResultLaunchEnvelope
|
||||
: null
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
sessionId: '',
|
||||
@@ -75,17 +126,22 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
const pendingLaunchEnvelope = loadPendingResultLaunchEnvelope()
|
||||
this.setData({
|
||||
statusText: '正在加载结果',
|
||||
sessionTitleText: snapshot.title,
|
||||
sessionSubtitleText: snapshot.subtitle,
|
||||
rows: [
|
||||
rows: appendRuntimeRows([
|
||||
{ label: snapshot.heroLabel, value: snapshot.heroValue },
|
||||
...snapshot.rows.map((row) => ({
|
||||
label: row.label,
|
||||
value: row.value,
|
||||
})),
|
||||
],
|
||||
], {
|
||||
runtime: pendingLaunchEnvelope && pendingLaunchEnvelope.runtime ? pendingLaunchEnvelope.runtime : null,
|
||||
variantName: pendingLaunchEnvelope && pendingLaunchEnvelope.variant ? pendingLaunchEnvelope.variant.variantName : null,
|
||||
routeCode: pendingLaunchEnvelope && pendingLaunchEnvelope.variant ? pendingLaunchEnvelope.variant.routeCode : null,
|
||||
}),
|
||||
})
|
||||
|
||||
if (app.globalData) {
|
||||
@@ -110,11 +166,12 @@ Page({
|
||||
accessToken,
|
||||
sessionId,
|
||||
})
|
||||
const pendingLaunchEnvelope = loadPendingResultLaunchEnvelope()
|
||||
this.setData({
|
||||
statusText: '单局结果加载完成',
|
||||
sessionTitleText: result.session.eventName || result.session.eventDisplayName || result.session.eventId || result.session.id || result.session.sessionId,
|
||||
sessionSubtitleText: `${result.session.status || result.session.sessionStatus} / ${result.result.status} / ${formatRouteSummary(result.session)}`,
|
||||
rows: [
|
||||
rows: appendRuntimeRows([
|
||||
{ label: '赛道版本', value: formatRouteSummary(result.session) },
|
||||
{ label: '最终得分', value: formatValue(result.result.finalScore) },
|
||||
{ label: '最终用时(秒)', value: formatValue(result.result.finalDurationSec) },
|
||||
@@ -123,8 +180,16 @@ Page({
|
||||
{ label: '累计里程(m)', value: formatValue(result.result.distanceMeters) },
|
||||
{ label: '平均速度(km/h)', value: formatValue(result.result.averageSpeedKmh) },
|
||||
{ label: '最大心率', value: formatValue(result.result.maxHeartRateBpm) },
|
||||
],
|
||||
], {
|
||||
runtime: result.session.runtime || (pendingLaunchEnvelope && pendingLaunchEnvelope.runtime ? pendingLaunchEnvelope.runtime : null),
|
||||
variantName: result.session.variantName || (pendingLaunchEnvelope && pendingLaunchEnvelope.variant ? pendingLaunchEnvelope.variant.variantName : null),
|
||||
routeCode: result.session.routeCode || (pendingLaunchEnvelope && pendingLaunchEnvelope.variant ? pendingLaunchEnvelope.variant.routeCode : null),
|
||||
}),
|
||||
})
|
||||
const app = getApp<IAppOption>()
|
||||
if (app.globalData) {
|
||||
app.globalData.pendingResultLaunchEnvelope = null
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error && (error as { message?: string }).message ? (error as { message: string }).message : '未知错误'
|
||||
this.setData({
|
||||
|
||||
Reference in New Issue
Block a user