hengyang_client/lua_probject/base_project/Game/View/Lobby/LobbyPlayerInfoView.lua

143 lines
4.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--设置窗口对象
local PasswordUpdateView = import(".PasswordUpdateView")
local LobbyPlayerInfoView = {}
local M = LobbyPlayerInfoView
setmetatable(M, { __index = BaseWindow })
function LobbyPlayerInfoView.new(user, callback)
local self = setmetatable({}, { __index = M })
self.class = 'LobbyPlayerInfoView'
self._close_destroy = true
self.user = user
self._callback = callback
self._loadAll = 0
self:init('ui://Lobby/PlayerInfo')
return self
end
function M:init(url)
BaseWindow.init(self, url)
local view = self._view
local user = self.user;
--show
view:GetChild('name').text = user.nick_name
view:GetChild('phone').text = user.phone
view:GetChild('id').text = user.account_id
view:GetChild('diamo').text = user.diamo
view:GetChild('sex').text = user.sex == 1 and "" or ""
view:GetController('ctr_sex').selectedIndex = user.sex - 1
view:GetChild('ip').text = DataManager.SelfUser.currenIp
ImageLoad.Load(DataManager.SelfUser.head_url, view:GetChild("btn_PlayerHead")._iconObject)
if DataManager.SelfUser.currenIp then
self._loadAll = self._loadAll + 1
else
GameApplication.Instance:GetPublicIP(function(ip)
DataManager.SelfUser.currenIp = ip
view:GetChild('ip').text = DataManager.SelfUser.currenIp
self:CheckAllload()
end)
end
--change
view:GetChild('choose_id').text = user.account_id
view:GetChild('choose_diamo').text = user.diamo
-- if user.phone and #user.phone == 11 then
-- self._view:GetChild('btn_changeInfo').visible = false
-- self._view:GetChild('btn_changeInfo').touchable = false
-- end
self.Lable_name = view:GetChild('Lable_name'):GetChild('text')
self.Lable_name.text = user.nick_name
self.group_sex = view:GetController('group_sex')
self.group_sex.selectedIndex = user.sex - 1
self.Lable_phone = view:GetChild('Lable_phone'):GetChild('text')
local bind = view:GetController('bind')
if user.phone then
self.Lable_phone.text = user.phone
else
self.Lable_phone.text = ""
end
view:GetChild('btn_headChange').onClick:Add(function()
local guo_msg = MsgWindow.new(self._root_view, "暂不支持更换头像", MsgWindow.MsgMode.OnlyOk)
guo_msg:Show()
end)
view:GetChild('btn_changePhone').onClick:Add(function()
local guo_msg = MsgWindow.new(self._root_view, "绑定页面正在优化中,请稍后绑定", MsgWindow.MsgMode.OnlyOk)
guo_msg:Show()
end)
view:GetChild('btn_bindPhone').onClick:Add(function()
local guo_msg = MsgWindow.new(self._root_view, "绑定页面正在优化中,请稍后绑定", MsgWindow.MsgMode.OnlyOk)
guo_msg.onOk(function()
end)
guo_msg:Show()
end)
local type = view:GetController('type')
view:GetChild('btn_save').onClick:Add(function()
local cnt = 0
if self.Lable_name.text ~= user.nick_name then
cnt = 1
end
if self.group_sex.selectedIndex ~= tonumber(user.sex) then
cnt = cnt + 2
end
if cnt > 0 then
local guo_msg = MsgWindow.new(self._root_view,
string.format("确定要修改%s%s%s吗", cnt % 2 == 1 and "昵称" or "", cnt == 3 and "" or "",
cnt >= 2 and "性别" or ""), MsgWindow.MsgMode.OnlyOk)
guo_msg.onOk(function()
type.selectedIndex = 0
end)
guo_msg:Show()
else
type.selectedIndex = 0
end
end)
view:GetController('ctr_sex').onChanged:Set(function(context)
user.sex = context.sender.selectedIndex + 1
ViewUtil.ShowModalWait2(self._root_view)
local loddyctr = ControllerManager.GetController(LoddyController)
local _data = {}
_data.sex = context.sender.selectedIndex + 1
_data.type = 7
loddyctr:UpdateUserInfo(_data, function(res)
ViewUtil.CloseModalWait2()
if (res.ReturnCode == 0) then
else
ViewUtil.ErrorTip(res.ReturnCode, "切换性别失败")
end
end)
end)
local pswType = DataManager.SelfUser.havaPsw and 1 or 0
local btn_changeInfo = self._view:GetChild('btn_changeInfo')
btn_changeInfo:GetController('type').selectedIndex = pswType
btn_changeInfo.onClick:Set(function()
local passwordUpdateView = PasswordUpdateView.new(pswType, function(res)
pswType = DataManager.SelfUser.havaPsw and 1 or 0
btn_changeInfo:GetController('type').selectedIndex = pswType
end)
passwordUpdateView:Show()
end)
local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:GetUserInfo(function(res)
if res.ReturnCode == 0 then
self:CheckAllload()
end
end)
end
function M:CheckAllload()
self._loadAll = self._loadAll + 1
if self._loadAll >= 2 then
self:Show()
end
end
return M