---@class KLUserCenterPanel:UIKmlLuaPanelBase ---@field view KLUserCenterPanelView local KLUserCenterPanel = class(UIKmlLuaPanelBase) local this =KLUserCenterPanel function this:AsyncLoadUI() end ---创建时调用一次 function this:Init() end ---注册UI事件和服务器消息 function this:RegistEvents() end ---界面显示时调用一次 function this:Show() self.env = SL:GetMetaValue("CS_MAIN_ENV") if self.env == "local" then self.url = "http://10.28.1.136/userCenter" elseif self.env == "dev" then self.url = "http://192.168.13.43:100/userCenter" elseif self.env == "test" then self.url = "http://sdkh5-test.yq712.shengaowl.com/userCenter" elseif self.env == "pre" then self.url = "http://sdkh5.yq712.shengaowl.com/userCenter" elseif self.env == "release" then self.url = "http://sdkh5.yq712.shengaowl.com/userCenter" end ---@type UnityEngine.GameObject local obj = GUI:GetGameObject(self.view.prefab_webview) ---@type Vuplex.WebView.Core.Scripts.WebViewEx.WebViewControl self.webViewControl = obj:GetComponentInChildren(typeof(CS.Vuplex.WebView.Core.Scripts.WebViewEx.WebViewControl)) self:LoadUrl(self.url .. "?time=" .. tostring(SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME))) if DebugFlag.LogEnable then log(self.url) end self.webViewControl:SetOnInitialized(function() self:SetSize(GUI:getSizeDelta(self.view.prefab_webview)) end ) self:SetMessageFun(self.OnMessage,self) end ---创建或者刷新界面数据时调用 function this:Refresh() end function this:Hide() end function this:Close() end -------------------------------------------------------------------------Other function this:LoadUrl(url) self.webViewControl:LoadURL(url) end function this:SetSize(width, height) self.webViewControl:SetSize(width, height) end function this:SetMessageFun(fun,ui) self.webViewControl:SetMessageHandler(function(json) fun(ui,json) end) end -------------------------------------------------------------------------接受协议 function this:OnMessage(jsonStr) local jsonTbl = json.decode(jsonStr) if DebugFlag.LogEnable then log(jsonStr) end if jsonTbl.action == 1003 then --1003 关闭sdk GUI:UIPanel_Close("dev/ui/WebView/Panel/KLUserCenter/KLUserCenterPanel") elseif jsonTbl.action == 1004 then --1004 打开隐私协议 SL:OpenURL(jsonTbl.data) elseif jsonTbl.action == 2003 then --2003 退出登录 self:SwitchToLogin() elseif jsonTbl.action == 2005 then --2005 注销账号 self:SwitchToLogin() elseif jsonTbl.action == 2006 then --2006 切换账号 self:SwitchToLogin() end end -------------------------------------------------------------------------function function this:SwitchToLogin() GUI:UIPanel_Open("dev/ui/WebView/Panel/KLUserLogin/KLUserLoginPanel") GUI:UIPanel_Close("dev/ui/Login/Panel/KLSelectGameLogin/KLSelectGameLoginPanel") GUI:UIPanel_Close("dev/ui/WebView/Panel/KLUserCenter/KLUserCenterPanel") end return this