import { RewardLayer } from "../../prefab/layer/RewardLayer"; import UserM, { GoodInfo } from "../api/UserM"; import WsM from "../api/WsM"; import { WS, WsResponse } from "../net/WS"; 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(401, this.OnUserTokenError, this); } 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); } }