/** * 用户数据管理 */ let UserMgr = { _uid: undefined, // 玩家uid //* ************* 初始化 ************* *// /** * 初始化 * * @author Wetion * @date 2019-03-25 */ init () { if (CC_EDITOR) { return; } this.launchTime = G.TimeUtils.getCurrentTime(); // 模块消息 cc.game.on('e_mgr_load_config_done', this.initLocalConfig, this); }, //* ************* 用户信息获取 ************* *// /** * 获取玩家uid * * @returns {number} */ getUid () { return this._uid || 0; }, /** * 设置玩家uid * * @author libo * @date 2019-06-06 * @param {*} uid */ setUid (uid) { this._uid = uid; }, /** * 设置玩家系统信息 * * @param {Object} data */ setUserSystemInfo (data) { }, /** * 请求自己的用户信息 * * @param {Number} uid * @param {Number} sysTime */ requestSelfInfo () { G.LogUtils.log('----> UserMgr requestSelfInfo()'); G.NetworkMgr.sendSocketRequest('user_self_info', {}, this._responseSelfInfo.bind(this)); }, _responseSelfInfo (data) { G.LogUtils.log('<---- UserMgr _responseSelfInfo()'); let responseInfo = data.responseInfo; if (responseInfo.code === 200) { // 玩家基础信息 this._baseInfo = responseInfo.baseInfo; // 登录完成判断 G.PublicMgr.isDoneUserSelfInfo = true; if (G.PublicMgr.isDoneSystemInfo) { G.PublicMgr.isDoneUserSelfInfo = false; G.PublicMgr.isDoneSystemInfo = false; G.PublicMgr.emit(JMC.PUBLIC_MSG.LOGIN_SUCCESS); } } else { // 断开网络并且弹出重连窗口 G.NetworkMgr.closeSocket(); G.AppUtils.getSceneCtrl().showOfflineAlert(); } }, } module.exports = UserMgr;