Commit 8cafa855 authored by 尚顺利's avatar 尚顺利

企业微信登录

parent 155cabe6
...@@ -47,8 +47,10 @@ class Login { ...@@ -47,8 +47,10 @@ class Login {
if (token) { if (token) {
self.getToweb(token); self.getToweb(token);
// eslint-disable-next-line no-empty // eslint-disable-next-line no-empty
} else if (ddCode) { } else if (ddCode && loginMode !== 'qywx') {
self.ddLoginIn(ddCode); self.ddLoginIn(ddCode);
} else if (ddCode && loginMode === 'qywx') {
self.qywxLoginIn(ddCode);
} else if (!!loginName && !!password) { } else if (!!loginName && !!password) {
self.otherLoginIn(loginName, password); self.otherLoginIn(loginName, password);
} else if ( } else if (
...@@ -397,38 +399,40 @@ class Login { ...@@ -397,38 +399,40 @@ class Login {
id: 'wxlogin_container', id: 'wxlogin_container',
appid: 'wxec56ca668e7f9155', appid: 'wxec56ca668e7f9155',
agentid: '1000083', agentid: '1000083',
redirect_uri: encodeURIComponent('https://mis.panda-water.cn'), redirect_uri: encodeURIComponent(window.location.href),
href: 'https://mis.panda-water.cn/web4/styles/wx.css', href: 'https://mis.panda-water.cn/web4/styles/wx.css',
}); });
} }
qywxLoginIn(code) { qywxLoginIn(code) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
Http.getInfo({ appService
query: { .getInfo({
code, query: {
}, code,
cacheBust: true, },
}).then(response => { cacheBust: true,
if (response && response.data && response.data.getMe) { })
const tk = response.data.getMe[0].Token; .then(response => {
this.globalConfig.token = tk; if (response && response.data && response.data.getMe) {
let url = window.location.href; // 获取当前页面的url const tk = response.data.getMe[0].Token;
if (url.indexOf('&code') !== -1) { this.globalConfig.token = tk;
// 判断是否存在参数 let url = window.location.href; // 获取当前页面的url
// eslint-disable-next-line no-useless-escape if (url.indexOf('&code') !== -1) {
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数 // 判断是否存在参数
window.history.pushState({}, 0, url); // eslint-disable-next-line no-useless-escape
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数
window.history.pushState({}, 0, url);
}
this.isSignIn = true;
this.getUserInfoAndConfig();
} else {
this.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message);
this.hasTry = true; // 已经输错过密码
} }
this.isSignIn = true; });
this.getUserInfoAndConfig();
} else {
this.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message);
this.hasTry = true; // 已经输错过密码
}
});
} }
loginByDD() { loginByDD() {
...@@ -466,31 +470,33 @@ class Login { ...@@ -466,31 +470,33 @@ class Login {
ddLoginIn(code) { ddLoginIn(code) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
Http.getOA({ appService
query: { .getOA({
TmpAuthCode: code, query: {
}, TmpAuthCode: code,
cacheBust: true, },
}).then(response => { cacheBust: true,
if (response && response.data && response.data.getMe) { })
const tk = response.data.getMe[0].token; .then(response => {
this.globalConfig.token = tk; if (response && response.data && response.data.getMe) {
let url = window.location.href; // 获取当前页面的url const tk = response.data.getMe[0].token;
if (url.indexOf('&code') !== -1) { this.globalConfig.token = tk;
// 判断是否存在参数 let url = window.location.href; // 获取当前页面的url
// eslint-disable-next-line no-useless-escape if (url.indexOf('&code') !== -1) {
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数 // 判断是否存在参数
window.history.pushState({}, 0, url); // eslint-disable-next-line no-useless-escape
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数
window.history.pushState({}, 0, url);
}
this.isSignIn = true;
this.getUserInfoAndConfig();
} else {
this.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message);
this.hasTry = true; // 已经输错过密码
} }
this.isSignIn = true; });
this.getUserInfoAndConfig();
} else {
this.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message);
this.hasTry = true; // 已经输错过密码
}
});
} }
qrcodeLogin(code) { qrcodeLogin(code) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
* @Author: shangshunli; * @Author: shangshunli;
* @Date: 2021-08-02 09:39:46; * @Date: 2021-08-02 09:39:46;
* @LastEditTime: 2021-08-23 10:31:31 * @LastEditTime: 2021-08-23 11:07:30
* @LastEditors: shangshunli * @LastEditors: shangshunli
* @Description:信息化登录页; * @Description:信息化登录页;
*/ */
...@@ -22,6 +22,7 @@ import Selected from '@/assets/oa/login/selected.jpg' ...@@ -22,6 +22,7 @@ import Selected from '@/assets/oa/login/selected.jpg'
import UnSelected from '@/assets/oa/login/unselected.jpg' import UnSelected from '@/assets/oa/login/unselected.jpg'
import LoginAction from '../login'; import LoginAction from '../login';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import Cookies from 'js-cookie';
const Logger = logger('login'); const Logger = logger('login');
// 、登录页 // 、登录页
class InfoLogin extends React.Component{ class InfoLogin extends React.Component{
...@@ -38,6 +39,9 @@ class InfoLogin extends React.Component{ ...@@ -38,6 +39,9 @@ class InfoLogin extends React.Component{
loginStyle:!this.state.loginStyle, loginStyle:!this.state.loginStyle,
ddOrWeixin:ddOrWeixin== 'dingding' ? '':'dingding' ddOrWeixin:ddOrWeixin== 'dingding' ? '':'dingding'
},()=>{ },()=>{
Cookies.set('loginMode', 'dingding', {
path: '/',
});
let action=new LoginAction(this.props,false,true) let action=new LoginAction(this.props,false,true)
action.loginByDD() action.loginByDD()
}) })
...@@ -47,11 +51,15 @@ changeQrCode=(item)=>{ ...@@ -47,11 +51,15 @@ changeQrCode=(item)=>{
this.setState({ this.setState({
ddOrWeixin:item ddOrWeixin:item
},()=>{ },()=>{
Cookies.set('loginMode', item, {
path: '/',
});
let action=new LoginAction(this.props,false,true) let action=new LoginAction(this.props,false,true)
if(item=='dingding'){ if(item=='dingding'){
action.loginByDD() action.loginByDD()
}else if(item=='weixin'){ }else if(item=='qywx'){
action.loginByWx() action.loginByWx()
} }
}) })
...@@ -114,10 +122,10 @@ changeQrCode=(item)=>{ ...@@ -114,10 +122,10 @@ changeQrCode=(item)=>{
<img role="logo" src={TitleImg} alt="gis" className={styles.titleImg} /> <img role="logo" src={TitleImg} alt="gis" className={styles.titleImg} />
{/* 登录主题 */} {/* 登录主题 */}
<div className={styles.login_container} id='login_container' style={{display:ddOrWeixin=='dingding'? '' :'none'}}></div> <div className={styles.login_container} id='login_container' style={{display:ddOrWeixin=='dingding'? '' :'none'}}></div>
<div className={styles.wxlogin_container} id='wxlogin_container' style={{display:ddOrWeixin=='weixin'? '' :'none'}}></div> <div className={styles.wxlogin_container} id='wxlogin_container' style={{display:ddOrWeixin=='qywx'? '' :'none'}}></div>
<div className={styles.changeCode} style={{display:ddOrWeixin? '' :'none'}}> <div className={styles.changeCode} style={{display:ddOrWeixin? '' :'none'}}>
<div style={{margin:'10px',cursor:'pointer',color:ddOrWeixin=='dingding'?'#25bc9e':''}} onClick={()=>this.changeQrCode('dingding')} className={styles.ddLoginBtn}>钉钉登录</div> <div style={{margin:'10px',cursor:'pointer',color:ddOrWeixin=='dingding'?'#25bc9e':''}} onClick={()=>this.changeQrCode('dingding')} className={styles.ddLoginBtn}>钉钉登录</div>
<div style={{margin:'10px',cursor:'pointer',color:ddOrWeixin=='weixin'?'#25bc9e':''}} onClick={()=>this.changeQrCode('weixin')} className={styles.wxLoginBtn}>企业微信登录</div> <div style={{margin:'10px',cursor:'pointer',color:ddOrWeixin=='qywx'?'#25bc9e':''}} onClick={()=>this.changeQrCode('qywx')} className={styles.wxLoginBtn}>企业微信登录</div>
</div> </div>
<form className={styles.loginForm} style={{display:loginStyle? 'none' :''}}> <form className={styles.loginForm} style={{display:loginStyle? 'none' :''}}>
<div className={styles.formgroup}> <div className={styles.formgroup}>
......
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