Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
U
uni-pdtravel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
panyongping
uni-pdtravel
Commits
21a85664
Commit
21a85664
authored
Aug 28, 2024
by
潘永坪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录优化
parent
438d3a35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
39 deletions
+53
-39
login.vue
pages/login/login.vue
+53
-39
No files found.
pages/login/login.vue
View file @
21a85664
...
...
@@ -45,15 +45,22 @@ export default {
data
.
companyId
=
uni
.
getStorageSync
(
'enterOptions'
).
query
.
companyId
||
''
}
this
.
$request
(
'wechat/wx/getUserInfoByCode'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
let
openid
=
res
.
data
.
openid
uni
.
setStorageSync
(
'openid'
,
openid
)
let
userId
=
res
.
data
.
userId
||
''
this
.
login
(
openid
,
userId
,
source
)
}
else
{
try
{
if
(
res
.
code
==
'00'
)
{
let
openid
=
res
.
data
.
openid
uni
.
setStorageSync
(
'openid'
,
openid
)
let
userId
=
res
.
data
.
userId
||
''
this
.
login
(
openid
,
userId
,
source
)
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
}
catch
(
e
){
uni
.
showToast
({
title
:
res
.
messag
e
,
icon
:
'none'
title
:
e
,
icon
:
'none'
})
}
}).
catch
(
err
=>
{
...
...
@@ -75,37 +82,44 @@ export default {
login
(
openid
,
userId
,
source
){
let
datas
=
{
openid
,
userId
,
source
}
this
.
$request
(
'wechatUser/login/findWxUserAndLogin'
,
datas
).
then
(
res
=>
{
//通过openid获取token
if
(
res
.
code
==
'00'
)
{
let
token
=
res
.
data
.
token
||
''
uni
.
setStorageSync
(
'token'
,
token
)
let
createUserId
=
res
.
data
.
personId
||
''
uni
.
setStorageSync
(
'createUserId'
,
createUserId
)
let
userId
=
res
.
data
.
userId
||
''
uni
.
setStorageSync
(
'userId'
,
userId
)
let
enterOptions
=
uni
.
getStorageSync
(
'enterOptions'
)
let
queryTotal
=
''
for
(
let
key
in
enterOptions
.
query
)
{
queryTotal
+=
'&'
+
key
+
'='
+
enterOptions
.
query
[
key
]
}
queryTotal
=
queryTotal
.
substr
(
1
)
if
(
token
)
{
uni
.
reLaunch
({
url
:
'/'
+
enterOptions
.
path
+
'?'
+
queryTotal
})
//保存当前日期
let
oldDate
=
this
.
$commonjs
.
today
()
uni
.
setStorageSync
(
'oldDate'
,
oldDate
)
// uni.navigateBack({
// delta:1
// })
}
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
try
{
//通过openid获取token
if
(
res
.
code
==
'00'
)
{
let
token
=
res
.
data
.
token
||
''
uni
.
setStorageSync
(
'token'
,
token
)
let
createUserId
=
res
.
data
.
personId
||
''
uni
.
setStorageSync
(
'createUserId'
,
createUserId
)
let
userId
=
res
.
data
.
userId
||
''
uni
.
setStorageSync
(
'userId'
,
userId
)
let
enterOptions
=
uni
.
getStorageSync
(
'enterOptions'
)
let
queryTotal
=
''
for
(
let
key
in
enterOptions
.
query
)
{
queryTotal
+=
'&'
+
key
+
'='
+
enterOptions
.
query
[
key
]
}
queryTotal
=
queryTotal
.
substr
(
1
)
if
(
token
)
{
uni
.
reLaunch
({
url
:
'/'
+
enterOptions
.
path
+
'?'
+
queryTotal
})
//保存当前日期
let
oldDate
=
this
.
$commonjs
.
today
()
uni
.
setStorageSync
(
'oldDate'
,
oldDate
)
// uni.navigateBack({
// delta:1
// })
}
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
}
catch
(
e
){
uni
.
showToast
({
title
:
e
,
icon
:
'none'
})
}
}).
catch
(
err
=>
{
uni
.
showToast
({
title
:
'登录失败,请退出并重新登录'
,
...
...
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