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

110 lines
3.7 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 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:init('ui://Lobby/PlayerInfo')
return self
end
function M:init(url)
BaseWindow.init(self, url)
local view = self._view
local user = self.user;
-- print("================phone=====================")
for k, v in pairs(user) do
-- print(string.format("k:%s|v:%s", k, v))
end
--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
ImageLoad.Load(DataManager.SelfUser.head_url, view:GetChild("btn_PlayerHead")._iconObject)
--change
view:GetChild('choose_id').text = user.account_id
view:GetChild('choose_diamo').text = user.diamo
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
self.Lable_phone = view:GetChild('Lable_phone'):GetChild('text')
local bind = view:GetController('bind')
if user.phone then
bind.selectedIndex = 1
self.Lable_phone.text = user.phone
else
bind.selectedIndex = 0
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()
bind.selectedIndex = 1
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)
end
return M