PushMsgM.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { RewardLayer } from "../../prefab/layer/RewardLayer";
  2. import UserM, { GoodInfo } from "../api/UserM";
  3. import WsM from "../api/WsM";
  4. import { WS, WsResponse } from "../net/WS";
  5. import ItemsM from "./ItemsM";
  6. export class RewardGoods {
  7. changeList: GoodInfo[];
  8. goodList: GoodInfo[];
  9. }
  10. export default class PushMsgM {
  11. private static _ins: PushMsgM = null;
  12. public static get ins(): PushMsgM {
  13. return (PushMsgM._ins ??= new PushMsgM());
  14. }
  15. init() {
  16. WS.ins.on(10001, this.onRechargeSuccess, this);
  17. WS.ins.on(10003, this.onRefreshUserData, this);
  18. WS.ins.on(10004, this.onRewardGoods, this);
  19. }
  20. onRefreshUserData(msg: WsResponse) {
  21. console.warn("onRefreshUserData", msg);
  22. UserM.ins.refreshData();
  23. }
  24. onRechargeSuccess(msg: WsResponse) {
  25. console.warn("onRechargeSuccess", msg);
  26. console.warn("changeList", msg.data.changeList);
  27. ItemsM.ins.itemChange(msg.data.changeList, msg.data.goodList);
  28. }
  29. onRewardGoods(msg: WsResponse) {
  30. console.warn("onRewardGoods", msg);
  31. let data = msg.data as RewardGoods;
  32. // UserM.ins.refreshGoods(data.goodList);
  33. // RewardLayer.show(data.changeList);
  34. ItemsM.ins.itemChange(data.changeList, data.goodList);
  35. }
  36. }