MarketBuyView = MarketBuyView or BaseClass(BaseView) local MarketBuyView = MarketBuyView function MarketBuyView:__init() self.base_file = "market" self.layout_file = "MarketBuyView" self.layer_name = "Activity" self.destroy_imm = true self.use_background = true --全屏界面默认使用这个参数 --self.hide_maincancas = true --全屏界面需要放开隐藏主UI self.change_scene_close = true self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.blur_activity_bg = true self.model = MarketModel:getInstance() self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() end self.switch_callback = function(index) self:SwitchTab(index) end self.destroy_callback = function ( ) self:DestroySuccess() end end --type: 1是一口价 2是竞拍 function MarketBuyView:Open(data,type ) self.data = data self.type = type BaseView.Open(self) end function MarketBuyView:LoadSuccess() local nodes = { "icon1:obj","title_text:tmp","close_btn:obj","right_text2:tmp","ok_btn:obj","name_text:tmp","right_text3:tmp","item_con", "icon3:obj","left_text2:tmp","left_text3:tmp","num_text:tmp","right_text1:tmp","icon2:obj","cancel_btn:obj","left_text1:tmp", "right_bg:obj","bg:img", } self:GetChildren(nodes) lua_resM:setOutsideImageSprite(self, self.bg_img,GameResPath.GetViewBigBg("market_buy_bg"),false) self.awardItem = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.item_con) self.awardItem:SetEnableClick(false) self.awardItem:SetItemSize(84, 84) end function MarketBuyView:AddEvent() local function on_click( target ) if target == self.ok_btn_obj then self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15507, self.data.id, self.price) -- if self.type == MarketModel.ONE_PRICE_TYPE then--一口价购买 -- elseif self.type == MarketModel.AUCTION_PRICE_TYPE then -- self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15507, self.data.id, self.price) -- end end self:Close() end AddClickEvent(self.close_btn_obj, on_click) AddClickEvent(self.ok_btn_obj, on_click) AddClickEvent(self.cancel_btn_obj, on_click) end function MarketBuyView:OpenSuccess() self:UpdateView() end function MarketBuyView:UpdateView() local goods_name = GoodsModel:getInstance():getGoodsName(self.data.type_id, true) self.name_text_tmp.text = goods_name local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.data.type_id) local wear_num = EquipModel:getInstance():EquipGoodsNumById(self.data.type_id) self.num_text_tmp.text = self.data.type == GoodsModel.TYPE.EQUIP and string.format("(拥有 %s 个)", HtmlColorTxt(wear_num, ColorUtil.GREEN_DARK)) or "" local equip_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(self.data) equip_data.equip_key = "EquipView" self.awardItem:SetData(self.data.type_id, self.data.goods_num,nil,equip_data) if self.type == MarketModel.ONE_PRICE_TYPE then--一口价购买 self.left_text1_tmp.text = "购买数量" self.left_text2_tmp.text = "购买价格" self.left_text3_tmp.text = "" self.icon1_obj:SetActive(false) self.icon3_obj:SetActive(false) self.right_bg_obj:SetActive(false) SetAnchoredPositionY(self.num_text, -51) self.title_text_tmp.text = "一口价" self.right_text1_tmp.text = self.data.goods_num self.right_text2_tmp.text = self.data.get_price self.price = self.data.get_price elseif self.type == MarketModel.AUCTION_PRICE_TYPE then self.left_text1_tmp.text = "当前竞价" self.left_text2_tmp.text = HtmlColorTxt("出价金额", ColorUtil.PURPLE_DARK) self.left_text3_tmp.text = "" self.icon3_obj:SetActive(false) self.right_bg_obj:SetActive(false) SetAnchoredPositionY(self.num_text, -51) self.title_text_tmp.text = "竞拍" self.right_text1_tmp.text = self.data.price local price_markup = goods_vo.price_markup * self.data.goods_num or 0 if self.data.aution_num > 0 then--如果已经不是第一次竞拍了 竞拍就要加价 if self.model:IsGoodsCanBuyOnePrice(self.data.type_id) then self.price = (self.data.price + price_markup) > self.data.get_price and self.data.get_price or (self.data.price + price_markup) else self.price = self.data.price + price_markup end else self.price = self.data.price end self.right_text2_tmp.text = self.price -- self.right_text2_tmp.text = price_markup end end function MarketBuyView:SwitchTab( index ) end function MarketBuyView:DestroySuccess( ) if self.awardItem then UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.awardItem) self.awardItem = nil end end