168 lines
5.2 KiB
Lua
168 lines
5.2 KiB
Lua
-- 玩家信息窗口(大厅点击头像进入)
|
|
|
|
local RealAddressView = import(".RealAddressView")
|
|
local PhoneBindView = import(".PhoneBindView")
|
|
local PhonePasswordView = import(".PhonePasswordView")
|
|
local WeChatView = import(".WeChatView")
|
|
local UserEditView = import(".UserEditView")
|
|
|
|
local LobbyHeadView = {}
|
|
|
|
local M = LobbyHeadView
|
|
|
|
function LobbyHeadView.new(user,agent,callback)
|
|
setmetatable(M, {__index = BaseWindow})
|
|
local self = setmetatable({}, {__index = M})
|
|
self.class = "LobbyHeadView"
|
|
self._user = user
|
|
self._agent = agent
|
|
--self._full = true
|
|
self._full_offset = false
|
|
self._animation = false
|
|
self._put_map = false
|
|
self._new_hide = false
|
|
self._queue = false
|
|
self.callback = callback
|
|
-- self:init("ui://Lobby/UserInfo")
|
|
|
|
return self
|
|
end
|
|
|
|
function M:fill_item(item_name, title, callback)
|
|
local item = self.user_info:GetChild(item_name)
|
|
local btn_opt = item:GetChild("btn_opt")
|
|
local ctr_c1 = item:GetController("c1")
|
|
if title then
|
|
item.text = title
|
|
ctr_c1.selectedIndex = 1
|
|
end
|
|
btn_opt.onClick:Set(function ()
|
|
callback()
|
|
end)
|
|
end
|
|
|
|
function M:fill_user_info()
|
|
local real_info = self._user.real_info
|
|
self:fill_item("item_real",real_info and real_info.name or nil,function ()
|
|
local real_view = RealAddressView.new(0,function ()
|
|
self:fill_user_info()
|
|
end)
|
|
real_view:Show()
|
|
end)
|
|
|
|
local address = self._user.address
|
|
self:fill_item("item_address",address,function ()
|
|
local real_view = RealAddressView.new(1,function ()
|
|
self:fill_user_info()
|
|
end)
|
|
real_view:Show()
|
|
end)
|
|
|
|
local phone = self._user.phone
|
|
self:fill_item("item_phone",phone and ViewUtil.phone_hide(phone) or nil,function ()
|
|
local phone_view = PhoneBindView.new(function ()
|
|
self:fill_user_info()
|
|
end)
|
|
phone_view:Show()
|
|
end)
|
|
|
|
local password = self._user.password
|
|
self:fill_item("item_password",password,function ()
|
|
-- if not phone then
|
|
-- ViewUtil.ShowTips("请绑定手机号")
|
|
-- return
|
|
-- end
|
|
local pw_view = PhonePasswordView.new(function()
|
|
self:fill_user_info()
|
|
end)
|
|
pw_view:Show()
|
|
end)
|
|
|
|
local invitation = self._user.invitation
|
|
local item_invte = self.user_info:GetChild("item_invte")
|
|
local ctr_invte = item_invte:GetController("c1")
|
|
ctr_invte.selectedIndex = invitation
|
|
ctr_invte.onChanged:Set(function ()
|
|
ViewUtil.ShowModalWait()
|
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
|
local _data = {}
|
|
_data.type =5
|
|
_data.invitation = ctr_invte.selectedIndex
|
|
loddyctr:UpdateUserInfo(_data,function( res)
|
|
ViewUtil.CloseModalWait()
|
|
if (res.ReturnCode ==0) then
|
|
DataManager.SelfUser.invitation = ctr_invte.selectedIndex
|
|
else
|
|
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
|
|
end
|
|
end)
|
|
end)
|
|
|
|
local acc = self._user.acc
|
|
self:fill_item("item_wx",acc and "(绑定:"..self._user.nick_name..")" or "",function ()
|
|
local wx_view = WeChatView.new(function()
|
|
self:fill_user_info()
|
|
end)
|
|
wx_view:Show()
|
|
end)
|
|
|
|
local _btn_logout = self._view:GetChild('btn_logout')
|
|
_btn_logout.onClick:Set(function()
|
|
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
|
|
_curren_msg.onOk:Add(function()
|
|
PlayerPrefs.DeleteKey('session_id')
|
|
PlayerPrefs.Save()
|
|
RestartGame()
|
|
end)
|
|
_curren_msg:Show()
|
|
end)
|
|
end
|
|
|
|
|
|
function M:ChangeToLogin()
|
|
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
|
|
_curren_msg.onOk:Add(function()
|
|
PlayerPrefs.DeleteKey('session_id')
|
|
PlayerPrefs.Save()
|
|
RestartGame()
|
|
end)
|
|
_curren_msg:Show()
|
|
end
|
|
|
|
function M:init(url)
|
|
BaseWindow.init(self,url)
|
|
self._close_destroy = true
|
|
self._close_zone = true
|
|
local view = self._view
|
|
|
|
local ctr_nav = view:GetController("nav")
|
|
--ctr_nav.selectedIndex = self._agent and 1 or 0
|
|
local ct_state = view:GetController("state")
|
|
view:GetChild("tex_nickname").text = self._user.nick_name
|
|
local str_playerid = self._user.account_id
|
|
view:GetChild("tex_id").text = "ID:"..str_playerid
|
|
|
|
|
|
local btn_head = view:GetChild("btn_head")
|
|
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
|
|
btn_head.onClick:Set(function()
|
|
local user_edit_view = UserEditView.new(function()
|
|
view:GetChild("tex_nickname").text = self._user.nick_name
|
|
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
|
|
self.callback()
|
|
end)
|
|
user_edit_view:Show()
|
|
end)
|
|
|
|
local ctr_load = view:GetController("load")
|
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
|
loddyCtr1:GetUserInfo(function(res)
|
|
if res.ReturnCode == 0 then
|
|
ctr_load.selectedIndex = 1
|
|
self:fill_user_info()
|
|
end
|
|
end)
|
|
self.user_info = view:GetChild("user_info")
|
|
end
|
|
|
|
return M |