require("Base/BasePanel") EnergyBaseLog = Inherit(BasePanel) local this = EnergyBaseLog local BaseResourceConfig = ConfigManager.GetConfig(ConfigName.BaseResourceConfig) local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) function EnergyBaseLog:InitComponent() this.btnBack = Util.GetGameObject(this.gameObject, "bg/btnBack") this.scroll = Util.GetGameObject(this.gameObject, "bg/scroll") this.prefab = Util.GetGameObject(this.gameObject, "bg/scroll/pre") local v2 = this.scroll.transform.rect this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform, this.prefab, nil, Vector2.New(v2.width, v2.height), 1, 1, Vector2.New(0, 5)) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 end function EnergyBaseLog:BindEvent() Util.AddClick(this.btnBack, function() self:ClosePanel() end) Util.AddClick(this.btnUpLv, function() end) end function EnergyBaseLog:AddListener() end function EnergyBaseLog:RemoveListener() end function EnergyBaseLog:OnOpen() end function EnergyBaseLog:OnShow() EnergyBaseManager.GetBaseSnatchLog(function (msg) table.sort(msg, function (a, b) return a.snatchTime > b.snatchTime end) this.scrollView:SetData(msg, function(index, go) this.SetScroll(go, msg[index]) end) end) end function EnergyBaseLog:OnClose() end function EnergyBaseLog:OnDestroy() end function this.SetScroll(go, data) local title = Util.GetGameObject(go, "title"):GetComponent("Text") local content = Util.GetGameObject(go, "content"):GetComponent("Text") local time = Util.GetGameObject(go, "time"):GetComponent("Text") local itemName = GetLanguageStrById(BaseResourceConfig[data.cfgId].Name) if data.targetUid == PlayerManager.uid then title.text = GetLanguageStrById(50463) if data.winnerId == PlayerManager.uid then content.text = GetLanguageStrById(50467)..itemName.."" else content.text = string.format(GetLanguageStrById(50468), data.winnerNickName, itemName) end else title.text = data.targetNickName..GetLanguageStrById(50464) if data.winnerId == PlayerManager.uid then content.text = string.format(GetLanguageStrById(50469), data.targetNickName, itemName) end end time.text = this.ShowTime(data.snatchTime) end function this.ShowTime(time) local onlineTime = math.floor(PlayerManager.serverTime - time) local timeText = "" if onlineTime < 60 then timeText = GetLanguageStrById(10824) return timeText elseif onlineTime >= 60 and onlineTime < 3600 then timeText = math.floor(onlineTime / 60) .. GetLanguageStrById(10825) return timeText elseif onlineTime >= 3600 and onlineTime < 3600 * 24 then timeText = math.floor(onlineTime / 3600) .. GetLanguageStrById(10826) return timeText elseif onlineTime >= 3600 * 24 and onlineTime <= 3600 * 24 * 30 then timeText = math.floor(onlineTime / (3600 * 24)) .. GetLanguageStrById(10827) return timeText elseif onlineTime > 3600 * 24 * 30 then timeText = GetLanguageStrById(10828) return timeText end end return this