UIInvite.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { AppKernel } from '@scripts/app/AppKernel';
  2. import VirtualList from '@scripts/components/virtualList/VirtualList';
  3. import { UIViewID } from '@scripts/define/UIDefine';
  4. import { UIPopup } from '@scripts/framework/ui/UIPopup';
  5. import { addBtnClick, addTogClick } from '@scripts/utils/UIHelper';
  6. import { _decorator, Component, Label, Node, Toggle } from 'cc';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('UIInvite')
  9. export class UIInvite extends UIPopup {
  10. readonly viewId: UIViewID = UIViewID.UIInvite;
  11. @property(Node)
  12. btnClose: Node;
  13. @property([Toggle])
  14. subToggles: Toggle[] = [];
  15. @property([Node])
  16. subViews: Node[] = [];
  17. @property(VirtualList)
  18. recordList: VirtualList;
  19. @property(Label)
  20. lblCode: Label;
  21. @property(Label)
  22. lblLink: Label;
  23. @property(Node)
  24. btnBind: Node;
  25. @property(Node)
  26. btnSpin: Node;
  27. @property(Label)
  28. lblBtnSpin: Label;
  29. @property(Node)
  30. btnCopy: Node;
  31. @property(Node)
  32. btnShare: Node;
  33. private _subViewID = -1;
  34. protected onCreate(): void | Promise<void> {
  35. addBtnClick(this.btnClose, this.closeSelf, this);
  36. addBtnClick(this.btnBind, this.onBtnBindClick, this);
  37. addBtnClick(this.btnSpin, this.onBtnSpinClick, this);
  38. this.recordList.renderEvent.target = this.node;
  39. this.recordList.renderEvent.component = "UIInvite";
  40. this.recordList.renderEvent.handler = "renderRecordItem";
  41. this.subToggles.forEach((tog, idx) => {
  42. addTogClick(tog, (t) => { this.onTogClick(t, idx) });
  43. })
  44. }
  45. private onBtnBindClick() {
  46. AppKernel.ui.open(UIViewID.UIInviteBind);
  47. }
  48. private onBtnSpinClick() {
  49. AppKernel.ui.open(UIViewID.UIInviteSpin);
  50. }
  51. private onTogClick(tog: Toggle, index: number) {
  52. if (this._subViewID === index) return;
  53. this.updateSubView(index);
  54. }
  55. private updateSubView(index: number) {
  56. this._subViewID = index;
  57. this.subViews.forEach((view, idx) => view.active = idx === index);
  58. }
  59. protected onOpen(_params: unknown) {
  60. this.subToggles[0].isChecked = true;
  61. this.updateSubView(0);
  62. }
  63. renderRecordItem(item: Node, index: number) {
  64. }
  65. }