hengyang_client/lua_probject/base_project/Game/View/Family/FamilyMyFamily.lua

188 lines
5.5 KiB
Lua

--region LOCAL
local FamilyMyFamily = {}
local root = {}
local rootLastIndex = 0
local function HideMainView()
rootLastIndex = root.familyType.selectedIndex
root.familyType.selectedIndex = 0
end
local function ShowMainView()
root.familyType.selectedIndex = rootLastIndex or 1
end
local function SetRelation(self)
local contentPane = self._root_view:GetChild("contentPane")
--contentPane:RemoveRelation(self._root_view, RelationType.Center_Center)
contentPane.relations:ClearAll()
contentPane:AddRelation(self._root_view, RelationType.Width)
contentPane:AddRelation(self._root_view, RelationType.Height)
end
--endregion
function FamilyMyFamily:TryShow(r)
self:Init()
root = r
self:Show()
end
function FamilyMyFamily:Show()
local family = root._group
--pt(family)
if not family then
-- 跳转创建家族界面
root:CreateFamily()
return
end
self:Refalsh()
HideMainView()
BaseWindow.Show(self)
end
function FamilyMyFamily:Close()
BaseWindow.Close(self)
ShowMainView()
end
function FamilyMyFamily:Refalsh()
local family = root._group
self.tex_fName.text = family.name
self.tex_playerName.text = "亲友圈号:" .. family.id
self.tex_fNumber.text = family.member_num
self.tex_cradNum.text = family.diamo
self.tex_nocice.text = family.notice
ImageLoad.Load(family.o_portrait, self.loader_icon)
self.cStyle.selectedIndex = family.lev -1
end
function FamilyMyFamily:Init()
setmetatable(FamilyMyFamily, { __index = BaseWindow })
BaseWindow.init(self, 'ui://Family/com_myFamily')
-- 设置成组件的形式
self._close_destroy = true
self._full = true
self._animation = false
self._root_view:GetChild("win_mode").visible = false
self._view:GetChild("btn_close").onClick:Set(function()
self:Close()
end)
self.loader_icon = self._view:GetChild("loader_icon")
self.tex_fName = self._view:GetChild("tex_fName")
self.tex_wxId = self._view:GetChild("tex_wxId")
self.tex_fNumber = self._view:GetChild("tex_fNumber")
self.tex_cradNum = self._view:GetChild("tex_cradNum")
self.tex_nocice = self._view:GetChild("tex_nocice")
self.tex_playerName = self._view:GetChild("tex_playerName")
self.btn_quitFamily = self._view:GetChild("btn_quitFamily")
self.btn_playSet = self._view:GetChild("btn_playSet")
self.btn_invite = self._view:GetChild("btn_invite")
self.btn_czRecord = self._view:GetChild("btn_czRecord")
self.btn_applyMsg = self._view:GetChild("btn_applyMsg")
self.btn_buyCrad = self._view:GetChild("btn_buyCrad")
self.btn_checkNumber = self._view:GetChild("btn_checkNumber")
self.btn_editNotice = self._view:GetChild("btn_editNotice")
self.btn_quitNotice = self._view:GetChild("btn_quitNotice")
self.btn_bgNotice = self._view:GetChild("btn_bgNotice")
self.btn_confirmNotice = self._view:GetChild("btn_confirmNotice")
self.input_notice = self._view:GetChild("input_notice")
self.cStyle = self._view:GetController("cStyle")
self.cWindow = self._view:GetController("cWindow")
self.btn_playSet.onClick:Set(function()
self:Close()
root:PlayEdit()
end)
self.btn_invite.onClick:Set(function()
self:Close()
root:ShareWx()
end)
self.btn_buyCrad.onClick:Set(function()
self:Close()
root:ShowShop()
end)
self.btn_checkNumber.onClick:Set(function()
self:Close()
root:AllNumber()
end)
self.btn_applyMsg.onClick:Set(function()
self:Close()
root:AuditNumber()
end)
self.btn_quitFamily.onClick:Set(function()
local fgCtr = ControllerManager.GetController(NewGroupController)
print("发送了退出协议 familyid = ",root._group.id)
fgCtr:FG_ExitGroup(root._group.id, function(res)
pt(res)
end)
end)
self.btn_quitNotice.onClick:Set(function()
self.cWindow.selectedIndex = 0
end)
self.btn_bgNotice.onClick:Set(function()
self.cWindow.selectedIndex = 0
end)
self.btn_editNotice.onClick:Set(function()
self.cWindow.selectedIndex = 1
end)
self.btn_confirmNotice.onClick:Set(function()
local family = root._group
local fgCtr = ControllerManager.GetController(NewGroupController)
fgCtr:FG_UpdateGroupInfo(
family.id,
family.name,
self.input_notice.text,
not family.ban,
family.dissolve_opt,
family.kick_opt,
family.apply,
family.ban_chat1,
family.ban_chat2,
family.option,
0,
function(res)
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode, "更改公告失败,请稍后再试")
else
ViewUtil.ErrorTip(res.ReturnCode, "修改成功!")
self:Refalsh()
end
end
)
end)
SetRelation(self)
print(string.format("myfamily x=%s height=%s", self._view.x, self._view.y))
print(string.format("myfamily width=%s height=%s", self._view.width, self._view.height))
print(string.format("myfamilyroot width=%s height=%s", self._root_view.width, self._root_view.height))
print(string.format("myfamilyroot x=%s y=%s", self._root_view.x, self._root_view.y))
--print(string.format("familyrootParent x=%s y=%s", self._root_view.parent.width, self._root_view.parent.height))
return self
end
return FamilyMyFamily