推进活动系统最小成品闭环与游客体验
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),
|
||||
|
||||
Reference in New Issue
Block a user