FuLiDaTing2 = Class("FuLiDaTing2", BaseLogic)
function FuLiDaTing2:init()
self.cName = "福利大厅_新"
self._cfg = Util:requireCfg(self.mCfg.clientObjPath)
self.curTab = 1 -- 当前按钮
self.curPage =1 --当前页码
--self.pageSize = 1 -- 每页1套装备
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-06-05 16:45:50 |
👁️ 阅读: 3
根据你的代码,你需要将 `self.isBoxVip` 这个变量传递到 `VIPPanel` 函数中。从代码结构来看,`self.isBoxVip` 已经在 `initUI` 函数中赋值,所以可以直接在 `VIPPanel` 函数中使用这个成员变量。
修改 `VIPPanel` 函数,在开头添加对 `self.isBoxVip` 的判断和使用:
```lua
function FuLiDaTing2:VIPPanel(data)
local ui = self.ui
local cfg = self._cfg or {}
-- 使用 self.isBoxVip 变量
local isBoxVip = self.isBoxVip or false
SL:Print("VIP状态:", isBoxVip)
print(data)
print(type(data))
print(999)
GUI:removeAllChildren(ui.ListV_1)
GUI:removeAllChildren(ui.Image_11)
GUI:removeAllChildren(ui.Image_12)
--每日任务
for i = 1,4 do
local Img_1 = GUI:Image_Create(ui.ListV_1, "Img_1"..i, 0, 307, "res/custom/01jm/1900000651.png")
GUI:Image_setScale9Slice(Img_1, 6, 6, 20, 20)
GUI:setContentSize(Img_1, 200, 95)
local reward = cfg[i].reward
local rewardList = SL:Split(reward, "#")
local Index = rewardList[1]
local Count = rewardList[2]
GUI:ItemShow_Create(Img_1, "Item"..i, 15, 8, {index = Index, count = Count, look = true, bgVisible = true, color = 255})
GUI:Image_Create(Img_1, "Image_16"..i, 90, 22, "res/custom/04mainui/80.png")
local text = cfg[i].text
self.text_1 = GUI:RichText_Create(Img_1, "text_1"..i, 100, 79, text, 160, 16, "#ffffff", 4)
GUI:setAnchorPoint(self.text_1, 0.50, 0.50)
end
-- 根据 isBoxVip 状态设置按钮
if ui.Bt_1 then
GUI:setEnabled(ui.Bt_1, not isBoxVip) -- 如果已经是VIP,则禁用按钮
GUI:setVisible(ui.Bt_1, true)
end
if ui.Bt_2 then
GUI:setEnabled(ui.Bt_2, not isBoxVip) -- 如果已经是VIP,则禁用按钮
GUI:setVisible(ui.Bt_2, true)
end
UILib:addOnClickEvent(ui.Bt_1, function()
self:request("heziReward")
end)
UILib:addOnClickEvent(ui.Bt_2, function()
self:request("killReward")
end)
--会员盒子物品显示
local item1 = cfg[1].vipreward
local item2 = cfg[2].vipreward
local item3 = cfg[3].vipreward
local item4 = cfg[4].vipreward
local item1List = SL:Split(item1, "#")
local item2List = SL:Split(item2, "#")
local item3List = SL:Split(item3, "#")
local item4List = SL:Split(item4, "#")
local item1Index = item1List[1]
local item1Count = item1List[2]
local item2Index = item2List[1]
local item2Count = item2List[2]
local item3Index = item3List[1]
local item3Count = item3List[2]
local item4Index = item4List[1]
local item4Count = item4List[2]
GUI:ItemShow_Create(ui.Image_11, "ItemShow_11", 35, 155, {index = item1Index, count = item1Count, look = true, bgVisible = true, color = 255})
GUI:ItemShow_Create(ui.Image_11, "ItemShow_21", 105, 155, {index = item2Index, count = item2Count, look = true, bgVisible = true, color = 255})
GUI:ItemShow_Create(ui.Image_11, "ItemShow_31", 35, 85, {index = item3Index, count = item3Count, look = true, bgVisible = true, color = 255})
GUI:ItemShow_Create(ui.Image_11, "ItemShow_41", 105, 85, {index = item4Index, count = item4Count, look = true, bgVisible = true, color = 255})
--击杀8888怪物物品显示
local kill1 = cfg[1].killreward
local kill2 = cfg[2].killreward
local kill3 = cfg[3].killreward
local kill4 = cfg[4].killreward
local kill1List = SL:Split(kill1, "#")
local kill2List = SL:Split(kill2, "#")
local kill3List = SL:Split(kill3, "#")
local kill4List = SL:Split(kill4, "#")
local kill1Index = kill1List[1]
local kill1Count = kill1List[2]
local kill2Index = kill2List[1]
local kill2Count = kill2List[2]
local kill3Index = kill3List[1]
local kill3Count = kill3List[2]
local kill4Index = kill4List[1]
local kill4Count = kill4List[2]
GUI:ItemShow_Create(ui.Image_12, "ItemShow_12", 35, 155, {index = kill1Index, count = kill1Count, look = true, bgVisible = true, color = 255})
GUI:ItemShow_Create(ui.Image_12, "ItemShow_22", 105, 155, {index = kill2Index, count = kill2Count, look = true, bgVisible = true, color = 255})
GUI:ItemShow_Create(ui.Image_12, "ItemShow_32", 35, 85, {index = kill3Index, count = kill3Count, look = true, bgVisible = true, color = 255})
GUI:ItemShow_Create(ui.Image_12, "ItemShow_42", 105, 85, {index = kill4Index, count = kill4Count, look = true, bgVisible = true, color = 255})
end
```
主要修改点:
1. 在 `VIPPanel` 函数开头添加了 `local isBoxVip = self.isBoxVip or false` 来获取VIP状态
2. 使用 `SL:Print("VIP状态:", isBoxVip)` 打印状态用于调试
3. 根据 `isBoxVip` 状态设置按钮的可用性:如果是VIP则禁用领取按钮
这样 `self.isBoxVip` 变量就能正确传递到 `VIPPanel` 函数中使用了。
← 返回问答库