|
|
- MarketUpShelvesView = MarketUpShelvesView or BaseClass(BaseItem)
- local MarketUpShelvesView = MarketUpShelvesView
-
- function MarketUpShelvesView:__init()
- self.base_file = "market"
- self.layout_file = "MarketUpShelvesView"
- self.model = MarketModel:GetInstance()
-
- self:Load()
- end
-
- function MarketUpShelvesView:Load_callback()
- self.nodes = {
- "bg:raw", "guild_btn:obj:imgex", "Toggle:obj:tog", "addNumCon", "world_btn:obj:imgex", "price_text:tmp", "one_text:tmp",
- }
- self:GetChildren(self.nodes)
- lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("shop_buy_view_bg"), false)
- self.addNumComponent = AddNumberComponent.New(self.addNumCon, nil, nil, nil, nil, nil, 264)
- self.addNumComponent:SetComponentWidth(244)
- self.addNumComponent:SetVisibleCalcBtn(false)
-
- self:AddEvents()
- if self.need_refreshData then
- self:UpdateView()
- end
- end
-
- function MarketUpShelvesView:AddEvents( )
- local onChangeCountHandler = function (count)
- self:SetCountNum(count)
- end
- self.change_count_id = self.addNumComponent:Bind(ComponentEvent.AddNumberComponent.CHANGE_COUNT,onChangeCountHandler)
-
- local function on_click( target )
- if target == self.Toggle_obj then
- elseif target == self.guild_btn_obj then--上架到社团
- if self.up_market_range == 1 then
- Message.show("该商品只能上架到世界拍卖哦~")
- else
- local function ok( ... )
- local data = self.data
- local is_to_world = self.Toggle_tog.isOn and 1 or 0
- self.model:Fire(MarketModel.REQUEST_CCMD_EVENT,15506,data.goods_id,data.type_id, self.market_count,MarketModel.AUCTION_GUILD_TYPE, is_to_world)
- self.model:Fire(MarketModel.CLOSE_MARKET_UP_SHELVES_VIEW)
- end
- local is_can_wear = EquipModel:getInstance():EquipCanShowGoodsTip(self.data)
- if is_can_wear then
- local ask_str = string.format("该装备可进行 <color=%s>穿戴</color> 或者 <color=%s>替换</color> 哦\n是否继续上架?", ColorUtil.GREEN_DARK,ColorUtil.GREEN_DARK)
- Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消")
- else
- ok()
- end
- end
- elseif target == self.world_btn_obj then--上架到世界
- self:FinishSpecialHelp()
- if self.up_market_range == 2 then
- Message.show("该商品只能上架到社团拍卖哦~")
- else
- local function ok( ... )
- local data = self.data
- self.model:Fire(MarketModel.REQUEST_CCMD_EVENT,15506,data.goods_id,data.type_id, self.market_count,MarketModel.AUCTION_WORLD_TYPE, 1)
- self.model:Fire(MarketModel.CLOSE_MARKET_UP_SHELVES_VIEW)
- end
- local is_can_wear = EquipModel:getInstance():EquipCanShowGoodsTip(self.data)
- if is_can_wear then
- local ask_str = string.format("该装备可进行 <color=%s>穿戴</color> 或者 <color=%s>替换</color> 哦\n是否继续上架?", ColorUtil.GREEN_DARK,ColorUtil.GREEN_DARK)
- Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消")
- else
- ok()
- end
- end
- end
-
- end
- AddClickEvent(self.Toggle_obj, on_click)
- AddClickEvent(self.world_btn_obj, on_click)
- AddClickEvent(self.guild_btn_obj, on_click)
- end
-
- function MarketUpShelvesView:UpdateView( )
- local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.data.type_id)
- if goods_vo.trade_price == 0 then
- self.no_get_price = true
- self.one_text_tmp.text = "一口价"
- else
- self.no_get_price = false
- self.one_text_tmp.text = "起拍价"
- end
- --market_range--可上架区域,0表示社团和世界都可以上架,1表示只能上架世界,2表示只能上架社团
- self.up_market_range = goods_vo.market_range
- if self.up_market_range == 0 then
- self.guild_btn_imgex.gray = false
- self.world_btn_imgex.gray = false
- elseif self.up_market_range == 1 then
- self.guild_btn_imgex.gray = true
- self.world_btn_imgex.gray = false
- elseif self.up_market_range == 2 then
- self.guild_btn_imgex.gray = false
- self.world_btn_imgex.gray = true
- end
- local num = GoodsModel:getInstance():GetTypeGoodsUnlockNum(self.data.type_id, true)
- if goods_vo.type == GoodsModel.TYPE.EQUIP then--装备不可堆叠 只能1
- num = 1
- end
- self.addNumComponent:InitData(1, num, 1, 1, 6)
- --引导
- self:TriggerSpecialHelp()
- end
-
- function MarketUpShelvesView:SetData( data )
- self.data = data
- if self.is_loaded then
- self.need_refreshData = false
- self:UpdateView()
- else
- self.need_refreshData = true
- end
- end
-
- function MarketUpShelvesView:SetCountNum( count )
- self.market_count = count
- local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.data.type_id)
- if self.no_get_price then
- self.price_text_tmp.text = goods_vo.buyout_price * count
- else
- self.price_text_tmp.text = goods_vo.trade_price * count
- end
- end
-
-
- function MarketUpShelvesView:__delete( )
- if self.change_count_id then
- self.addNumComponent:UnBind(self.change_count_id)
- self.change_count_id = nil
- self.addNumComponent:DeleteMe()
- self.addNumComponent = nil
- end
- self:FinishSpecialHelp()
- end
-
-
- --上架引导
- function MarketUpShelvesView:TriggerSpecialHelp( )
- if self.data and self.data.has_special_guide then
- self.has_special_guide = true
- local button = self.world_btn_obj
- if button then
- local function call_back()
- end
- local helpVo = Config.ConfigHelper.Task[8000000002][2]
- helpVo.step = 2
- helpVo.task_id = 8000000002
- GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file)
- GlobalEventSystem:Fire(GuideModel.REQ_LIFELONG_HELPER_CHANGE, GuideModel.LIFELONG_TYPE.MARKET_SELL, 1)
- end
- end
- end
-
- --结束引导
- function MarketUpShelvesView:FinishSpecialHelp( )
- if self.has_special_guide then
- GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
- self.has_special_guide = false
- end
- end
|