源战役客户端
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.
 
 
 
 
 

69 lines
2.1 KiB

CloudShopOddsItem = CloudShopOddsItem or BaseClass(BaseItem)
function CloudShopOddsItem:__init()
self.base_file = "cloudShopping"
self.layout_file = "CloudShopOddsItem"
-- self.use_local_view = true
self.is_delay_callback = true
self:Load()
end
--清除界面
function CloudShopOddsItem:__delete()
end
function CloudShopOddsItem:Load_callback()
self:LoadSuccess()
self:InitEvent()
if self.need_refreshData then
self:SetData(self.total_weight, self.prop)
end
end
function CloudShopOddsItem:LoadSuccess()
self.name_text,
self.odds_text
= GetChildTexts(self.transform, {
"nameText",
"oddsText"
})
end
function CloudShopOddsItem:InitEvent()
end
function CloudShopOddsItem:SetData(total_weight, prop)
self.total_weight = total_weight
self.prop = prop
if self.is_loaded then
self.need_refreshData = false
local my_wieght = tonumber(prop[1])
local goods_indext = tonumber(prop[2])
local cfg = Config.Cloudbuyreward[goods_indext]
if cfg then
local reward_list = ErlangParser:GetInstance():Parse(cfg.reward_list)
local type_id = reward_list[1] and tonumber(reward_list[1][2])
if cfg.reward_type == 2 then --按职业区分
local career = RoleManager.Instance:GetMainRoleVo().career
for _,v in pairs(reward_list) do
if career == tonumber(v[1]) then
type_id = tonumber(v[2][1][2])
break
end
end
else
type_id = reward_list[1] and tonumber(reward_list[1][2])
end
if type_id then
local basic = GoodsModel.Instance:GetGoodsBasicByTypeId(type_id)
self.name_text.text = basic and "<color="..WordManager.GetGoodsColor(basic.color) ..">".. basic.goods_name.."</color>" or ""
end
end
self.odds_text.text = string.format("<color=#4eae1a>%.2f%%</color>",(my_wieght / total_weight * 100))
else
self.need_refreshData = true
end
end