FamilyM.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import ItemsM from "../mgr/ItemsM";
  2. import { RewardGoods } from "../mgr/PushMsgM";
  3. import WsM from "./WsM";
  4. export class OwnerInfo {
  5. owner: boolean; // 当前用户是否是owener
  6. ownerId: string; // owner的id
  7. ownerName: string; // owner的名字
  8. rewardStatus: number; // 是否有奖励 0有1没有
  9. rewardPog: number; // 奖励的pog数量
  10. }
  11. export class FamilyInfo {
  12. familyId: string; // 家族id
  13. familyName: string; // 家族名族
  14. notice: string; // 家族公告
  15. share: string;
  16. dailyPog: string; // 家族今日pog
  17. seasonPassGame: number; // 家族赛季通行证
  18. xp: string; // 家族当前xp
  19. boxCount: number; // 宝箱数量
  20. totalSize: number; // 家族最大人数
  21. memberSize: number; // 家族当前人数
  22. ownerDto: OwnerInfo;
  23. }
  24. export class FamilyMember {
  25. familyId: string;
  26. userId: string;
  27. userName: string;
  28. totalXp: string;
  29. dailyXp: string;
  30. }
  31. export class FamilyJoinPlayer {
  32. id: string;
  33. createTime: string;
  34. updateTime: string;
  35. isDeleted: number;
  36. familyId: string;
  37. userId: string;
  38. reason: string;
  39. status: number;
  40. }
  41. export default class FamilyM {
  42. private static _ins: FamilyM;
  43. public static get ins(): FamilyM {
  44. return (FamilyM._ins ??= new FamilyM());
  45. }
  46. async getFamilyInfo(familyId: string): Promise<FamilyInfo> {
  47. let result = await WsM.ins.syncRequest(26009, { familyId: familyId });
  48. return result as FamilyInfo;
  49. }
  50. async familyMemberList(familyId: string): Promise<FamilyMember[]> {
  51. let result = await WsM.ins.syncRequest(26010, { familyId });
  52. return result.memberList as FamilyMember[];
  53. }
  54. async searchFamily(keyWords: string): Promise<FamilyInfo[]> {
  55. let result = await WsM.ins.syncRequest(26002, { keyWords });
  56. return result as FamilyInfo[];
  57. }
  58. async createFamily(familyName: string): Promise<FamilyInfo> {
  59. let result = await WsM.ins.syncRequest(26001, {
  60. familyName: familyName,
  61. notice: "",
  62. });
  63. return result as FamilyInfo;
  64. }
  65. async editFamilyNotice(familyId: string, notice: string): Promise<any> {
  66. let result = await WsM.ins.syncRequest(26003, {
  67. familyId,
  68. notice,
  69. });
  70. return result;
  71. }
  72. async requestJoinFamily(familyId: string, reason: string): Promise<any> {
  73. let result = await WsM.ins.syncRequest(26004, {
  74. familyId,
  75. reason,
  76. });
  77. return result;
  78. }
  79. async familyRequestList(familyId: string): Promise<FamilyJoinPlayer[]> {
  80. let result = await WsM.ins.syncRequest(26013, { familyId });
  81. if (!result || !result.joinList) {
  82. return [];
  83. }
  84. return result.joinList as FamilyJoinPlayer[];
  85. }
  86. async agreeJoinFamily(familyId: string, userId: string): Promise<any> {
  87. let result = await WsM.ins.syncRequest(26005, {
  88. familyId,
  89. userId,
  90. });
  91. return result;
  92. }
  93. async rejectJoinFamily(familyId: string, userId: string): Promise<any> {
  94. let result = await WsM.ins.syncRequest(26006, {
  95. familyId,
  96. userId,
  97. });
  98. return result;
  99. }
  100. async upgradeFamily(familyId: string): Promise<any> {
  101. let result = await WsM.ins.syncRequest(26007, { familyId });
  102. return result;
  103. }
  104. async kickFamilyMember(familyId: string, userId: string): Promise<any> {
  105. let result = await WsM.ins.syncRequest(26008, { familyId, userId });
  106. return result;
  107. }
  108. async claimFamilyRewardMemberBox(
  109. familyId: string,
  110. num: number
  111. ): Promise<RewardGoods> {
  112. let result: RewardGoods = await WsM.ins.syncRequest(26011, {
  113. familyId,
  114. num,
  115. });
  116. if (result) {
  117. ItemsM.ins.itemChange(result.changeList, result.goodList);
  118. }
  119. return result;
  120. }
  121. async claimFamilyRewardOwnerPog(familyId: string): Promise<RewardGoods> {
  122. let result = await WsM.ins.syncRequest(26012, { familyId });
  123. if (result) {
  124. ItemsM.ins.itemChange(result.changeList, result.goodList);
  125. }
  126. return result;
  127. }
  128. async leaveFamily(): Promise<any> {
  129. let result = await WsM.ins.syncRequest(26014, {});
  130. return result;
  131. }
  132. }