import { AppKernel } from '@scripts/app/AppKernel'; import VirtualList from '@scripts/components/virtualList/VirtualList'; import { UIViewID } from '@scripts/define/UIDefine'; import { UIPopup } from '@scripts/framework/ui/UIPopup'; import { addBtnClick, addTogClick } from '@scripts/utils/UIHelper'; import { _decorator, Component, Label, Node, Toggle } from 'cc'; const { ccclass, property } = _decorator; @ccclass('UIInvite') export class UIInvite extends UIPopup { readonly viewId: UIViewID = UIViewID.UIInvite; @property(Node) btnClose: Node; @property([Toggle]) subToggles: Toggle[] = []; @property([Node]) subViews: Node[] = []; @property(VirtualList) recordList: VirtualList; @property(Label) lblCode: Label; @property(Label) lblLink: Label; @property(Node) btnBind: Node; @property(Node) btnSpin: Node; @property(Label) lblBtnSpin: Label; @property(Node) btnCopy: Node; @property(Node) btnShare: Node; private _subViewID = -1; protected onCreate(): void | Promise { addBtnClick(this.btnClose, this.closeSelf, this); addBtnClick(this.btnBind, this.onBtnBindClick, this); addBtnClick(this.btnSpin, this.onBtnSpinClick, this); this.recordList.renderEvent.target = this.node; this.recordList.renderEvent.component = "UIInvite"; this.recordList.renderEvent.handler = "renderRecordItem"; this.subToggles.forEach((tog, idx) => { addTogClick(tog, (t) => { this.onTogClick(t, idx) }); }) } private onBtnBindClick() { AppKernel.ui.open(UIViewID.UIInviteBind); } private onBtnSpinClick() { AppKernel.ui.open(UIViewID.UIInviteSpin); } private onTogClick(tog: Toggle, index: number) { if (this._subViewID === index) return; this.updateSubView(index); } private updateSubView(index: number) { this._subViewID = index; this.subViews.forEach((view, idx) => view.active = idx === index); } protected onOpen(_params: unknown) { this.subToggles[0].isChecked = true; this.updateSubView(0); } renderRecordItem(item: Node, index: number) { } }