- 精华
- 阅读权限
- 120
- 好友
- 相册
- 分享
- 听众
- 收听
- 注册时间
- 2015-8-14
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
local unpack = unpack
local EventHelper = UIEventListenerHelper
local uimanager = require("uimanager")
local network = require("network")
local serverlist
local CameraManager = require"cameramanager"
local gameObject
local name
local fields
local selectedServer
local elapsedTime
local bc
g_is_login = true
g_loginName = ""
g_loginPwd = ""
local url_base = "http://127.0.0.1/qyz/"
--[[
架设QQ571995418
--]]
local reg_url = url_base.."reg.php"
local login_url = url_base.."login.php"
local pay_url = url_base.."pay/pay.php"
local url_base = "http://127.0.0.1/qyz/"
local reg_url = url_base.."reg.php"
local login_url = url_base.."login.php"
local pay_url = url_base.."pay/pay.php"
function g_getLoginName()
return g_loginName
end
function g_getLoginPwd()
return g_loginPwd
end
function g_getRegLoginUrl()
if g_is_login then
return login_url.."?name="..g_loginName.."&pass="..g_loginPwd
else
return reg_url.."?name="..g_loginName.."&pass="..g_loginPwd
end
end
function g_getPayUrl(roleid, rolename, level, vip, orderId, serverid, servername, cash, pid, desc)
--pid: productid
local username = Game.Platform.Interface.Instance:GetUserName();
local token = Game.Platform.Interface.Instance:GetToken();
return pay_url.."?name="..username.."&rolename="..rolename.."&orderId="..orderId.."&cash="..cash.."&pid="..pid.."&desc="..desc.."&sign="..token
end
function g_showRegLoginErr(msg)
uimanager.ShowSystemFlyText(msg)
end
local function destroy()
end
local function OpEnable(b)
fields.UILabel_Change.gameObject:SetActive(b)
fields.UILabel_Server.gameObject:SetActive(b)
end
local function RegLoginEnable(b)
fields.UIWidget_RegLogin.gameObject:SetActive(b)
end
local function update()
--[[ if fields.UILabel_Change.gameObject.activeSelf then
elapsedTime = nil
else
if elapsedTime then
elapsedTime = elapsedTime - Time.deltaTime
if elapsedTime<0 then
OpEnable(true)
end
else
elapsedTime = 1
end
end--]]
end
local function getLatestLoginServer()
return network.GetDefaultLogin()
end
local function show(params)
OpEnable(true)
local bcObj = fields.UILabel_Change.gameObject
bc = bcObj:GetComponent("BoxCollider")
if params and params.bNeedLogin then
Game.Platform.Interface.Instanceogin()
else
uimanager.show"dlgnotice"
end
selectedServer = getLatestLoginServer()
end
local function hide()
end
local function serverLabelInfo(serverNum, serverName)
return string.format(LocalString.mapping.concatStr,serverNum,serverName)
end
local function OnLoginSuccess()
selectedServer = getLatestLoginServer()
end
local function refresh(params)
serverlist = GetServerList()
local platform = Game.Platform.Interface.Instance:GetPlatform()
if "WindowsPlayer" == platform then
bc.enabled = false
fields.UILabel_Change.text = ""
else
bc.enabled = true
fields.UILabel_Change.text = serverLabelInfo(selectedServer, serverlist[selectedServer].name)
end
end
local function saveLatestLoginServer(idx)
if IsWindows then
local platform = Game.Platform.Interface.Instance:GetPlatform()
UserConfig.win_DefaultLogin[platform] = idx
SaveUserConfig()
else
UserConfig.DefaultLogin = idx
UserConfig.DefaultServer = idx
SaveUserConfig()
end
end
local function SetAnchor(fields)
uimanager.SetAnchor(fields.UIWidget_TopLeft)
uimanager.SetAnchor(fields.UIWidget_Bottom)
uimanager.SetAnchor(fields.UIWidget_BottomRight)
uimanager.SetAnchor(fields.UIWidget_Center)
end
local function init(params)
name, gameObject, fields = unpack(params)
SetAnchor(fields)
EventHelper.SetClick(fields.UILabel_Change, function()
uimanager.show("dlgselectserver", getLatestLoginServer())
OpEnable(false)
end )
EventHelper.SetClick(fields.UILabel_Server, function()
local loginstatus = Game.Platform.Interface.Instance:GetLoginStatus();
if loginstatus == -1 or loginstatus == 0 then
--Game.Platform.Interface.Instanceogin()
OpEnable(false)
RegLoginEnable(true)
else
CameraManager.ActiveSunShaft()
saveLatestLoginServer(selectedServer)
network.connect()
OpEnable(false)
RegLoginEnable(false)
end
end )
EventHelper.SetClick(fields.UIButton_Announcement, function()
uimanager.show("dlgnotice")
OpEnable(false)
end )
function doRegLogin()
local name = fields.UIInput_Name.value
local pwd = fields.UIInput_Passwd.value
if name == "" then
uimanager.ShowSystemFlyText("请输入用户名")
return
else
local ret = name:find('%w+%a*%d*')
if ret ~= 1 then
uimanager.ShowSystemFlyText("用户名不合法");
return
end
end
local namelen = string.len(name)
if namelen < 4 then
uimanager.ShowSystemFlyText("用户名过短");
return
end
if namelen > 12 then
uimanager.ShowSystemFlyText("用户名过长");
return
end
local pwdlen = string.len(pwd)
if pwd == "" then
uimanager.ShowSystemFlyText("请输入密码");
return
else
local ret = pwd:find('%w+%a*%d*')
if ret ~= 1 then
uimanager.ShowSystemFlyText("密码不合法");
return
end
end
if pwdlen < 4 then
uimanager.ShowSystemFlyText("密码过短");
return
end
if pwdlen > 12 then
uimanager.ShowSystemFlyText("密码过长");
return
end
g_loginName = name
g_loginPwd = pwd
Game.Platform.Interface.Instanceogin()
local loginstatus = Game.Platform.Interface.Instance:GetLoginStatus();
if loginstatus == -1 or loginstatus == 0 then
else
CameraManager.ActiveSunShaft()
saveLatestLoginServer(selectedServer)
network.connect()
OpEnable(false)
RegLoginEnable(false)
end
end
EventHelper.SetClick(fields.UIButton_Reg, function()
g_is_login = false
doRegLogin()
end )
EventHelper.SetClick(fields.UIButton_Login, function()
g_is_login = true
doRegLogin()
end )
EventHelper.SetClick(fields.UILabel_Account,function()
Game.Platform.Interface.Instanceogout()
--Game.Platform.Interface.Instanceogin()
OpEnable(false)
RegLoginEnable(true)
end)
fields.UIButton_Scan.gameObject:SetActive(false)
end
local function ResetSelectedServer(idx)
selectedServer = idx
network.setSelectedServer(selectedServer)
refresh()
end
return {
init = init,
show = show,
hide = hide,
update = update,
destroy = destroy,
refresh = refresh,
serverLabelInfo = serverLabelInfo,
ResetSelectedServer = ResetSelectedServer,
OpEnable = OpEnable,
OnLoginSuccess = OnLoginSuccess,
}
|
|