1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { Hall } from "../../prefab/hall/Hall";
- import { RewardLayer } from "../../prefab/layer/RewardLayer";
- import { TipsLayer } from "../../prefab/layer/TipsLayer";
- import UserM, { GoodInfo } from "../api/UserM";
- import WsM from "../api/WsM";
- import { WS, WsResponse } from "../net/WS";
- import Utils from "../utils/Utils";
- import EV, { EV_TYPE } from "./EV";
- import ItemsM from "./ItemsM";
- export class RewardGoods {
- changeList: GoodInfo[];
- goodList: GoodInfo[];
- }
- export default class PushMsgM {
- private static _ins: PushMsgM = null;
- public static get ins(): PushMsgM {
- return (PushMsgM._ins ??= new PushMsgM());
- }
- init() {
- WS.ins.on(10001, this.onRechargeSuccess, this);
- WS.ins.on(10003, this.onRefreshUserData, this);
- WS.ins.on(10004, this.onRewardGoods, this);
- WS.ins.on(10005, this.OnJoinFamilySuccess, this);
- WS.ins.on(10006, this.OnFamilyKickedMe, this);
- WS.ins.on(401, this.OnUserTokenError, this);
- }
- async OnJoinFamilySuccess(msg: WsResponse) {
- await UserM.ins.refreshInfo();
- await TipsLayer.showConfirm(
- "",
- Utils.setI18nLabel("Family.JoinFamilySuccess")
- );
- EV.ins.emit(EV_TYPE.FAMILY_STATUS_UPDATE);
- Hall.ins.switchPage(Hall.PageFamily);
- }
- async OnFamilyKickedMe(msg: WsResponse) {
- let result = await TipsLayer.showConfirm(
- "",
- Utils.setI18nLabel("Family.KickedMe")
- );
- await UserM.ins.refreshInfo();
- EV.ins.emit(EV_TYPE.FAMILY_STATUS_UPDATE);
- }
- OnUserTokenError(msg: WsResponse) {
- console.warn("OnUserTokenError", msg);
- window.location.reload();
- }
- onRefreshUserData(msg: WsResponse) {
- console.warn("onRefreshUserData", msg);
- UserM.ins.refreshData();
- }
- onRechargeSuccess(msg: WsResponse) {
- console.warn("onRechargeSuccess", msg);
- console.warn("changeList", msg.data.changeList);
- ItemsM.ins.itemChange(msg.data.changeList, msg.data.goodList);
- }
- onRewardGoods(msg: WsResponse) {
- console.warn("onRewardGoods", msg);
- let data = msg.data as RewardGoods;
- // UserM.ins.refreshGoods(data.goodList);
- // RewardLayer.show(data.changeList);
- ItemsM.ins.itemChange(data.changeList, data.goodList);
- }
- }
|