CloudShopOddsView = CloudShopOddsView or BaseClass(BaseView) function CloudShopOddsView:__init() self.base_file = "cloudShopping" self.layout_file = "CloudShopOddsView" self.layer_name = "Activity" -- self.use_local_view = true self.close_mode = CloseMode.CloseDestroy self.change_scene_close = true self.destroy_imm = true self.use_background = true self.is_set_zdepth = true self.change_scene_close = true self.model = CustomActivityModel:getInstance() self.item_list = {} self.load_callback = function() self:LoadSuccess() self:InitEvent() end self.open_callback = function() self:SetData() end self.close_callback = function() end self.destroy_callback = function() self:Remove() end end function CloudShopOddsView:Remove() for i, item in pairs(self.item_list) do item:DeleteMe() end self.item_list = {} self.model = nil end function CloudShopOddsView:Open(index) BaseView.Open(self) end function CloudShopOddsView:LoadSuccess() self.content = GetChildTransforms(self.transform, { "ScrollView/Viewport/Content" }) end function CloudShopOddsView:InitEvent() end function CloudShopOddsView:SetData() local data = self.model:GetCloudShoppingInfo() if data then local cfg = Config.Cloudbuy[data.big_reward_id] if cfg then local total_weight = 0 local happy_awards = ErlangParser:GetInstance():Parse(cfg.happy_awards) for _, v in pairs(happy_awards) do total_weight = total_weight + tonumber(v[1]) end table.sort(happy_awards, function (a, b) return tonumber(a[2]) < tonumber(b[2]) end) self.content.sizeDelta = Vector2(400, 62 * #happy_awards) for i, v in ipairs(happy_awards) do local item = self.item_list[i] if not item then item = CloudShopOddsItem.New(self.content) self.item_list[i] = item end item:SetData(total_weight, v) item:SetPosition(0, -62 * (i - 1)) end end end end