源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

91 lines
2.9 KiB

SellView = SellView or BaseClass(BaseView)
function SellView:__init()
self.base_file = "bag"
self.layout_file = "SellView"
self.layer_name = "Activity"
self.use_background = true
self.click_bg_toClose= true
self.is_set_zdepth = true
self.load_callback = function ()
self:LocalSuccess()
end
self.open_callback = function ()
self:SetData()
end
self.destroy_callback = function ()
self:Remove()
end
end
function SellView:Remove()
if self.icon_item then
self.icon_item:DeleteMe()
self.icon_item = nil
end
if self.addNumComponent then
if self.change_count_id then
self.addNumComponent:UnBind(self.change_count_id)
self.change_count_id = nil
end
self.addNumComponent:DeleteMe()
self.addNumComponent = nil
end
end
function SellView:LocalSuccess()
self.icon_item = BagIconItem.New(self:GetChild("iconItem"))
self.icon_item:ChangeCountVisible(false)
self.nameText = self:GetChild("nameText"):GetComponent("Text")
self.moneyIcon = self:GetChild("moneyIcon"):GetComponent("Image")
self.moneyText = self:GetChild("moneyText"):GetComponent("Text")
self.sellBtn = self:GetChild("sellBtn").gameObject
self.addNumComponent = AddNumberComponent.New(self:GetChild("addNumCon"))
self:InitEvent()
end
function SellView:InitEvent()
local function onBtnClickHandler(target)
if target == self.sellBtn then
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15021,1,self.goods_vo.goods_id,self.addNumComponent:GetCurrCount(), self.goods_vo.type_id)
self:Close()
end
end
AddClickEvent(self.sellBtn,onBtnClickHandler)
local function onChangeCountHandler(count)
self:ChangeCount(count)
end
self.change_count_id = self.addNumComponent:Bind(ComponentEvent.AddNumberComponent.CHANGE_COUNT,onChangeCountHandler)
end
function SellView:Open(goods_vo)
self.goods_vo = goods_vo
BaseView.Open(self)
end
function SellView:SetData()
if self.goods_vo then
self.icon_item:SetData(self.goods_vo)
self.addNumComponent:InitData(1,self.goods_vo.goods_num,1,1,8)
self:ChangeCount(1)
local name = Trim(self.goods_vo.goods_name)
if self.goods_vo.type == 11 and (self.goods_vo.subtype == 10 or self.goods_vo.subtype == 11) then
local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(self.goods_vo.type_id, RoleManager.Instance.mainRoleInfo.career, self.goods_vo.color)
name = _name
end
self.nameText.text = "<color="..WordManager.GetGoodsColor(self.goods_vo.color)..">" .. name.."</color>"
local price_type = Config.Goodsprice[self.goods_vo.type_id] and Config.Goodsprice[self.goods_vo.type_id].sell_price_type or 3
local asset, source = WordManager:GetCommonMoneyIcon(tonumber(price_type))
lua_resM:setImageSprite(self, self.moneyIcon, asset, source, true)
end
end
function SellView:ChangeCount(count)
local price = GoodsModel:getInstance():GetSellPriceByTypeId(self.goods_vo.type_id)
self.moneyText.text = tonumber(price) * count
end