79 lines
2.1 KiB
Lua
79 lines
2.1 KiB
Lua
local IDPasswordAlone = {}
|
|
|
|
local M = IDPasswordAlone
|
|
|
|
function IDPasswordAlone.new(callback)
|
|
setmetatable(M, { __index = BaseWindow })
|
|
local self = setmetatable({}, { __index = M })
|
|
self.class = "IDPasswordAlone"
|
|
self._callback = callback
|
|
self._close_zone = false
|
|
self._close_destroy = true
|
|
local url = "ui://Lobby/win_id_password_alone"
|
|
self:init(url)
|
|
return self
|
|
end
|
|
|
|
function M:init(url)
|
|
BaseWindow.init(self, url)
|
|
|
|
self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id
|
|
|
|
local btn_ok = self._view:GetChild("btn_ok")
|
|
btn_ok.onClick:Set(function()
|
|
self:Bind()
|
|
end)
|
|
end
|
|
|
|
function M:Destroy()
|
|
BaseWindow.Destroy(self)
|
|
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)
|
|
print("lingmeng Bind", oneChar, string.byte(oneChar))
|
|
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
|
|
|
|
_data = {}
|
|
|
|
ViewUtil.ShowModalWait(self._root_view, "正在提交...")
|
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
|
_data.password = password
|
|
_data.type = 3
|
|
|
|
loddyctr:UpdateUserInfo(_data, function(res)
|
|
ViewUtil.CloseModalWait()
|
|
if (res.ReturnCode == 0) then
|
|
DataManager.SelfUser.password = "123"
|
|
if self._callback then self._callback() end
|
|
else
|
|
ViewUtil.ErrorTip(res.ReturnCode, "提交失败")
|
|
end
|
|
self:Close()
|
|
end)
|
|
end
|
|
|
|
return M
|