--快乐二级选择界面 有需要可以直接拿来用参数下面有标记的 --[[ { gold_ab_res = "uiComponent_asset", gold_res = "ui_momey_icon_1", nameText = "是否使用 ", -- 在价格文本前 toggleText = "本次登录不再提示", price = 100, priceText = "100 扫荡副本", -- 将价格文本也添加在这里面,这个文本介绍包括价格跟目标的购买操作 titleText = "副本扫荡", close_callback = close_callback, ok_callback = ok_callback, gold_goods_id = 100007,可能是道具图标 is_complex_ok_callback = false, --如果ok_callback中的货币类型比较复杂,不适用于单彩钻的情况,就需要在自己的ok_callback中判断货币满足情况并把这个参数设为true toggle_function = toggle_function,--判断是否要重新弹出改界面的方法 一定要传自己的 bg_res = "tips_comm_bg2", rechanger_callback = --GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW, 1) no_need_toggle = true,--不需要toggle con_pos_y = 20,--文本框高度 con qc_type = 0, 当彩钻不足的时候会直接转到快速充值界面,这个参数是快速充值的类型,默认0(¥68以上档位出快充) 1投资类型(全档位出快充) special_icon_data = false,--有些不是货币图标的也要显示就要用以前的老方法了 jump_recharge_callback = jump_recharge_callback, 有些界面还没进来这里就被拦住了 这个是给那个充值界面关闭回调用的 } ]]--data数据 uiComToggleTipView = uiComToggleTipView or BaseClass(BaseView) local uiComToggleTipView = uiComToggleTipView function uiComToggleTipView:__init() self.base_file = "uiComponent" self.layout_file = "uiComToggleTipView" self.layer_name = "Top" self.destroy_imm = true self.use_background = true self.change_scene_close = true self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.is_set_zdepth = true self.model = BaseDungeonModel:getInstance() self.reward_item_list = {} self.is_toggle_on = false 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 uiComToggleTipView:DestroySuccess() if self.delay_id then GlobalTimerQuest:CancelQuest(self.delay_id) self.delay_id = nil end end function uiComToggleTipView:LoadSuccess() local nodes = { "Toggle:obj","Window/windowTitleCon/windowTitleText:tmp","Window/windowCloseBtn:obj", "con/price:tmp","btnCancel:obj","Toggle/Label:tmp","btnOK:obj","Window:raw","con", "btnOK/lb_btn_ok:tmp","btnCancel/lb_btn_cancel:tmp","con/goodIcon:img:obj", "con/priceTitle:tmp:obj", } self:GetChildren(nodes) self.Toggle:GetComponent("Toggle").isOn = false--默认不勾选 if self.need_load_again then self:UpdateView() end end function uiComToggleTipView:AddEvent() local function onBtnClickHandler(target,x,y) if target == self.btnOK_obj then if self.data.is_complex_ok_callback then if self.data.ok_callback then self.data.ok_callback() end self:Close() return end if not self.data or not self.data.price then Message.show("配置有误") return end if not GoodsModel:getInstance():IsJinEnough(self.data.price) then if self.data.rechanger_callback then self.data.rechanger_callback() end else if self.data.ok_callback then self.data.ok_callback() end end self:Close() elseif target == self.btnCancel_obj then if self.data.close_callback then self.data.close_callback() end self:Close() elseif target == self.windowCloseBtn_btn then self:Close() elseif target == self.Toggle_obj then self.is_toggle_on = not self.is_toggle_on if self.data.toggle_function then self.data.toggle_function(self.is_toggle_on) else self.model.sweep_no_tip = self.is_toggle_on end end end AddClickEvent(self.btnOK_obj,onBtnClickHandler,1) AddClickEvent(self.btnCancel_obj,onBtnClickHandler,1) AddClickEvent(self.windowCloseBtn_btn,onBtnClickHandler,1) AddClickEvent(self.Toggle_obj,onBtnClickHandler,1) end function uiComToggleTipView:Open(data) -- print("huangcong:uiComToggleTipView [start:100] 1111:", 1111) self.data = data or self.data BaseView.Open(self) end function uiComToggleTipView:OpenSuccess( ) self:UpdateView() end function uiComToggleTipView:UpdateView( data ) self.data = data or self.data -- print("huangcong:uiComToggleTipView [start:110] 111:", self.data) if not self.data then return end if not self.is_loaded then self.need_load_again = true return end if self.data.no_need_toggle and not self.data.toggle_function then self.Toggle_obj:SetActive(false) SetAnchoredPositionY(self.con,30) else self.Toggle_obj:SetActive(true) SetAnchoredPositionY(self.con,50) end self.windowTitleText_tmp.text = self.data.titleText or "扫荡副本" self.Label_tmp.text = self.data.toggleText or "本次登录不再提示" self.lb_btn_ok_tmp.text = self.data.okText or "确认" self.lb_btn_cancel_tmp.text = self.data.cancelText or "取消" -- self.data.rechanger_desc = self.data.rechanger_desc or "您的彩钻不足,是否前往充值?" local function rechanger_callback( ... ) local ok = function ( ) OpenFun.Open(158, 0) end Alert.show("您的彩钻不足,是否前往充值?",Alert.Type.Two,ok) end self.data.rechanger_callback = self.data.rechanger_callback or rechanger_callback --现在加入了图文混排把原来的逻辑给删除 local price_str = "" if not self.data.special_icon_data then--没有特殊图标结构 local name_str = self.data.nameText or "是否使用 " local gold_res = 1 if self.data.gold_res and self.data.gold_res ~= "" then gold_res = string.gsub(self.data.gold_res, "ui_momey_icon_", "") end if self.data.hide_money_icon ~= nil then price_str = string.format("%s%s %s",self.data.insufficientText and self.data.insufficientText.."\n" or "",name_str,self.data.priceText or "0 扫荡副本?") else price_str = string.format("%s%s %s%s",self.data.insufficientText and self.data.insufficientText.."\n" or "",name_str,WordManager:GetMoneyFaceStr(tonumber(gold_res)),self.data.priceText or "0 扫荡副本?") end self.price_tmp.text = price_str else self.goodIcon_obj:SetActive(true) self.priceTitle_obj:SetActive(true) local function delay_method( ) self.priceTitle_tmp.text = self.data.priceTitleText lua_resM:setImageSprite(self, self.goodIcon_img, self.data.special_icon_data.ab_name, self.data.special_icon_data.icon_res,true) self.price_tmp.text = string.format("%s%s",self.data.price,self.data.priceText) SetSizeDeltaX(self.price, self.price_tmp.preferredWidth + 2) SetSizeDeltaX(self.priceTitle, self.priceTitle_tmp.preferredWidth + 2) end self.delay_id = setTimeout(delay_method, 0.02) end lua_resM:setOutsideRawImage(self,self.Window_raw, GameResPath.GetViewBigBg(self.data.tips_comm_bg2 or "tips_comm_bg6"),false) end