2020-07-04 14:41:25 +08:00
|
|
|
|
---@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为调用refresh,show和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()
|
2020-07-09 09:23:09 +08:00
|
|
|
|
MyUtl.toastW("登录失败,请确保网络通畅!")
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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
|