110 lines
3.4 KiB
Lua
110 lines
3.4 KiB
Lua
local data = {
|
||
{ num = 50, colorIndex = 0 },
|
||
{ num = 200, colorIndex = 1 },
|
||
{ num = 1000, colorIndex = 2 },
|
||
}
|
||
|
||
--#region
|
||
|
||
local FamilyRoomCard = {}
|
||
|
||
local function charge(num, self)
|
||
local _curren_msg =
|
||
MsgWindow.new(
|
||
self._root_view,
|
||
string.format('确定要向该亲友圈里充值%d房卡?', num),
|
||
MsgWindow.MsgMode.OkAndCancel
|
||
)
|
||
_curren_msg.onOk:Add(
|
||
function()
|
||
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
fgCtr:FG_Recharge_Diamo(self.groupId, num, function(res)
|
||
if res.ReturnCode ~= 0 then
|
||
ViewUtil.ErrorTip(res.ReturnCode, "重置房卡操作失败")
|
||
return
|
||
end
|
||
ViewUtil.ErrorTip(-1, "房卡充值成功")
|
||
local groupDiamo = res.Data.groupDiamo
|
||
local playerDiamo = res.Data.userDiamo
|
||
self.tex_curCard.text = "当前帐号房卡:" .. playerDiamo
|
||
self.tex_famliyCard.text = "亲友圈房卡:" .. groupDiamo
|
||
self.group.groupDiamo = groupDiamo
|
||
DataManager.SelfUser.diamo = playerDiamo
|
||
self:Destroy()
|
||
end)
|
||
end
|
||
)
|
||
_curren_msg:Show()
|
||
end
|
||
|
||
--#endregion
|
||
|
||
function FamilyRoomCard:TryShow(groupId)
|
||
local Instance = self.New()
|
||
Instance:Show(groupId)
|
||
end
|
||
|
||
function FamilyRoomCard.New()
|
||
setmetatable(FamilyRoomCard, { __index = BaseWindow })
|
||
local Instance = setmetatable({}, { __index = FamilyRoomCard })
|
||
BaseWindow.init(Instance, "ui://Family/com_roomCard")
|
||
|
||
Instance._close_destroy = true
|
||
Instance.btn_close = Instance._view:GetChild("btn_close")
|
||
Instance.list_bayCrad = Instance._view:GetChild("list_bayCrad")
|
||
Instance.tex_curCard = Instance._view:GetChild('tex_curCard')
|
||
Instance.tex_famliyCard = Instance._view:GetChild("tex_famliyCard")
|
||
|
||
Instance.btn_close.onClick:Set(function()
|
||
Instance:Close()
|
||
end)
|
||
|
||
Instance.list_bayCrad.itemRenderer = function(index, obj)
|
||
local _idx = index + 1
|
||
local num = data[_idx].num
|
||
|
||
obj:GetChild("tex_cardNum").text = num
|
||
obj:GetController("cColor").selectedIndex = data[_idx].colorIndex
|
||
|
||
obj.onClick:Set(function()
|
||
if Instance.group and Instance.group ~= 1 then
|
||
local _curren_msg =
|
||
MsgWindow.new(
|
||
Instance._root_view,
|
||
"只有管理员可以充值",
|
||
MsgWindow.MsgMode.OnlyOk
|
||
)
|
||
_curren_msg:Show()
|
||
return
|
||
end
|
||
if DataManager.SelfUser.diamo < num then
|
||
local _curren_msg =
|
||
MsgWindow.new(
|
||
Instance._root_view,
|
||
"您的房卡不足",
|
||
MsgWindow.MsgMode.OnlyOk
|
||
)
|
||
_curren_msg:Show()
|
||
else
|
||
charge(num, Instance)
|
||
end
|
||
end)
|
||
end
|
||
|
||
Instance.list_bayCrad.numItems = #data
|
||
|
||
return Instance
|
||
end
|
||
|
||
function FamilyRoomCard:Show(groupId)
|
||
self.groupId = groupId
|
||
self.group = DataManager.groups:get(self.groupId)
|
||
|
||
self.tex_curCard.text = "当前帐号房卡:" .. DataManager.SelfUser.diamo
|
||
self.tex_famliyCard.text = "亲友圈房卡:" .. self.group.groupDiamo
|
||
|
||
BaseWindow.Show(self)
|
||
end
|
||
|
||
return FamilyRoomCard
|