|
|
|
|
@ -237,22 +237,55 @@ export class UIpageShop extends Auto_pageShop { |
|
|
|
|
|
|
|
|
|
/**显示章节礼包 */ |
|
|
|
|
showChapterBox() { |
|
|
|
|
let chapterGiftNode = find("chapterGift", this.ui_content); |
|
|
|
|
if (!chapterGiftNode) { |
|
|
|
|
chapterGiftNode = gg.res.getNode(GPath.UIPrefab, "chapterGift", GBundle.ChapterGiftBg) |
|
|
|
|
this.ui_content.addChild(chapterGiftNode); |
|
|
|
|
chapterGiftNode.setSiblingIndex(1); |
|
|
|
|
void this._showChapterBoxAsync(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async _showChapterBoxAsync(): Promise<void> { |
|
|
|
|
if (!this.ui_content?.isValid) return; |
|
|
|
|
let chapterGiftNode = find('chapterGift', this.ui_content); |
|
|
|
|
if (!chapterGiftNode?.isValid) { |
|
|
|
|
chapterGiftNode = await gg.res.getNodeAsync(GPath.UIPrefab, 'chapterGift', GBundle.ChapterGiftBg); |
|
|
|
|
if (!chapterGiftNode?.isValid || !this.ui_content?.isValid) { |
|
|
|
|
console.warn('[UIpageShop] chapterGift 加载失败'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 异步期间可能已挂上同名节点,避免重复
|
|
|
|
|
const existed = find('chapterGift', this.ui_content); |
|
|
|
|
if (existed?.isValid) { |
|
|
|
|
gg.res.putNode(chapterGiftNode); |
|
|
|
|
chapterGiftNode = existed; |
|
|
|
|
} else { |
|
|
|
|
this.ui_content.addChild(chapterGiftNode); |
|
|
|
|
chapterGiftNode.setSiblingIndex(1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
chapterGiftNode.active = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showDiamondShop() { |
|
|
|
|
let diamondShopNode = find("diamondShop", this.ui_content); |
|
|
|
|
if (!diamondShopNode) { |
|
|
|
|
diamondShopNode = gg.res.getNode(GPath.UIPrefab, "diamondShop", GBundle.DiamondShop) |
|
|
|
|
this.ui_content.addChild(diamondShopNode); |
|
|
|
|
let index = find("BoxNodes", this.ui_content).getSiblingIndex(); |
|
|
|
|
diamondShopNode.setSiblingIndex(index + 1); |
|
|
|
|
void this._showDiamondShopAsync(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async _showDiamondShopAsync(): Promise<void> { |
|
|
|
|
if (!this.ui_content?.isValid) return; |
|
|
|
|
let diamondShopNode = find('diamondShop', this.ui_content); |
|
|
|
|
if (!diamondShopNode?.isValid) { |
|
|
|
|
diamondShopNode = await gg.res.getNodeAsync(GPath.UIPrefab, 'diamondShop', GBundle.DiamondShop); |
|
|
|
|
if (!diamondShopNode?.isValid || !this.ui_content?.isValid) { |
|
|
|
|
console.warn('[UIpageShop] diamondShop 加载失败'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const existed = find('diamondShop', this.ui_content); |
|
|
|
|
if (existed?.isValid) { |
|
|
|
|
gg.res.putNode(diamondShopNode); |
|
|
|
|
diamondShopNode = existed; |
|
|
|
|
} else { |
|
|
|
|
this.ui_content.addChild(diamondShopNode); |
|
|
|
|
const boxNodes = find('BoxNodes', this.ui_content); |
|
|
|
|
if (boxNodes) { |
|
|
|
|
diamondShopNode.setSiblingIndex(boxNodes.getSiblingIndex() + 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
diamondShopNode.active = true; |
|
|
|
|
} |
|
|
|
|
|