PageFamily.ts 977 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { _decorator, Component, Node } from "cc";
  2. import BaseUI from "../../scripts/base/BaseUI";
  3. import { ScrollView } from "cc";
  4. import EV, { EV_TYPE } from "../../scripts/mgr/EV";
  5. import UserM from "../../scripts/api/UserM";
  6. const { ccclass, property } = _decorator;
  7. @ccclass("PageFamily")
  8. export class PageFamily extends BaseUI {
  9. private _data: any = {
  10. name: "",
  11. notice: "",
  12. };
  13. private _scrollView: ScrollView;
  14. onLoad(): void {
  15. super.onLoad();
  16. EV.ins.on(
  17. EV_TYPE.FAMILY_STATUS_UPDATE,
  18. this.onFamilyStatusUpdate.bind(this),
  19. this
  20. );
  21. }
  22. private onFamilyStatusUpdate() {
  23. this.refresh();
  24. }
  25. public onShow(): void {
  26. this.refresh();
  27. }
  28. async refresh() {
  29. let hasFamily = UserM.ins.hasFamily();
  30. this.FindNode("FamilyPageHas").active = hasFamily;
  31. this.FindNode("FamilyPageNo").active = !hasFamily;
  32. if (hasFamily) {
  33. this.FindNode("FamilyPageHas").getComponent(BaseUI).onShow();
  34. }
  35. }
  36. }