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

企业微信登录

parent 155cabe6
......@@ -47,8 +47,10 @@ class Login {
if (token) {
self.getToweb(token);
// eslint-disable-next-line no-empty
} else if (ddCode) {
} else if (ddCode && loginMode !== 'qywx') {
self.ddLoginIn(ddCode);
} else if (ddCode && loginMode === 'qywx') {
self.qywxLoginIn(ddCode);
} else if (!!loginName && !!password) {
self.otherLoginIn(loginName, password);
} else if (
......@@ -397,38 +399,40 @@ class Login {
id: 'wxlogin_container',
appid: 'wxec56ca668e7f9155',
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',
});
}
qywxLoginIn(code) {
// eslint-disable-next-line no-undef
Http.getInfo({
query: {
code,
},
cacheBust: true,
}).then(response => {
if (response && response.data && response.data.getMe) {
const tk = response.data.getMe[0].Token;
this.globalConfig.token = tk;
let url = window.location.href; // 获取当前页面的url
if (url.indexOf('&code') !== -1) {
// 判断是否存在参数
// eslint-disable-next-line no-useless-escape
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数
window.history.pushState({}, 0, url);
appService
.getInfo({
query: {
code,
},
cacheBust: true,
})
.then(response => {
if (response && response.data && response.data.getMe) {
const tk = response.data.getMe[0].Token;
this.globalConfig.token = tk;
let url = window.location.href; // 获取当前页面的url
if (url.indexOf('&code') !== -1) {
// 判断是否存在参数
// 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() {
......@@ -466,31 +470,33 @@ class Login {
ddLoginIn(code) {
// eslint-disable-next-line no-undef
Http.getOA({
query: {
TmpAuthCode: code,
},
cacheBust: true,
}).then(response => {
if (response && response.data && response.data.getMe) {
const tk = response.data.getMe[0].token;
this.globalConfig.token = tk;
let url = window.location.href; // 获取当前页面的url
if (url.indexOf('&code') !== -1) {
// 判断是否存在参数
// eslint-disable-next-line no-useless-escape
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数
window.history.pushState({}, 0, url);
appService
.getOA({
query: {
TmpAuthCode: code,
},
cacheBust: true,
})
.then(response => {
if (response && response.data && response.data.getMe) {
const tk = response.data.getMe[0].token;
this.globalConfig.token = tk;
let url = window.location.href; // 获取当前页面的url
if (url.indexOf('&code') !== -1) {
// 判断是否存在参数
// 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) {
......
......@@ -2,7 +2,7 @@
/*
* @Author: shangshunli;
* @Date: 2021-08-02 09:39:46;
* @LastEditTime: 2021-08-23 10:31:31
* @LastEditTime: 2021-08-23 11:07:30
* @LastEditors: shangshunli
* @Description:信息化登录页;
*/
......@@ -22,6 +22,7 @@ import Selected from '@/assets/oa/login/selected.jpg'
import UnSelected from '@/assets/oa/login/unselected.jpg'
import LoginAction from '../login';
import { actionCreators } from '@/containers/App/store';
import Cookies from 'js-cookie';
const Logger = logger('login');
// 、登录页
class InfoLogin extends React.Component{
......@@ -38,6 +39,9 @@ class InfoLogin extends React.Component{
loginStyle:!this.state.loginStyle,
ddOrWeixin:ddOrWeixin== 'dingding' ? '':'dingding'
},()=>{
Cookies.set('loginMode', 'dingding', {
path: '/',
});
let action=new LoginAction(this.props,false,true)
action.loginByDD()
})
......@@ -47,11 +51,15 @@ changeQrCode=(item)=>{
this.setState({
ddOrWeixin:item
},()=>{
Cookies.set('loginMode', item, {
path: '/',
});
let action=new LoginAction(this.props,false,true)
if(item=='dingding'){
action.loginByDD()
}else if(item=='weixin'){
}else if(item=='qywx'){
action.loginByWx()
}
})
......@@ -114,10 +122,10 @@ changeQrCode=(item)=>{
<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.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 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>
<form className={styles.loginForm} style={{display:loginStyle? 'none' :''}}>
<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