Commit 96fc3efd by zhangleyuan

feat:处理冲突

parents d05a8b2a 652a5ce4
...@@ -10,7 +10,8 @@ class Authorize extends React.Component { ...@@ -10,7 +10,8 @@ class Authorize extends React.Component {
this.state = { this.state = {
code:'', code:'',
ticket:'', ticket:'',
hasBindWechat:false hasBindWechat:false,
headImgUrl:''
} }
} }
componentDidMount() { componentDidMount() {
...@@ -26,7 +27,6 @@ class Authorize extends React.Component { ...@@ -26,7 +27,6 @@ class Authorize extends React.Component {
},()=>this.changeCodeState()) },()=>this.changeCodeState())
}else{ }else{
this.getWechatUserInfo(); this.getWechatUserInfo();
} }
} }
changeCodeState = ()=>{ changeCodeState = ()=>{
...@@ -44,7 +44,8 @@ class Authorize extends React.Component { ...@@ -44,7 +44,8 @@ class Authorize extends React.Component {
'&redirect_uri=' + encodeURIComponent(path) + '&redirect_uri=' + encodeURIComponent(path) +
'&response_type=code&scope=snsapi_userinfo&state=state#wechat_redirect'; '&response_type=code&scope=snsapi_userinfo&state=state#wechat_redirect';
window.location.href = htmlUrl; window.location.href = htmlUrl;
} }
getWechatUserInfo = ()=>{ getWechatUserInfo = ()=>{
const code = window.getParameterByName('code'); const code = window.getParameterByName('code');
const ticket = window.getParameterByName('ticket'); const ticket = window.getParameterByName('ticket');
...@@ -57,24 +58,38 @@ class Authorize extends React.Component { ...@@ -57,24 +58,38 @@ class Authorize extends React.Component {
Service.hades('/anon/hades/bindWeChat',params).then((res)=>{ Service.hades('/anon/hades/bindWeChat',params).then((res)=>{
if(res.success){ if(res.success){
this.setState({ this.setState({
hasBindWechat:true hasBindWechat:true,
}) headImgUrl:res.result.headImgUrl,
ticketState:"AUTH_SUCCESS"
},()=>{this.changeCodeState()})
} }
}) })
} }
render() { render() {
const { hasBindWechat } = this.state const { hasBindWechat , headImgUrl} = this.state
return ( return (
<div className="authorize-page"> <div className="authorize-page">
<div> <div>
<img src="https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png" className="avatar-img"></img> { !hasBindWechat &&
</div> <div>
<div> <div>
{ !hasBindWechat && <img src="https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png" className="avatar-img"></img>
<button className="login-btn" onClick={this.wechatAuthorize}>微信登录</button> </div>
<button className="login-btn" onClick={this.wechatAuthorize}>微信登录</button>
</div>
} }
{ hasBindWechat && { 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>
</div> </div>
......
...@@ -19,4 +19,14 @@ ...@@ -19,4 +19,14 @@
margin-top:10.6vw; margin-top:10.6vw;
font-size:4vw; 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment