From 0a924855ed631264cb8eb1ee5ae2a72245a6effd Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 16 Nov 2021 17:01:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E8=B4=A6=E5=8F=B7ID=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E3=80=91=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Login/LoginManager.lua | 70 ++++++++++++++----- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua index eebd790807..863894fa7e 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua @@ -45,26 +45,30 @@ function this.Initialize() this.extData = result[6] or "" this.p_appId = result[7] or "" this.SdkSubChannel = result[8] or "" + AppConst.SdkPackageName = AndroidDeviceInfo.Instance:GetPackageName() - -- 判断是否是注册并登录 - if this.isRegister then - this.isRegister = false - -- 触发创建账户的事件 - this.TrackCreateAccount() - -- 发送登录成功事件 - Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,result[1]) - else - this.CheckIsRegister(AppConst.OpenId, function(isRegister) - if isRegister then - -- 触发创建账户的事件 - this.TrackCreateAccount() - end + -- 账号数据正确性检测 + this.CheckUserId(this.extData, function() + -- 判断是否是注册并登录 + if this.isRegister then + this.isRegister = false + -- 触发创建账户的事件 + this.TrackCreateAccount() -- 发送登录成功事件 - Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,result[1]) - end) - end - -- 防沉迷检测 - this.CheckRealName() + Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess, result[1]) + else + this.CheckIsRegister(AppConst.OpenId, function(isRegister) + if isRegister then + -- 触发创建账户的事件 + this.TrackCreateAccount() + end + -- 发送登录成功事件 + Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess, result[1]) + end) + end + -- 防沉迷检测 + this.CheckRealName() + end) else local errCode = result[2] if not errCode then @@ -134,6 +138,36 @@ function this.CheckRealName() end, nil) end end + +function this.CheckUserId(extData, func) + -- 如果没有OpenId则向登录服请求校验 + if not AppConst.OpenId or AppConst.OpenId == "" then + local json = require 'cjson' + if extData then + local context = json.decode(extData) + if context then + HttpManager:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getKTGameUserInfo?gid=".. context.gid .. "&pid=".. context.pid .. "&access_token=" .. AppConst.TokenStr, + function(str) + if str then + Log(str) + local data = json.decode(str) + AppConst.OpenId = data.openId + end + -- 完成 + if func then + func() + end + end) + return + end + end + end + -- 不符合条件 + if func then + func() + end +end + -- 检测是否是新账户 function this.CheckIsRegister(openId, func) if func then From 3565dc2b2ab5cbf4f955e1c26c09ec92584e7b35 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 18 Nov 2021 11:34:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E6=94=B9=E5=90=8D=E6=97=B6?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E4=BA=8B=E4=BB=B6=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ManagedResources/~Lua/Common/GlobalDefine.lua | 3 ++- Assets/ManagedResources/~Lua/Common/functions.lua | 10 ++++++++-- .../~Lua/Modules/Popup/NameManager.lua | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua index 14367c4585..1a99babb55 100644 --- a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua +++ b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua @@ -30,7 +30,8 @@ SDKSubMitType = { TYPE_EXIT_GAME = 5, TYPE_ENTER_COPY = 6, TYPE_EXIT_COPY = 7, - TYPE_VIP_LEVELUP = 8 + TYPE_VIP_LEVELUP = 8, + TYPE_CHANGE_NAME = 9 } SDK_RESULT = { diff --git a/Assets/ManagedResources/~Lua/Common/functions.lua b/Assets/ManagedResources/~Lua/Common/functions.lua index 789606f1fc..e7adee6643 100644 --- a/Assets/ManagedResources/~Lua/Common/functions.lua +++ b/Assets/ManagedResources/~Lua/Common/functions.lua @@ -1622,8 +1622,14 @@ function SubmitExtraData(context) params.guildID = PlayerManager.familyId params.Vip = tostring(VipManager.GetVipLevel()) params.moneyNum = BagManager.GetItemCountById(16) - params.roleCreateTime = DateUtils.GetDateTime(PlayerManager.userCreateTime) - params.roleLevelUpTime = context.roleLevelUpTime and DateUtils.GetDateTime(context.roleLevelUpTime) or "" + params.roleCreateTime = PlayerManager.userCreateTime + params.roleLevelUpTime = context.roleLevelUpTime and context.roleLevelUpTime or "0" + + -- 特殊处理, 改名时用zoneName传递老名字 + if context.type == SDKSubMitType.TYPE_CHANGE_NAME then + params.zoneName = context.oldName + end + SDKMgr:SubmitExtraData(params) end diff --git a/Assets/ManagedResources/~Lua/Modules/Popup/NameManager.lua b/Assets/ManagedResources/~Lua/Modules/Popup/NameManager.lua index 2d4b6b1295..0ea62a244a 100644 --- a/Assets/ManagedResources/~Lua/Modules/Popup/NameManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Popup/NameManager.lua @@ -71,6 +71,9 @@ function this.ChangeUserName(type, name, teamPosId, sex, callBack) return end NetManager.ChangeUserNameRequest(type, name, teamPosId, sex, function() + -- 保存一下老名字,用于上报事件 + local oldName = this.roleName + -- this.roleSex = sex this.roleName = name PlayerManager.nickName = name @@ -79,6 +82,9 @@ function this.ChangeUserName(type, name, teamPosId, sex, callBack) ThinkingAnalyticsManager.SetSuperProperties({ role_name = PlayerManager.nickName, }) + -- 上报改名事件 + SubmitExtraData({ type = SDKSubMitType.TYPE_CHANGE_NAME, oldName = oldName }) + -- 创建角色时保存一下头像数据 if type == 1 then local config = ConfigManager.GetConfigDataByKey(ConfigName.PlayerRole, "Role", sex) From f5f2e9c7ef59cc55fe8b8b16d50f369e1a2e1a5d Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 18 Nov 2021 14:20:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E8=B4=A6=E5=8F=B7=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E3=80=91=E5=A4=A7=E5=B0=8F=E5=86=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua index 863894fa7e..dc97cb5ad3 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua @@ -151,7 +151,7 @@ function this.CheckUserId(extData, func) if str then Log(str) local data = json.decode(str) - AppConst.OpenId = data.openId + AppConst.OpenId = data.openid end -- 完成 if func then