120 lines
3.7 KiB
Lua
120 lines
3.7 KiB
Lua
|
|
local SelectAcc = {}
|
||
|
|
|
||
|
|
local M = SelectAcc
|
||
|
|
|
||
|
|
function SelectAcc.new(data, callback)
|
||
|
|
setmetatable(M, { __index = BaseWindow })
|
||
|
|
local self = setmetatable({}, { __index = M })
|
||
|
|
self.class = "SelectAcc"
|
||
|
|
self._callback = callback
|
||
|
|
self._close_zone = false
|
||
|
|
self._close_destroy = true
|
||
|
|
self._data = data
|
||
|
|
local url = "ui://Lobby/win_selectAccont"
|
||
|
|
self:init(url)
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:init(url)
|
||
|
|
getmetatable(M).__index.init(self, url)
|
||
|
|
local lobbyCtr1 = ControllerManager.GetController(LoddyController)
|
||
|
|
|
||
|
|
local user = DataManager.SelfUser
|
||
|
|
self._view:GetChild('text_nick').text = user.nick_name
|
||
|
|
self._view:GetChild('text_id').text = user.account_id
|
||
|
|
ImageLoad.Load(user.head_url, self._view:GetChild('head_url'))
|
||
|
|
|
||
|
|
self._view:GetChild('btn_ok').onClick:Set(function()
|
||
|
|
self._view:GetController('choose').selectedIndex = 1
|
||
|
|
end)
|
||
|
|
|
||
|
|
self._view:GetChild('btn_cancle').onClick:Set(function()
|
||
|
|
self:Destroy()
|
||
|
|
end)
|
||
|
|
|
||
|
|
self._list_acc = self._view:GetChild('list_acc')
|
||
|
|
self._list_acc:SetVirtual()
|
||
|
|
self._list_acc.itemRenderer = function(index, obj)
|
||
|
|
ImageLoad.Load(self._resData[index + 1].portrait, obj._iconObject)
|
||
|
|
obj:GetChild('text_id').text = self._resData[index + 1].id
|
||
|
|
obj:GetChild('text_name').text = self._resData[index + 1].nick
|
||
|
|
obj:GetChild('btn_bing').onClick:Set(function(context)
|
||
|
|
self._view:GetChild('tex_phone').text = self._resData[index + 1].id
|
||
|
|
self._view:GetController('choose').selectedIndex = 2
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
self._view:GetChild('btn_ok_pws').onClick:Set(function()
|
||
|
|
self:Bind()
|
||
|
|
end)
|
||
|
|
|
||
|
|
self._view:GetChild('btn_cancel_pws').onClick:Set(function()
|
||
|
|
self._view:GetController('choose').selectedIndex = 1
|
||
|
|
end)
|
||
|
|
|
||
|
|
self:initInfo()
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:initInfo()
|
||
|
|
local lobbyCtr1 = ControllerManager.GetController(LoddyController)
|
||
|
|
lobbyCtr1:GetAccInfo({}, function(res)
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode)
|
||
|
|
return
|
||
|
|
end
|
||
|
|
self._resData = res.Data.accounts
|
||
|
|
self._list_acc.numItems = #self._resData
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:Bind()
|
||
|
|
local tex_passwd = self._view:GetChild("tex_passwd")
|
||
|
|
local password = tex_passwd.text
|
||
|
|
if string.len(password) < 6 then
|
||
|
|
ViewUtil.ShowTips("请输入5位以上的密码")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
-- local flg_xiaozimu = false
|
||
|
|
-- local flg_dazimu = false
|
||
|
|
-- local fla_shuzi = false
|
||
|
|
-- for i = 1, #password do
|
||
|
|
-- local oneChar = string.sub(password, i, i)
|
||
|
|
-- if string.byte(oneChar) >= 65 and string.byte(oneChar) <= 90 then
|
||
|
|
-- flg_dazimu = true
|
||
|
|
-- elseif string.byte(oneChar) >= 97 and string.byte(oneChar) <= 122 then
|
||
|
|
-- flg_xiaozimu = true
|
||
|
|
-- elseif string.byte(oneChar) >= 48 and string.byte(oneChar) <= 57 then
|
||
|
|
-- fla_shuzi = true
|
||
|
|
-- end
|
||
|
|
-- end
|
||
|
|
-- if not (flg_xiaozimu or flg_dazimu) then
|
||
|
|
-- ViewUtil.ShowTips("密码必须包含字母")
|
||
|
|
-- return
|
||
|
|
-- end
|
||
|
|
|
||
|
|
local _data = {}
|
||
|
|
|
||
|
|
ViewUtil.ShowModalWait(self._root_view, "正在提交...")
|
||
|
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||
|
|
_data.password = password
|
||
|
|
_data.tagId = tonumber(self._view:GetChild("tex_phone").text)
|
||
|
|
|
||
|
|
loddyctr:SetAccInfo(_data, function(res)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "密码错误")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
PlayerPrefs.DeleteKey('session_id')
|
||
|
|
PlayerPrefs.Save()
|
||
|
|
RestartGame()
|
||
|
|
self:Destroy()
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:Destroy()
|
||
|
|
BaseWindow.Destroy(self)
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|