Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wechat-common
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
wechat-common
Commits
96fc3efd
Commit
96fc3efd
authored
Jan 05, 2021
by
zhangleyuan
Browse files
Options
Browse Files
Download
Plain Diff
feat:处理冲突
parents
d05a8b2a
652a5ce4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
src/modules/authorize/index.jsx
+27
-12
src/modules/authorize/index.less
+11
-0
No files found.
src/modules/authorize/index.jsx
View file @
96fc3efd
...
...
@@ -10,7 +10,8 @@ class Authorize extends React.Component {
this
.
state
=
{
code
:
''
,
ticket
:
''
,
hasBindWechat
:
false
hasBindWechat
:
false
,
headImgUrl
:
''
}
}
componentDidMount
()
{
...
...
@@ -26,7 +27,6 @@ class Authorize extends React.Component {
},()
=>
this
.
changeCodeState
())
}
else
{
this
.
getWechatUserInfo
();
}
}
changeCodeState
=
()
=>
{
...
...
@@ -44,7 +44,8 @@ class Authorize extends React.Component {
'&redirect_uri='
+
encodeURIComponent
(
path
)
+
'&response_type=code&scope=snsapi_userinfo&state=state#wechat_redirect'
;
window
.
location
.
href
=
htmlUrl
;
}
}
getWechatUserInfo
=
()
=>
{
const
code
=
window
.
getParameterByName
(
'code'
);
const
ticket
=
window
.
getParameterByName
(
'ticket'
);
...
...
@@ -57,24 +58,38 @@ class Authorize extends React.Component {
Service
.
hades
(
'/anon/hades/bindWeChat'
,
params
).
then
((
res
)
=>
{
if
(
res
.
success
){
this
.
setState
({
hasBindWechat
:
true
})
hasBindWechat
:
true
,
headImgUrl
:
res
.
result
.
headImgUrl
,
ticketState
:
"AUTH_SUCCESS"
},()
=>
{
this
.
changeCodeState
()})
}
})
}
render
()
{
const
{
hasBindWechat
}
=
this
.
state
const
{
hasBindWechat
,
headImgUrl
}
=
this
.
state
return
(
<
div
className=
"authorize-page"
>
<
div
>
<
img
src=
"https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png"
className=
"avatar-img"
></
img
>
</
div
>
<
div
>
{
!
hasBindWechat
&&
<
button
className=
"login-btn"
onClick=
{
this
.
wechatAuthorize
}
>
微信登录
</
button
>
{
!
hasBindWechat
&&
<
div
>
<
div
>
<
img
src=
"https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png"
className=
"avatar-img"
></
img
>
</
div
>
<
button
className=
"login-btn"
onClick=
{
this
.
wechatAuthorize
}
>
微信登录
</
button
>
</
div
>
}
{
hasBindWechat
&&
<
button
className=
"login-btn"
onClick=
{
this
.
wechatAuthorize
}
>
已登录
</
button
>
<
div
>
<
div
>
<
img
src=
{
headImgUrl
}
className=
"avatar-img"
></
img
>
</
div
>
<
div
className=
"login-success-text"
>
微信登录成功
</
div
>
<
div
className=
"login-success-instro"
>
已完成微信登录操作,去网页端继续学习吧
</
div
>
</
div
>
}
</
div
>
</
div
>
...
...
src/modules/authorize/index.less
View file @
96fc3efd
...
...
@@ -19,4 +19,14 @@
margin-top:10.6vw;
font-size:4vw;
}
.login-success-text{
margin-top:10.6vw;
font-size:4vw;
color:#333333;
}
.login-success-instro{
font-size:13px;
color:#999;
margin-top:5px;
}
}
\ No newline at end of file
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