推进活动系统最小成品闭环与游客体验
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import { loadBackendAuthTokens, loadBackendBaseUrl } from '../../utils/backendAuth'
|
||||
import { getEventPlay, type BackendEventPlayResult } from '../../utils/backendApi'
|
||||
import { getEventPlay, getPublicEventPlay, type BackendEventPlayResult } from '../../utils/backendApi'
|
||||
import { formatBackendPlayActionText, formatBackendPlayStatusText } from '../../utils/backendPlayCopy'
|
||||
import { reportBackendClientLog } from '../../utils/backendClientLogs'
|
||||
|
||||
type EventPageData = {
|
||||
eventId: string
|
||||
loading: boolean
|
||||
canLaunch: boolean
|
||||
titleText: string
|
||||
summaryText: string
|
||||
releaseText: string
|
||||
actionText: string
|
||||
statusText: string
|
||||
primaryButtonText: string
|
||||
variantModeText: string
|
||||
variantSummaryText: string
|
||||
presentationText: string
|
||||
@@ -78,11 +80,13 @@ Page({
|
||||
data: {
|
||||
eventId: '',
|
||||
loading: false,
|
||||
canLaunch: false,
|
||||
titleText: '活动详情',
|
||||
summaryText: '未加载',
|
||||
releaseText: '--',
|
||||
actionText: '--',
|
||||
statusText: '待加载',
|
||||
primaryButtonText: '前往准备页',
|
||||
variantModeText: '--',
|
||||
variantSummaryText: '--',
|
||||
presentationText: '--',
|
||||
@@ -104,10 +108,6 @@ Page({
|
||||
async loadEventPlay(eventId?: string) {
|
||||
const targetEventId = eventId || this.data.eventId
|
||||
const accessToken = getAccessToken()
|
||||
if (!accessToken) {
|
||||
wx.redirectTo({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({
|
||||
loading: true,
|
||||
@@ -115,11 +115,17 @@ Page({
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getEventPlay({
|
||||
baseUrl: loadBackendBaseUrl(),
|
||||
eventId: targetEventId,
|
||||
accessToken,
|
||||
})
|
||||
const baseUrl = loadBackendBaseUrl()
|
||||
const result = accessToken
|
||||
? await getEventPlay({
|
||||
baseUrl,
|
||||
eventId: targetEventId,
|
||||
accessToken,
|
||||
})
|
||||
: await getPublicEventPlay({
|
||||
baseUrl,
|
||||
eventId: targetEventId,
|
||||
})
|
||||
this.applyEventPlay(result)
|
||||
} catch (error) {
|
||||
const message = error && (error as { message?: string }).message ? (error as { message: string }).message : '未知错误'
|
||||
@@ -144,6 +150,7 @@ Page({
|
||||
? result.resolvedRelease.manifestUrl
|
||||
: '',
|
||||
details: {
|
||||
guestMode: !getAccessToken(),
|
||||
pageEventId: this.data.eventId || '',
|
||||
resultEventId: result.event.id || '',
|
||||
primaryAction: result.play.primaryAction || '',
|
||||
@@ -161,6 +168,7 @@ Page({
|
||||
})
|
||||
this.setData({
|
||||
loading: false,
|
||||
canLaunch: result.play.canLaunch,
|
||||
titleText: result.event.displayName,
|
||||
summaryText: result.event.summary || '暂无活动简介',
|
||||
releaseText: result.resolvedRelease
|
||||
@@ -168,6 +176,7 @@ Page({
|
||||
: '当前无可用 release',
|
||||
actionText: formatBackendPlayActionText(result.play.primaryAction, result.play.reason),
|
||||
statusText: formatBackendPlayStatusText(result.play.canLaunch, result.play.primaryAction, result.play.reason),
|
||||
primaryButtonText: result.play.canLaunch ? '前往准备页' : '查看准备状态',
|
||||
variantModeText: formatAssignmentMode(result.play.assignmentMode),
|
||||
variantSummaryText: formatVariantSummary(result),
|
||||
presentationText: formatPresentationSummary(result),
|
||||
|
||||
@@ -7,18 +7,23 @@
|
||||
</view>
|
||||
|
||||
<view class="panel">
|
||||
<view class="panel__title">开始前准备</view>
|
||||
<view class="summary">Release:{{releaseText}}</view>
|
||||
<view class="summary">主动作:{{actionText}}</view>
|
||||
<view class="summary">状态:{{statusText}}</view>
|
||||
<view class="panel__title">当前状态</view>
|
||||
<view class="status-chip {{canLaunch ? 'status-chip--ready' : 'status-chip--blocked'}}">{{statusText}}</view>
|
||||
<view class="summary">{{actionText}}</view>
|
||||
<view class="summary">你可以先进入准备页查看赛道、设备和局前状态,再决定是否进入地图。</view>
|
||||
<view class="actions">
|
||||
<button class="btn btn--secondary" bindtap="handleRefresh">刷新</button>
|
||||
<button class="btn btn--primary" bindtap="handleLaunch">{{primaryButtonText}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="panel">
|
||||
<view class="panel__title">赛道与版本</view>
|
||||
<view class="summary">当前发布版本:{{releaseText}}</view>
|
||||
<view class="summary">赛道模式:{{variantModeText}}</view>
|
||||
<view class="summary">赛道摘要:{{variantSummaryText}}</view>
|
||||
<view class="summary">当前发布展示版本:{{presentationText}}</view>
|
||||
<view class="summary">当前发布内容包版本:{{contentBundleText}}</view>
|
||||
<view class="actions">
|
||||
<button class="btn btn--secondary" bindtap="handleRefresh">刷新</button>
|
||||
<button class="btn btn--primary" bindtap="handleLaunch">前往准备页</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
@@ -61,6 +61,27 @@ page {
|
||||
color: #30465f;
|
||||
}
|
||||
|
||||
.status-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 52rpx;
|
||||
padding: 0 18rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.status-chip--ready {
|
||||
background: #ddf1e4;
|
||||
color: #1f6a3a;
|
||||
}
|
||||
|
||||
.status-chip--blocked {
|
||||
background: #f8e7e3;
|
||||
color: #8a3d28;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
|
||||
Reference in New Issue
Block a user