全局变量ACCOUNT改名USER
This commit is contained in:
@@ -302,7 +302,7 @@ for i=1,25 do
|
||||
STAT.spin[i]={0,0,0,0,0,0,0}
|
||||
end
|
||||
|
||||
ACCOUNT={
|
||||
USER={
|
||||
email=nil,
|
||||
auth_token=nil,
|
||||
access_token=nil,
|
||||
|
||||
@@ -44,7 +44,7 @@ function scene.sceneInit()
|
||||
BG.set("none")
|
||||
wsConnect(
|
||||
TICK.wsCONN_connect,
|
||||
PATH.socket..PATH.chat.."?email="..urlEncode(ACCOUNT.email).."&access_token="..urlEncode(ACCOUNT.access_token)
|
||||
PATH.socket..PATH.chat.."?email="..urlEncode(USER.email).."&access_token="..urlEncode(USER.access_token)
|
||||
)
|
||||
end
|
||||
function scene.sceneBack()
|
||||
|
||||
@@ -180,15 +180,15 @@ function scene.update()
|
||||
SFX.play("welcome_sfx")
|
||||
VOC.play("welcome_voc")
|
||||
httpRequest(tick_httpREQ_launch,PATH.api..PATH.appInfo)
|
||||
if ACCOUNT.auth_token and ACCOUNT.email then
|
||||
if USER.auth_token and USER.email then
|
||||
httpRequest(
|
||||
tick_httpREQ_autoLogin,
|
||||
PATH.api..PATH.auth,
|
||||
"GET",
|
||||
{["Content-Type"]="application/json"},
|
||||
json.encode{
|
||||
email=ACCOUNT.email,
|
||||
auth_token=ACCOUNT.auth_token,
|
||||
email=USER.email,
|
||||
auth_token=USER.auth_token,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -9,9 +9,9 @@ local function tick_httpREQ_newLogin(task)
|
||||
if res then
|
||||
if LOGIN then
|
||||
LOG.print(text.loginSuccessed)
|
||||
ACCOUNT.email=res.email
|
||||
ACCOUNT.auth_token=res.auth_token
|
||||
FILE.save(ACCOUNT,"conf/account","q")
|
||||
USER.email=res.email
|
||||
USER.auth_token=res.auth_token
|
||||
FILE.save(USER,"conf/account","q")
|
||||
|
||||
httpRequest(
|
||||
TICK.httpREQ_getAccessToken,
|
||||
@@ -19,8 +19,8 @@ local function tick_httpREQ_newLogin(task)
|
||||
"POST",
|
||||
{["Content-Type"]="application/json"},
|
||||
json.encode{
|
||||
email=ACCOUNT.email,
|
||||
auth_token=ACCOUNT.auth_token,
|
||||
email=USER.email,
|
||||
auth_token=USER.auth_token,
|
||||
}
|
||||
)
|
||||
else
|
||||
|
||||
@@ -16,8 +16,8 @@ local function tick_httpREQ_checkAccessToken(task)
|
||||
"POST",
|
||||
{["Content-Type"]="application/json"},
|
||||
json.encode{
|
||||
email=ACCOUNT.email,
|
||||
auth_token=ACCOUNT.auth_token,
|
||||
email=USER.email,
|
||||
auth_token=USER.auth_token,
|
||||
}
|
||||
)
|
||||
else
|
||||
@@ -82,15 +82,15 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")},
|
||||
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=function()
|
||||
if LOGIN then
|
||||
if ACCOUNT.access_token then
|
||||
if USER.access_token then
|
||||
httpRequest(
|
||||
tick_httpREQ_checkAccessToken,
|
||||
PATH.api..PATH.access,
|
||||
"GET",
|
||||
{["Content-Type"]="application/json"},
|
||||
json.encode{
|
||||
email=ACCOUNT.email,
|
||||
access_token=ACCOUNT.access_token,
|
||||
email=USER.email,
|
||||
access_token=USER.access_token,
|
||||
}
|
||||
)
|
||||
else
|
||||
@@ -100,8 +100,8 @@ scene.widgetList={
|
||||
"POST",
|
||||
{["Content-Type"]="application/json"},
|
||||
json.encode{
|
||||
email=ACCOUNT.email,
|
||||
auth_token=ACCOUNT.auth_token,
|
||||
email=USER.email,
|
||||
auth_token=USER.auth_token,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -9,16 +9,16 @@ function Tick.httpREQ_getAccessToken(task)
|
||||
local res=json.decode(response.body)
|
||||
if res then
|
||||
LOG.print(text.accessSuccessed)
|
||||
ACCOUNT.access_token=res.access_token
|
||||
FILE.save(ACCOUNT,"conf/account")
|
||||
USER.access_token=res.access_token
|
||||
FILE.save(USER,"conf/account")
|
||||
SCN.swapTo("netgame")
|
||||
else
|
||||
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
|
||||
end
|
||||
else
|
||||
LOGIN=false
|
||||
ACCOUNT.access_token=nil
|
||||
ACCOUNT.auth_token=nil
|
||||
USER.access_token=nil
|
||||
USER.auth_token=nil
|
||||
local err=json.decode(response.body)
|
||||
if err then
|
||||
LOG.print(text.loginFailed..": "..text.netErrorCode..response.code.."-"..err.message,"warn")
|
||||
|
||||
Reference in New Issue
Block a user