ManagePlayerItem.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { _decorator, Component, Node } from "cc";
  2. import BaseUI from "../../scripts/base/BaseUI";
  3. import { Tips } from "../../scripts/mgr/Tips";
  4. import { TipsData, TipsLayer } from "../layer/TipsLayer";
  5. import Utils from "../../scripts/utils/Utils";
  6. const { ccclass, property } = _decorator;
  7. export enum ManagePlayerItemType {
  8. APPROVE = 0,
  9. MEMBERS = 1,
  10. }
  11. @ccclass("ManagePlayerItem")
  12. export class ManagePlayerItem extends BaseUI {
  13. init(type: ManagePlayerItemType, data: any) {
  14. this.setText("lbl_user_name", "Player_" + data);
  15. this.initType(type);
  16. }
  17. private type: ManagePlayerItemType = null!;
  18. initType(type: ManagePlayerItemType) {
  19. this.type = type;
  20. if (type == ManagePlayerItemType.APPROVE) {
  21. this.setText("lbl_manager_name", "" + "Approve");
  22. } else if (type == ManagePlayerItemType.MEMBERS) {
  23. this.setText("lbl_manager_name", "" + "Remove");
  24. }
  25. this.FindNode("exp").active = type == ManagePlayerItemType.MEMBERS;
  26. this.FindNode("lbl_approve_info").active = type == ManagePlayerItemType.APPROVE;
  27. }
  28. protected simpleOnBtnClick(name: string): void {
  29. switch (name) {
  30. case "btn_manage_one":
  31. if (this.type == ManagePlayerItemType.APPROVE) {
  32. } else if (this.type == ManagePlayerItemType.MEMBERS) {
  33. this.remove();
  34. }
  35. break;
  36. }
  37. }
  38. remove() {
  39. let self = this;
  40. TipsLayer.showConfirm(
  41. Utils.setI18nLabel("Family.RemoveSuccessTitle"),
  42. Utils.setI18nLabel("Family.RemoveConfirmContent")
  43. ).then((success) => {
  44. if (success) {
  45. Tips.show(Utils.setI18nLabel("Family.RemoveMemberSuccess"));
  46. self.node.destroy();
  47. }
  48. });
  49. }
  50. }