local IDPasswordAlone = {} local M = IDPasswordAlone --黑体字提示 local Tips1 = { { "当前账号未设置密码,为了您的账号安全请设置密码", "若您为旧用户或者当前账号不属于你,点击左上角可以找回账号" }, { "请输入正确的账号和密码,若忘记请联系客服人员" } } --红字提示 local Tips1 = { { "注:初始账号将强制要求设置密码" }, { "注:找回账号功能会删除现有账户,请勿随便使用" } } 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) local text_id = self._view:GetChild("tex_phone") local tex_passwd = self._view:GetChild("tex_passwd") text_id.text = DataManager.SelfUser.account_id local ctr_retrieve = self._view:GetController('retrieve') ctr_retrieve.onChanged:Set(function(context) if ctr_retrieve.selectedIndex == 0 then text_id.text = DataManager.SelfUser.account_id tex_passwd.text = "" else text_id.text = "" tex_passwd.text = "" end end) local btn_ok = self._view:GetChild("btn_ok") btn_ok.onClick:Set(function() if ctr_retrieve.selectedIndex == 0 then self:Bind() else self:Retrieve() end 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 local _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 --找回账号 function M:Retrieve() local tex_phone = self._view:GetChild("tex_phone") local text_id = tex_phone.text local tex_passwd = self._view:GetChild("tex_passwd") local password = tex_passwd.text local _data = {} ViewUtil.ShowModalWait(self._root_view, "正在提交...") local loddyctr = ControllerManager.GetController(LoddyController) _data.password = password _data.id = tonumber(text_id) loddyctr:RetrievePassword(_data, function(res) ViewUtil.CloseModalWait() if res.ReturnCode == 0 then PlayerPrefs.DeleteKey('session_id') ViewUtil.CloseModalWait() local _curren_msg = MsgWindow.new(self._root_view, "您的账号已经切换,请重新登录", MsgWindow.MsgMode.OnlyOk, nil, nil, { closeZone = true }) _curren_msg.onOk:Add( function() Application.Quit() end ) _curren_msg:Show() else ViewUtil.ErrorTip(res.ReturnCode, "找回账号失败,请联系客服人员") end end) end return M