Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPLogin.lua
2020-07-09 08:50:24 +08:00

151 lines
5.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---@type IDBasePanel
local IDBasePanel = require("ui.panel.TRBasePanel")
---@class TRPLogin:IDBasePanel 邮件列表
local TRPLogin = class("TRPLogin", IDBasePanel)
local uiobjs = {}
-- 初始化,只会调用一次
function TRPLogin:init(csObj)
TRPLogin.super.init(self, csObj)
self:setEventDelegate()
---@type CLUIFormRoot
uiobjs.formRoot = self.csSelf:GetComponent("CLUIFormRoot")
uiobjs.InputPhoneNum = getCC(self.transform, "InputPhoneNum", "UIInput")
uiobjs.InputPassword = getCC(self.transform, "InputPassword", "UIInput")
---@type UIButton
uiobjs.ButtonLogin = getCC(self.transform, "ButtonLogin", "UIButton")
---@type UISprite
uiobjs.ButtonLoginBg = uiobjs.ButtonLogin:GetComponent("UISprite")
uiobjs.ButtonDelPhoneNum = getChild(uiobjs.InputPhoneNum.transform, "ButtonDelPhoneNum")
uiobjs.ButtonDelPassword = getChild(uiobjs.InputPassword.transform, "ButtonDelPassword")
end
-- 设置数据
---@param paras _ParamTRPLogin
function TRPLogin:setData(paras)
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPLogin:show()
uiobjs.formRoot:setValue({})
uiobjs.InputPassword.value = Prefs.getUserPsd()
uiobjs.InputPhoneNum.value = Prefs.getUserName()
SetActive(uiobjs.ButtonDelPassword.gameObject, false)
SetActive(uiobjs.ButtonDelPhoneNum.gameObject, false)
self:getsetButtonloginState()
end
-- 刷新
function TRPLogin:refresh()
end
-- 关闭页面
function TRPLogin:hide()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPLogin:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
--[[
if cmd == xx then
end
]]
end
end
function TRPLogin:onInputPhoneNumChg()
self:getsetButtonloginState()
-- if isNilOrEmpty(uiobjs.InputPhoneNum.value) then
-- SetActive(uiobjs.ButtonDelPhoneNum.gameObject, false)
-- else
-- SetActive(uiobjs.ButtonDelPhoneNum.gameObject, true)
-- end
end
function TRPLogin:onInputPasswordChg()
self:getsetButtonloginState()
-- if isNilOrEmpty(uiobjs.InputPassword.value) then
-- SetActive(uiobjs.ButtonDelPassword.gameObject, false)
-- else
-- SetActive(uiobjs.ButtonDelPassword.gameObject, true)
-- end
end
function TRPLogin:getsetButtonloginState()
if (isNilOrEmpty(uiobjs.InputPhoneNum.value) or isNilOrEmpty(uiobjs.InputPassword.value)) then
-- uiobjs.ButtonLogin.isEnabled = false
uiobjs.ButtonLoginBg.alpha = 0.65
return false
end
-- uiobjs.ButtonLogin.isEnabled = true
uiobjs.ButtonLoginBg.alpha = 1
return true
end
function TRPLogin:setEventDelegate()
self.EventDelegate = {
ButtonLogin = function()
local err = uiobjs.formRoot:checkValid()
if not isNilOrEmpty(err) then
return
end
if not self:getsetButtonloginState() then
return
end
local formData = uiobjs.formRoot:getValue(true)
NetProto.login(
formData,
function(content, orgs)
if content.success then
Prefs.setUserName(formData.phone)
Prefs.setUserPsd(formData.password)
local currGroup = Prefs.getCurrGroup(Prefs.getUserName())
if isNilOrEmpty(currGroup) then
---@type _ParamTRPSelectGroup
local d = {}
d.isHideCloseBtn = true
d.companyList = content.result
getPanelAsy("PanelSelectCompany", onLoadedPanel, d)
else
getPanelAsy("PanelConnect", onLoadedPanel)
end
end
end,
function()
CLAlert.add("登录失败,请确保网络通畅!", Color.white, 1)
end
)
end,
ButtonDelPhoneNum = function()
uiobjs.InputPhoneNum.value = ""
SetActive(uiobjs.ButtonDelPhoneNum.gameObject, false)
end,
ButtonDelPassword = function()
uiobjs.InputPassword.value = ""
SetActive(uiobjs.ButtonDelPassword.gameObject, false)
end,
ButtonForgetPassword = function()
getPanelAsy("PanelResetPasswordStep1", onLoadedPanelTT, uiobjs.formRoot:getValue(true))
end
}
end
-- 处理ui上的事件例如点击等
function TRPLogin:uiEventDelegate(go)
local func = self.EventDelegate[go.name]
if func then
func()
end
end
function TRPLogin:hideSelfOnKeyBack()
return false
end
-- 当顶层页面发生变化时回调
function TRPLogin:onTopPanelChange(topPanel)
end
--------------------------------------------
return TRPLogin