public static async Task <AccountInfo> WeChatRegisterCreatUser(WeChatJsonData weChatJsonData) { User user = ComponentFactory.Create <User>(); user.Icon = weChatJsonData.headimgurl; user.Name = weChatJsonData.nickname; user.Beans = UserConfigComponent.Ins.InitUserBeans.Value; user.Jewel = UserConfigComponent.Ins.InitUserJewel.Value; user.UserId = ++UserConfigComponent.Ins.MaximumUserId; user.Sex = weChatJsonData.sex; await Game.Scene.GetComponent <DBProxyComponent>().Save(user); AccountInfo accountInfo = ComponentFactory.Create <AccountInfo>(); accountInfo.UserId = user.UserId; accountInfo.Account = weChatJsonData.unionid; accountInfo.IsStopSeal = false; await Game.Scene.GetComponent <DBProxyComponent>().Save(accountInfo); return(accountInfo); }
//微信登陆 public static async Task <AccountInfo> WeChatLogin(this UserComponent userComponent, string accessTokenAndOpenid) { WeChatJsonData weChatJsonData = WeChatJsonAnalysis.HttpGetUserInfoJson(accessTokenAndOpenid); if (weChatJsonData == null) { return(null); } List <AccountInfo> accountInfos = await userComponent.dbProxyComponent.Query <AccountInfo>(AccountInfo => AccountInfo.Account == weChatJsonData.unionid); if (accountInfos.Count == 0) { AccountInfo accountInfo = await UserFactory.WeChatRegisterCreatUser(weChatJsonData); accountInfos.Add(accountInfo); } accountInfos[0].Password = TimeTool.GetCurrenTimeStamp().ToString(); await userComponent.dbProxyComponent.Save(accountInfos[0]); return(accountInfos[0]); }