Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
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
baiguangyao
mr-julyedu
Commits
7b808cbe
Commit
7b808cbe
authored
Aug 22, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信登录redirect_url
parent
cbe294db
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
9 deletions
+27
-9
src/App.js
+15
-1
src/components/passport/accountLogin/index.js
+1
-1
src/components/passport/index.js
+9
-5
src/components/passport/login/index.js
+2
-2
No files found.
src/App.js
View file @
7b808cbe
...
...
@@ -23,6 +23,7 @@ import './assets/font/iconfont.css';
class
App
extends
Component
{
previousLocation
=
this
.
props
.
location
componentDidMount
()
{
//平台信息
...
...
@@ -34,6 +35,13 @@ class App extends Component {
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
})
const
{
history
}
=
this
.
props
history
.
listen
(
location
=>
{
if
(
location
.
pathname
.
startsWith
(
'/passport'
))
{
location
.
state
=
{
from
:
this
.
previousLocation
};
}
})
//微信
let
code
=
getParam
(
'code'
)
...
...
@@ -46,7 +54,6 @@ class App extends Component {
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
window
.
location
.
assign
(
data
.
data
.
url
)
}
else
{
let
user
=
this
.
transformWxUser
(
res
)
let
{
role
,
uid
,
token
}
=
data
.
data
...
...
@@ -67,6 +74,13 @@ class App extends Component {
}
componentDidUpdate
()
{
const
{
location
}
=
this
.
props
this
.
previousLocation
=
location
.
pathname
.
startsWith
(
'/passport'
)
?
this
.
previousLocation
.
pathname
===
'/'
?
location
:
this
.
previousLocation
:
location
}
transformUser
=
res
=>
{
let
payload
if
(
res
.
data
.
code
===
200
)
{
...
...
src/components/passport/accountLogin/index.js
View file @
7b808cbe
...
...
@@ -77,7 +77,7 @@ const formikConfig = {
}).
then
(
res
=>
{
if
(
!
res
.
hasError
)
{
let
{
from
}
=
props
.
location
.
state
||
{
from
:
{
pathname
:
'/'
,
search
:
''
}}
history
.
replace
({
pathname
:
from
.
pathname
,
search
:
from
.
search
})
history
.
replace
({
pathname
:
from
.
pathname
,
search
:
from
.
search
||
''
})
}
else
{
Toast
.
info
(
res
.
msg
,
2
,
null
,
false
)
}
...
...
src/components/passport/index.js
View file @
7b808cbe
...
...
@@ -19,10 +19,13 @@ import wechat from './wechat.png'
class
Passport
extends
Component
{
redirect
_url
=
location
.
protocol
+
'//'
+
location
.
hostname
redirect
URL
=
'/'
constructor
(
props
)
{
super
(
props
);
const
{
location
:
{
state
:
{
from
}}}
=
props
this
.
redirectURL
=
window
.
location
.
origin
+
from
.
pathname
+
from
.
search
+
from
.
hash
// console.log(props.location);
this
.
state
=
{
loginWays
:
[
{
...
...
@@ -32,17 +35,17 @@ class Passport extends Component {
{
logo
:
wechat
,
text
:
'微信'
,
url
:
'
https://www.baidu.com
'
url
:
''
},
{
logo
:
qq
,
text
:
'QQ'
,
url
:
`
${
API
[
"passport-api"
]}
/mob/qqlogin?redirect_url=
https://m.julyedu.com
`
url
:
`
${
API
[
"passport-api"
]}
/mob/qqlogin?redirect_url=
${
this
.
redirectURL
}
`
},
{
logo
:
sina
,
text
:
'新浪'
,
url
:
`
${
API
[
'passport-api'
]}
/mob/sinalogin?redirect_url=
${
this
.
redirect
_url
}
`
url
:
`
${
API
[
'passport-api'
]}
/mob/sinalogin?redirect_url=
${
this
.
redirect
URL
}
`
},
]
}
...
...
@@ -51,11 +54,12 @@ class Passport extends Component {
componentDidMount
()
{
this
.
routeWhenUserLoggedIn
()
}
componentDidUpdate
()
{
this
.
routeWhenUserLoggedIn
()
// console.log(this.props.location);
}
...
...
src/components/passport/login/index.js
View file @
7b808cbe
...
...
@@ -32,9 +32,9 @@ class Login extends Component {
history
.
push
(
'/passport/account-login'
,
location
.
state
)
break
;
case
'微信'
:
let
{
from
}
=
location
.
state
||
{
from
:
{
pathname
:
'/'
}}
let
{
from
}
=
location
.
state
||
{
from
:
{
pathname
:
'/'
,
search
:
''
,
hash
:
''
}}
const
redirectURI
=
window
.
location
.
origin
+
from
.
pathname
const
redirectURI
=
window
.
location
.
origin
+
from
.
pathname
+
from
.
search
+
from
.
hash
window
.
location
.
assign
(
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=
${
encodeURIComponent
(
redirectURI
)}
&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
)
break
;
...
...
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