Commit 9ad4dfd5 authored by 尚顺利's avatar 尚顺利

企业微信扫码

parent 204c5515
...@@ -41,13 +41,12 @@ class Login { ...@@ -41,13 +41,12 @@ class Login {
const { password } = this.globalConfig; const { password } = this.globalConfig;
const loginMode = Cookies.get('loginMode') || null; const loginMode = Cookies.get('loginMode') || null;
if (loginMode && loginMode === 'iotWechat') ddCode = null; if (loginMode && loginMode === 'iotWechat') ddCode = null;
const self = this; const self = this;
// self.qrcodeLogin(self.globalConfig.qrcodeData.code); // self.qrcodeLogin(self.globalConfig.qrcodeData.code);
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 && loginMode !== 'qywx') { } else if (ddCode && loginMode === 'dingding') {
self.ddLoginIn(ddCode); self.ddLoginIn(ddCode);
} else if (ddCode && loginMode === 'qywx') { } else if (ddCode && loginMode === 'qywx') {
self.qywxLoginIn(ddCode); self.qywxLoginIn(ddCode);
...@@ -392,8 +391,8 @@ class Login { ...@@ -392,8 +391,8 @@ class Login {
} }
return s; return s;
} }
// 企业微信登录
// 企业微信登录
loginByWx() { loginByWx() {
window.WwLogin({ window.WwLogin({
id: 'wxlogin_container', id: 'wxlogin_container',
...@@ -406,17 +405,17 @@ class Login { ...@@ -406,17 +405,17 @@ class Login {
qywxLoginIn(code) { qywxLoginIn(code) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const self = this;
appService appService
.getInfo({ .getInfo({
query: { code,
code,
},
cacheBust: true, cacheBust: true,
}) })
.then(response => { .then(response => {
if (response && response.data && response.data.getMe) { if (response && response.getMe && response.getMe.length) {
const tk = response.data.getMe[0].Token; const tk = response.getMe[0].Token;
this.globalConfig.token = tk; self.globalConfig.token = tk;
Cookies.set('token', tk);
let url = window.location.href; // 获取当前页面的url let url = window.location.href; // 获取当前页面的url
if (url.indexOf('&code') !== -1) { if (url.indexOf('&code') !== -1) {
// 判断是否存在参数 // 判断是否存在参数
...@@ -424,13 +423,13 @@ class Login { ...@@ -424,13 +423,13 @@ class Login {
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数 url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数
window.history.pushState({}, 0, url); window.history.pushState({}, 0, url);
} }
this.isSignIn = true; self.isSignIn = true;
this.getUserInfoAndConfig(); self.getUserInfoAndConfig();
} else { } else {
this.handleLoginError(); self.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码"); // msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message); // msgUtils.fault("登录失败," + error.message);
this.hasTry = true; // 已经输错过密码 self.hasTry = true; // 已经输错过密码
} }
}); });
} }
......
...@@ -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 11:07:30 * @LastEditTime: 2021-09-03 14:58:29
* @LastEditors: shangshunli * @LastEditors: shangshunli
* @Description:信息化登录页; * @Description:信息化登录页;
*/ */
...@@ -32,18 +32,23 @@ class InfoLogin extends React.Component{ ...@@ -32,18 +32,23 @@ class InfoLogin extends React.Component{
isRember:false, //记住密码 isRember:false, //记住密码
ddOrWeixin:'' ddOrWeixin:''
} }
componentDidMount(){
let action=new LoginAction(this.props,false,true)
}
// 切换登录方式 // 切换登录方式
changeloginStyle=()=>{ changeloginStyle=()=>{
const {ddOrWeixin}=this.state const {ddOrWeixin}=this.state
this.setState({ this.setState({
loginStyle:!this.state.loginStyle, loginStyle:!this.state.loginStyle,
ddOrWeixin:ddOrWeixin== 'dingding' ? '':'dingding' ddOrWeixin:ddOrWeixin ? '':'dingding'
},()=>{ },()=>{
Cookies.set('loginMode', 'dingding', { Cookies.set('loginMode', `${ddOrWeixin ? 'pdw' : 'dingding'}`, {
path: '/', path: '/',
}); });
let action=new LoginAction(this.props,false,true) if (ddOrWeixin==='dingding'){
action.loginByDD() let action=new LoginAction(this.props,false,true)
action.loginByDD()
}
}) })
} }
// 切换二维码 // 切换二维码
...@@ -55,15 +60,14 @@ changeQrCode=(item)=>{ ...@@ -55,15 +60,14 @@ changeQrCode=(item)=>{
path: '/', path: '/',
}); });
let action=new LoginAction(this.props,false,true) let action=new LoginAction(this.props,false,true)
if(item=='dingding'){ if(item==='qywx'){
action.loginByDD()
}else if(item=='qywx'){
action.loginByWx() action.loginByWx()
}else if (item==='dingding'){
action.loginByDD()
} }
}) })
} }
// 查看密码 // 查看密码
seePassWord=(e)=>{ seePassWord=(e)=>{
this.setState({ this.setState({
......
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