SoulPowerChargeView = SoulPowerChargeView or BaseClass(BaseView) local SoulPowerChargeView = SoulPowerChargeView function SoulPowerChargeView:__init() self.base_file = "soulPower" self.layout_file = "SoulPowerChargeView" self.layer_name = "Activity" self.destroy_imm = true self.use_background = true self.change_scene_close = true self.hide_maincancas = true --是否隐藏主界面 self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.blur_activity_bg = true self.use_show_anim = true self.use_hide_anim = true self.jump_close = true self.model = SoulPowerModel:getInstance() self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() end self.destroy_callback = function ( ) self:DestroySuccess() end end function SoulPowerChargeView:Open(sp_grade, sp_lv) self.sp_grade = sp_grade self.sp_lv = sp_lv BaseView.Open(self) end function SoulPowerChargeView:LoadSuccess() local nodes = { "bg:raw", "close:obj", "confirmBtn:obj", "chargeTip:tmp", "leftTime:tmp", "costNum:tmp", } self:GetChildren(nodes) lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("tips_comm_bg6")) end function SoulPowerChargeView:AddEvent() local on_click = function ( click_obj ) if self.close_obj == click_obj then self:Close() elseif self.confirmBtn_obj == click_obj then if not self.left_time then return end if self.left_time < 60 then Message.show("您即将完成充能,无需快速充能!") else self:DoCharge() end end end AddClickEvent(self.close_obj, on_click) AddClickEvent(self.confirmBtn_obj, on_click) local update_soul_power_left_time = function() if not self.is_loaded then return end self:UpdateLeftTime() end self:BindEvent(self.model, SoulPowerConst.UPDATE_SOUL_POWER_LEFT_TIME, update_soul_power_left_time) end function SoulPowerChargeView:DoCharge( ) local function ok_callback( ... ) self.model:Fire(SoulPowerConst.REQUEST_CCMD_EVENT,14403) self:Close() end local function toggle_function( flag ) self.model._charge_no_double_check = flag end local function use_function( toggle_tip_data,call_fun_sum ) if not self.model._charge_no_double_check and self.need_cost ~= 0 then GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data) else call_fun_sum() end end local buy_tip_data = { gold_type = 1,--货币类型 cost_price = self.need_cost,--消耗金额 ok_callback = ok_callback,--成功 toggle_function = toggle_function,--多选 togglePriceStr = string.format("<#fdffc2>%s 完成充能",self.need_cost),--提示语 use_function = use_function,--最终调用 } CustomActivityModel:getInstance():BuyTips(buy_tip_data) end function SoulPowerChargeView:OpenSuccess() local sp_grade_condition_cfg = self.model:GetSoulPowerGradeCfgByGrade(self.sp_grade) --当前阶数的额外配置 self.chargeTip_tmp.text = string.format("当前正在充能 <#fdffc2>%s%s层", Trim(sp_grade_condition_cfg.name), self.sp_lv+1) self:UpdateLeftTime() end function SoulPowerChargeView:UpdateLeftTime( ) local time_head, time_tail = self.model:GetSoulPowerTimeHeadTail() local next_lv_total_time = self.model:GetSoulPowerNextLvNeedTotalTime(self.sp_grade, self.sp_lv) self.left_time = time_tail - next_lv_total_time - TimeUtil:getServerTime() if self.left_time < 0 then self.left_time = 0 end self.leftTime_tmp.text = string.format("剩余时间:%s",TimeUtil:timeConvert(self.left_time, "hh:mm:ss")) --充能:剩余时间小于60s时不给充, 充能需求 彩钻 * 向上取整(剩余秒数/300),即5分钟1彩钻 self.need_cost = math.ceil(self.left_time/300) self.costNum_tmp.text = string.format("确认消耗 %s<#2CF86F>%s 直接完成充能吗?", WordManager:GetMoneyFaceStr(1), self.need_cost) end function SoulPowerChargeView:DestroySuccess( ) end