feat: 添加挑战详情页面预制体,优化分享功能与数据展示
This commit is contained in:
@@ -131,6 +131,13 @@ export class PagePKData extends BaseView {
|
||||
this._setLabel(this._findLabelIn(item, 'RankNumberLabel'), firstParticipant ? `第 ${rankNumber} 名` : '暂无排名');
|
||||
this._loadAvatar(firstParticipant?.avatarUrl ?? '', this._findAvatarSprite(item), version);
|
||||
|
||||
const viewButton = this._findChild(item, 'ViewButton');
|
||||
if (viewButton) {
|
||||
const handler = () => this._openShareDetail(share);
|
||||
viewButton.on(Button.EventType.CLICK, handler, this);
|
||||
this._createdButtonBindings.push({ node: viewButton, handler });
|
||||
}
|
||||
|
||||
const shareButton = this._findChild(item, 'ShareButton');
|
||||
if (shareButton) {
|
||||
const handler = () => ShareManager.instance.triggerWxShare(share.title, share.shareCode);
|
||||
@@ -139,6 +146,24 @@ export class PagePKData extends BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
private _openShareDetail(share: CreatedShareItem): void {
|
||||
if (!share.shareCode) {
|
||||
ToastManager.instance.show('挑战数据异常,请稍后重试');
|
||||
return;
|
||||
}
|
||||
|
||||
ViewManager.instance.open('PagePKDetail', {
|
||||
params: {
|
||||
share,
|
||||
shareCode: share.shareCode,
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error('[PagePKData] 打开挑战详情失败:', err);
|
||||
ToastManager.instance.show('打开挑战详情失败,请稍后重试');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private _getFirstParticipant(share: CreatedShareItem): ShareParticipantRankSummary | null {
|
||||
return share.firstPlaceUser ?? share.topParticipant ?? share.firstParticipant ?? share.champion ?? null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user