FamilyPageNo.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { _decorator, Component, Node } from "cc";
  2. import BaseUI from "../../scripts/base/BaseUI";
  3. import { InputNameLayer } from "./InputNameLayer";
  4. import Utils from "../../scripts/utils/Utils";
  5. import { TipsLayer } from "../layer/TipsLayer";
  6. import AB from "../../scripts/base/AB";
  7. import { instantiate } from "cc";
  8. import EV, { EV_TYPE } from "../../scripts/mgr/EV";
  9. import { Tips } from "../../scripts/mgr/Tips";
  10. import UserM from "../../scripts/api/UserM";
  11. import ShareM from "../../scripts/mgr/ShareM";
  12. const { ccclass, property } = _decorator;
  13. @ccclass("FamilyPageNo")
  14. export class FamilyPageNo extends BaseUI {
  15. async createFamily() {
  16. let name = await InputNameLayer.show(10);
  17. console.log("name", name);
  18. if (name == null) {
  19. return;
  20. }
  21. let title = Utils.setI18nLabel("Family.CreateFamilySuccessTitle");
  22. let content = Utils.setI18nLabel("Family.CreateFamilySuccess", name);
  23. let familyOwner = UserM.ins.getUserName();
  24. let shareLink = await ShareM.ins.getFamilyShareLink(name, familyOwner);
  25. let success = await TipsLayer.forceConfirm(title, content, shareLink);
  26. if (success) {
  27. UserM.ins.setMockHasFamily(true);
  28. EV.ins.emit(EV_TYPE.FAMILY_STATUS_UPDATE);
  29. } else {
  30. console.log("cancel");
  31. }
  32. }
  33. async searchFamily() {
  34. let p = await AB.ins.loadPrefab("prefab/family/FamilyItem");
  35. let families_layout = this.FindNode("families_layout");
  36. families_layout.removeAllChildren();
  37. for (let index = 0; index < 10; index++) {
  38. let item = instantiate(p);
  39. item.active = true;
  40. item.parent = families_layout;
  41. }
  42. }
  43. protected simpleOnBtnClick(name: string): void {
  44. switch (name) {
  45. case "btn_search":
  46. this.searchFamily();
  47. break;
  48. case "btn_join_family":
  49. Tips.show("Coming Soon");
  50. break;
  51. case "btn_create_family":
  52. this.createFamily();
  53. break;
  54. }
  55. }
  56. }