123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- ---@class KLMonthCardRechargePanel:UIKmlLuaPanelBase
- ---@field view KLMonthCardRechargePanelView
- local KLMonthCardRechargePanel = class(UIKmlLuaPanelBase)
- local this =KLMonthCardRechargePanel
- function this:AsyncLoadUI()
- end
- ---创建时调用一次
- function this:Init()
- GUI:SetActive(self.view.clickMask, false)
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- end
- ---界面显示时调用一次
- function this:Show()
- end
- function this:LoadPayWebview(data)
- self.args = data
- self.env = SL:GetMetaValue("CS_MAIN_ENV")
- if self.env == "local" then
- self.url = "http://10.28.1.136/order?time="
- elseif self.env == "dev" then
- self.url = "http://192.168.13.43:100/order?time="
- elseif self.env == "test" then
- self.url = "http://sdkh5-test.yq712.shengaowl.com/order?time="
- elseif self.env == "pre" then
- self.url = "http://sdkh5.yq712.shengaowl.com/order?time="
- elseif self.env == "release" then
- self.url = "http://sdkh5.yq712.shengaowl.com/order?time="
- 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 .. tostring(SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME)))
- self.webViewControl:SetOnInitialized(function()
- self:SetSize(GUI:getSizeDelta(self.view.prefab_webview))
- GUI:SetActive(self.view.clickMask, true)
- end )
- self:SetMessageFun(self.OnMessage,self)
- end
- function this:SendPageMsg()
- local serverId = SL:GetMetaValue("SERVER_ID")
- local roleId = SL:GetMetaValue("MAIN_ACTOR_ID")
- local roleName = SL:GetMetaValue("USER_NAME")
- local serverName = SL:GetMetaValue("SERVER_NAME")
- ---@type BoxTokenData
- local boxData = GamePlay.boxData
- ---@type SdkTokenData
- local sdkData = GamePlay.sdkData
- local userToken = boxData.userToken
- local token = sdkData.token
- local gameId = SL:GetMetaValue("GAME_ID")
- local data = self.args
- local goodsId = data.shopId
- local goodsName = data.shopName
- --临时chanelId
- local channelId = SL:GetMetaValue("CHANNEL_ID")
- local shopPrice = data.shopPrice
- local shopCount = data.shopCount
- local goodsAmount = shopPrice * shopCount
- local extraParams = data.extraParams
- local appVersion = boxData.appVersion
- local isBoxSDK = LoginInfo.IsBoxSDK()
- local userId = sdkData.userId
- local msg = json.encode({ userId = tostring(userId), serverId = tostring(serverId), roleId = tostring(roleId), roleName = roleName, serverName = serverName,
- token = token,userToken = userToken, gameId = gameId, goodsAmount = tostring(goodsAmount), goodsId = tostring(goodsId), goodsName = goodsName,
- channelId = tostring(channelId), shopPrice = tostring(shopPrice), shopCount = tostring(shopCount), extraParams = tostring(extraParams), appVersion = tostring(appVersion), isBoxSDK = isBoxSDK})
- if DebugFlag.LogEnable then
- log(msg)
- end
- self:SendJsonMessage(msg)
- end
- function this:OnMessage(jsonStr)
- local jsonTbl = json.decode(jsonStr)
- if DebugFlag.LogEnable then
- log(jsonStr)
- end
- if jsonTbl.action == 1003 or jsonTbl.action == 3001 then --旧1234 新1003关闭,3001支付成功
- GUI:UIPanel_Close("dev/ui/WebView/Panel/KLMonthCardRecharge/KLMonthCardRechargePanel")
- elseif jsonTbl.action == 1005 then
- if jsonTbl.data.action == 3001 then
- self:SendPageMsg()
- end
- end
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- end
- function this:Close()
- GUI:SetActive(self.view.clickMask, false)
- if self.webViewControl then
- self.webViewControl:SetOnInitialized(nil)
- end
- end
- function this:SetSize(width, height)
- self.webViewControl:SetSize(width, height)
- end
- function this:LoadUrl(url)
- self.webViewControl:LoadURL(url)
- end
- function this:SetMessageFun(fun,ui)
- self.webViewControl:SetMessageHandler(function(json)
- fun(ui,json)
- end)
- end
- function this:SendJsonMessage(json)
- self.webViewControl:SendJsonMessage(json)
- end
- return this
|