Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
严立
/
mini-shimao
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ab53f413
authored
Sep 17, 2020
by
严立
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
LL - 增加用户登录判断
parent
9d8c5647
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
app.js
app.js
View file @
ab53f413
...
@@ -48,25 +48,25 @@ App({
...
@@ -48,25 +48,25 @@ App({
wxRequest
:
function
(
obj
)
{
wxRequest
:
function
(
obj
)
{
var
token
=
this
.
globalData
.
token
var
token
=
this
.
globalData
.
token
var
param
=
obj
.
data
?
JSON
.
stringify
(
obj
.
data
)
:
""
var
param
=
obj
.
data
?
JSON
.
stringify
(
obj
.
data
)
:
''
var
header
=
obj
.
header
?
obj
.
header
:
{
'token'
:
token
||
''
,
}
var
header
=
obj
.
header
?
obj
.
header
:
{
'token'
:
token
||
''
,
}
wx
.
request
({
wx
.
request
({
url
:
this
.
globalData
.
baseUrl
+
obj
.
url
,
url
:
this
.
globalData
.
baseUrl
+
obj
.
url
,
data
:
param
,
data
:
param
,
method
:
obj
.
method
||
"POST"
,
method
:
obj
.
method
||
'POST'
,
header
:
header
,
header
:
header
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
// console.log("接口:", this.globalData.baseUrl + obj.url);
// console.log("接口:", this.globalData.baseUrl + obj.url);
// console.log("参数:", JSON.stringify(obj.data));
// console.log("参数:", JSON.stringify(obj.data));
// console.log("返回:", res);
// console.log("返回:", res);
let
code
=
res
.
data
.
code
*
1
;
let
code
=
res
.
data
.
code
*
1
if
(
200
==
code
&&
true
==
res
.
data
.
success
)
{
if
(
200
==
code
&&
true
==
res
.
data
.
success
)
{
if
(
obj
.
success
)
{
if
(
obj
.
success
)
{
obj
.
success
(
res
.
data
)
obj
.
success
(
res
.
data
)
}
}
}
else
if
(
402
==
code
)
{
// token失效
}
else
if
(
402
==
code
)
{
this
.
refreshToken
({
this
.
refreshToken
({
success
:
()
=>
{
success
:
()
=>
{
this
.
wxRequest
(
obj
)
this
.
wxRequest
(
obj
)
...
@@ -87,9 +87,9 @@ App({
...
@@ -87,9 +87,9 @@ App({
}
}
},
},
fail
:
(
err
)
=>
{
fail
:
(
err
)
=>
{
console
.
log
(
"接口:"
,
this
.
globalData
.
baseUrl
+
obj
.
url
)
//
console.log("接口:", this.globalData.baseUrl + obj.url)
console
.
log
(
"参数:"
,
obj
.
data
)
//
console.log("参数:", obj.data)
console
.
log
(
"返回:"
,
err
)
//
console.log("返回:", err)
if
(
obj
.
fail
)
{
if
(
obj
.
fail
)
{
let
err
=
{
let
err
=
{
statusCode
:
9999
,
statusCode
:
9999
,
...
@@ -108,6 +108,12 @@ App({
...
@@ -108,6 +108,12 @@ App({
});
});
},
},
/**
* 登录
* @function
* @param
* @returns
*/
login
:
function
(
obj
)
{
login
:
function
(
obj
)
{
let
token
=
this
.
globalData
.
token
let
token
=
this
.
globalData
.
token
if
(
token
)
{
if
(
token
)
{
...
@@ -139,8 +145,12 @@ App({
...
@@ -139,8 +145,12 @@ App({
'birthday'
:
funcResponse
.
birthday
,
'birthday'
:
funcResponse
.
birthday
,
'sex'
:
funcResponse
.
sex
,
'sex'
:
funcResponse
.
sex
,
'userType'
:
Number
(
funcResponse
.
userType
),
'userType'
:
Number
(
funcResponse
.
userType
),
'isSignIn'
:
false
,
}
}
// 以返回信息中是否包含手机号码判断用户是否注册过
if
(
funcUserInfo
.
phone
)
funcUserInfo
.
isSignIn
=
true
wx
.
setStorageSync
(
'userInfo'
,
funcUserInfo
)
wx
.
setStorageSync
(
'userInfo'
,
funcUserInfo
)
if
(
obj
.
success
)
{
if
(
obj
.
success
)
{
...
@@ -153,6 +163,12 @@ App({
...
@@ -153,6 +163,12 @@ App({
}
}
},
},
/**
* 注册
* @function
* @param {number} - funcAmountValue 金额,单位分
* @returns
*/
registUserInfo
:
function
(
obj
)
{
registUserInfo
:
function
(
obj
)
{
this
.
wxRequest
({
this
.
wxRequest
({
url
:
'/api/v1/login/getDecryptData'
,
url
:
'/api/v1/login/getDecryptData'
,
...
@@ -170,6 +186,12 @@ App({
...
@@ -170,6 +186,12 @@ App({
})
})
},
},
/**
* 刷新令牌
* @function
* @param {number} - funcAmountValue 金额,单位分
* @returns
*/
refreshToken
:
function
(
obj
)
{
refreshToken
:
function
(
obj
)
{
this
.
wxRequest
({
this
.
wxRequest
({
url
:
'/api/v1/login/refreshToken'
,
url
:
'/api/v1/login/refreshToken'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment