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';
...
@@ -23,6 +23,7 @@ import './assets/font/iconfont.css';
class
App
extends
Component
{
class
App
extends
Component
{
previousLocation
=
this
.
props
.
location
componentDidMount
()
{
componentDidMount
()
{
//平台信息
//平台信息
...
@@ -34,6 +35,13 @@ class App extends Component {
...
@@ -34,6 +35,13 @@ class App extends Component {
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
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'
)
let
code
=
getParam
(
'code'
)
...
@@ -46,7 +54,6 @@ class App extends Component {
...
@@ -46,7 +54,6 @@ class App extends Component {
if
(
data
.
errno
==
200
)
{
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
window
.
location
.
assign
(
data
.
data
.
url
)
window
.
location
.
assign
(
data
.
data
.
url
)
}
else
{
}
else
{
let
user
=
this
.
transformWxUser
(
res
)
let
user
=
this
.
transformWxUser
(
res
)
let
{
role
,
uid
,
token
}
=
data
.
data
let
{
role
,
uid
,
token
}
=
data
.
data
...
@@ -67,6 +74,13 @@ class App extends Component {
...
@@ -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
=>
{
transformUser
=
res
=>
{
let
payload
let
payload
if
(
res
.
data
.
code
===
200
)
{
if
(
res
.
data
.
code
===
200
)
{
...
...
src/components/passport/accountLogin/index.js
View file @
7b808cbe
...
@@ -77,7 +77,7 @@ const formikConfig = {
...
@@ -77,7 +77,7 @@ const formikConfig = {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
if
(
!
res
.
hasError
)
{
if
(
!
res
.
hasError
)
{
let
{
from
}
=
props
.
location
.
state
||
{
from
:
{
pathname
:
'/'
,
search
:
''
}}
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
{
}
else
{
Toast
.
info
(
res
.
msg
,
2
,
null
,
false
)
Toast
.
info
(
res
.
msg
,
2
,
null
,
false
)
}
}
...
...
src/components/passport/index.js
View file @
7b808cbe
...
@@ -19,10 +19,13 @@ import wechat from './wechat.png'
...
@@ -19,10 +19,13 @@ import wechat from './wechat.png'
class
Passport
extends
Component
{
class
Passport
extends
Component
{
redirect
_url
=
location
.
protocol
+
'//'
+
location
.
hostname
redirect
URL
=
'/'
constructor
(
props
)
{
constructor
(
props
)
{
super
(
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
=
{
this
.
state
=
{
loginWays
:
[
loginWays
:
[
{
{
...
@@ -32,17 +35,17 @@ class Passport extends Component {
...
@@ -32,17 +35,17 @@ class Passport extends Component {
{
{
logo
:
wechat
,
logo
:
wechat
,
text
:
'微信'
,
text
:
'微信'
,
url
:
'
https://www.baidu.com
'
url
:
''
},
},
{
{
logo
:
qq
,
logo
:
qq
,
text
:
'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
,
logo
:
sina
,
text
:
'新浪'
,
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 {
...
@@ -51,11 +54,12 @@ class Passport extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
routeWhenUserLoggedIn
()
this
.
routeWhenUserLoggedIn
()
}
}
componentDidUpdate
()
{
componentDidUpdate
()
{
this
.
routeWhenUserLoggedIn
()
this
.
routeWhenUserLoggedIn
()
// console.log(this.props.location);
}
}
...
...
src/components/passport/login/index.js
View file @
7b808cbe
...
@@ -32,9 +32,9 @@ class Login extends Component {
...
@@ -32,9 +32,9 @@ class Login extends Component {
history
.
push
(
'/passport/account-login'
,
location
.
state
)
history
.
push
(
'/passport/account-login'
,
location
.
state
)
break
;
break
;
case
'微信'
:
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`
)
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
;
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