微信登录 调整

competitions
杨树明 5 years ago
parent 315f58a7fb
commit a03bb0dafb

@ -70,6 +70,12 @@ const Otherlogin=Loadable({
loader: () => import('./modules/login/Otherlogin'), loader: () => import('./modules/login/Otherlogin'),
loading: Loading, loading: Loading,
}) })
const Otherloginstart=Loadable({
loader: () => import('./modules/login/Otherloginstart'),
loading: Loading,
})
const TestIndex = Loadable({ const TestIndex = Loadable({
loader: () => import('./modules/test'), loader: () => import('./modules/test'),
loading: Loading, loading: Loading,
@ -412,6 +418,9 @@ class App extends Component {
<Route <Route
path="/register" component={EducoderLogin} path="/register" component={EducoderLogin}
/> />
<Route
path="/otherloginstart" component={Otherloginstart}
/>
<Route <Route
path="/otherlogin" component={Otherlogin} path="/otherlogin" component={Otherlogin}
/> />

@ -638,7 +638,7 @@ class LoginDialog extends Component {
frameBorder="0" frameBorder="0"
sandbox="allow-scripts allow-same-origin allow-top-navigation" sandbox="allow-scripts allow-same-origin allow-top-navigation"
scrolling="no" scrolling="no"
src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherlogin&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""} src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginstart&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""}
{weixinlogin===true?<p className="clearfix"> {weixinlogin===true?<p className="clearfix">
<a className={"startlogin color-blue"} onClick={()=>this.hideweixinlogin()}>返回账号登录</a> <a className={"startlogin color-blue"} onClick={()=>this.hideweixinlogin()}>返回账号登录</a>
</p>:""} </p>:""}

@ -79,48 +79,26 @@ class Otherlogin extends Component {
} }
getinfo=()=>{
let url = `/users/get_user_info.json`
axios.get(url).then((result)=> {
console.log(result);
if(result){
this.setState({
data:result.data,
spinnings:false
})
}
}).catch((error)=>{
this.setState({
spinnings:false
})
})
}
componentDidMount() { componentDidMount() {
let query=this.props.location.search;
const type = query.split('?code='); let url = `/users/get_user_info.json`
const types = type[1].split('&state='); axios.get(url).then((result)=> {
let codeurl = `/auth/wechat/callback.json` console.log(result);
axios.get(codeurl,{params:{
code:types[0]
}}).then((result)=> {
if(result){ if(result){
if(result.data.status===0){ this.setState({
if(result.data.true===false){ data:result.data,
this.getinfo() spinnings:false
}else{ })
// this.getinfo()
window.location.href="/"
}
}
} }
}).catch((error)=>{ }).catch((error)=>{
this.setState({ this.setState({
spinnings:false spinnings:false
}) })
}) })
}
}
loginInputonChange=(e)=>{ loginInputonChange=(e)=>{

@ -0,0 +1,52 @@
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { Spin } from 'antd';
import axios from 'axios';
class Otherloginstart extends Component {
componentDidMount() {
let query=this.props.location.search;
const type = query.split('?code=');
const types = type[1].split('&state=');
let codeurl = `/auth/wechat/callback.json`
axios.get(codeurl,{params:{
code:types[0]
}}).then((result)=> {
if(result){
if(result.data.status===0){
if(result.data.true===false){
window.location.href="/otherlogin"
}else{
// this.getinfo()
window.location.href="/"
}
}
}
}).catch((error)=>{
})
}
render() {
// Loading
return (
<div className="App" style={{minHeight: '800px',width:"100%"}}>
<style>
{
`
.margintop{
margin-top:20%;
}
`
}
</style>
<Spin size="large" className={"margintop"}/>
</div>
);
}
}
export default Otherloginstart;

@ -1192,7 +1192,7 @@ class LoginRegisterComponent extends Component {
frameBorder="0" frameBorder="0"
sandbox="allow-scripts allow-same-origin allow-top-navigation" sandbox="allow-scripts allow-same-origin allow-top-navigation"
scrolling="no" scrolling="no"
src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherlogin&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""} src="https://open.weixin.qq.com/connect/qrconnect?appid=wx6b119e2d829c13fa&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginstart&response_type=code&scope=snsapi_login#wechat_redirect"></iframe>:""}
{weixinlogin===true?<p className="clearfix mb20 textcenter"> {weixinlogin===true?<p className="clearfix mb20 textcenter">
<a className={"startlogin color-blue"} onClick={()=>this.hideweixinlogin()}>返回登录注册</a> <a className={"startlogin color-blue"} onClick={()=>this.hideweixinlogin()}>返回登录注册</a>
</p>:""} </p>:""}

Loading…
Cancel
Save