qq登录调整

issues25489
杨树明 5 years ago
parent 1104f3cb2c
commit 194b9677ba

@ -75,7 +75,10 @@ const Otherloginstart=Loadable({
loader: () => import('./modules/login/Otherloginstart'), loader: () => import('./modules/login/Otherloginstart'),
loading: Loading, loading: Loading,
}) })
const Otherloginsqq=Loadable({
loader: () => import('./modules/login/Otherloginqq'),
loading: Loading,
})
// const TestIndex = Loadable({ // const TestIndex = Loadable({
// loader: () => import('./modules/test'), // loader: () => import('./modules/test'),
// loading: Loading, // loading: Loading,
@ -527,6 +530,9 @@ class App extends Component {
<Route <Route
path="/otherloginstart" component={Otherloginstart} path="/otherloginstart" component={Otherloginstart}
/> />
<Route
path={"/otherloginqq"} component={Otherloginsqq}
/>
<Route <Route
path="/otherlogin" component={Otherlogin} path="/otherlogin" component={Otherlogin}
/> />

@ -21,16 +21,16 @@ let hashTimeout
// TODO 开发期多个身份切换 // TODO 开发期多个身份切换
let debugType ="" let debugType =""
if (isDev) { // if (isDev) {
const _search = window.location.search; // const _search = window.location.search;
let parsed = {}; // let parsed = {};
if (_search) { // if (_search) {
parsed = queryString.parse(_search); // parsed = queryString.parse(_search);
} // }
debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : // debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' :
window.location.search.indexOf('debug=s') != -1 ? 'student' : // window.location.search.indexOf('debug=s') != -1 ? 'student' :
window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' // window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin'
} // }
window._debugType = debugType; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {
initOnlineOfflineListener() initOnlineOfflineListener()
@ -73,15 +73,22 @@ export function initAxiosInterceptors(props) {
} }
requestProxy(config) requestProxy(config)
var url = `/api${config.url}`; let url = `/api${config.url}`;
//qq登录去掉api
if(config.params&&config.params.redirect_uri!=undefined){
if(config.params.redirect_uri.indexOf('otherloginqq')!=-1){
url = `${config.url}`;
}
}
if(`${config[0]}`!=`true`){ if(`${config[0]}`!=`true`){
if (window.location.port === "3007") { if (window.location.port === "3007") {
if (url.indexOf('.json') == -1) { // if (url.indexOf('.json') == -1) {
//
alert('开发提示:请给接口加.json:' + url) // alert('开发提示:请给接口加.json:' + url)
//
} // }
config.url = `${proxy}${url}`; config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) { if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${debugType}`; config.url = `${config.url}?debug=${debugType}`;

@ -533,8 +533,8 @@ class LoginDialog extends Component {
this.setState({ this.setState({
qqlogin:true qqlogin:true
}) })
window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2f${window.location.host}%2otherloginqq&response_type=code` //window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2f${window.location.host}%2otherloginqq&response_type=code`
window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2ftest-newweb.educoder.net%2fotherloginqq&response_type=code`
// window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginstart&tp=qq&response_type=code` // window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2fwww.educoder.net%2fotherloginstart&tp=qq&response_type=code`
} }
hideweixinlogin=()=>{ hideweixinlogin=()=>{

@ -132,6 +132,8 @@ class Otherlogin extends Component {
} }
postwechatlogin=(type,username,password)=>{ postwechatlogin=(type,username,password)=>{
let query=this.props.location.search;
const types = query.split('?type=');
if(type===false){ if(type===false){
if(username===undefined||username===""||username===null){ if(username===undefined||username===""||username===null){
this.setState({ this.setState({
@ -146,9 +148,11 @@ class Otherlogin extends Component {
return return
} }
} }
let url = "/bind_user.json"; let url = "/bind_user.json";
axios.post(url, { axios.post(url, {
type: 'wechat', type: types[1]==="qq"?"qq":'wechat',
not_bind:type, not_bind:type,
username:username, username:username,
password:password password:password

@ -0,0 +1,60 @@
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { Spin } from 'antd';
import axios from 'axios';
class Otherloginqq extends Component {
componentDidMount() {
let query=this.props.location.search;
if(query!= ""){
}
const type = query.split('?code=');
let codeurl = `/auth/qq/callback`;
axios.get(codeurl,{params:{
code:type[1],
redirect_uri:`https://test-newweb.educoder.net/otherloginqq`
}}).then((result)=> {
if(result){
if(result.data.status===0){
if(result.data.new_user===true){
window.location.href="/otherlogin?type=qq"
}else{
// this.getinfo()
if(types[1]==="account"){
window.location.href="/account/binding"
}else{
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 Otherloginqq;

@ -8,30 +8,34 @@ class Otherloginstart extends Component {
componentDidMount() { componentDidMount() {
let query=this.props.location.search; let query=this.props.location.search;
const type = query.split('?code='); debugger
const types = type[1].split('&state='); if(query!= ""){
let codeurl = `/auth/wechat/callback.json` const type = query.split('?code=');
axios.get(codeurl,{params:{ const types = type[1].split('&state=');
code:types[0] let codeurl = `/auth/wechat/callback.json`
}}).then((result)=> { axios.get(codeurl,{params:{
if(result){ code:types[0]
if(result.data.status===0){ }}).then((result)=> {
if(result.data.new_user===true){ if(result){
window.location.href="/otherlogin" if(result.data.status===0){
}else{ if(result.data.new_user===true){
// this.getinfo() window.location.href="/otherlogin?type=wechat"
if(types[1]==="account"){
window.location.href="/account/binding"
}else{ }else{
window.location.href="/" // this.getinfo()
} if(types[1]==="account"){
window.location.href="/account/binding"
}else{
window.location.href="/"
}
}
} }
} }
} }).catch((error)=>{
}).catch((error)=>{
})
}
})
} }

Loading…
Cancel
Save