Commit b16e7c8d authored by 尚顺利's avatar 尚顺利

钉钉扫码

parent 30861356
...@@ -449,7 +449,7 @@ class Login { ...@@ -449,7 +449,7 @@ class Login {
const handleMessage = function(event) { const handleMessage = function(event) {
const { origin } = event; const { origin } = event;
Logger.log('origin', event.origin); // Logger.log('origin', event.origin);
if (origin === 'https://login.dingtalk.com') { if (origin === 'https://login.dingtalk.com') {
// 判断是否来自ddLogin扫码事件。 // 判断是否来自ddLogin扫码事件。
const loginTmpCode = event.data; const loginTmpCode = event.data;
...@@ -469,17 +469,17 @@ class Login { ...@@ -469,17 +469,17 @@ class Login {
ddLoginIn(code) { ddLoginIn(code) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const self = this;
appService appService
.getOA({ .getOA({
query: { TmpAuthCode: code,
TmpAuthCode: 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) {
// 判断是否存在参数 // 判断是否存在参数
...@@ -487,13 +487,13 @@ class Login { ...@@ -487,13 +487,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; // 已经输错过密码
} }
}); });
} }
...@@ -601,7 +601,7 @@ class Login { ...@@ -601,7 +601,7 @@ class Login {
getUserInfoAndConfig(failCallback, flag, industry) { getUserInfoAndConfig(failCallback, flag, industry) {
const { token: tk } = this.globalConfig; const { token: tk } = this.globalConfig;
const token = tk || Cookies.get('token') const token = tk || Cookies.get('token');
const site = Cookies.get('site'); const site = Cookies.get('site');
const self = this; const self = this;
/* eslint-disable */ /* eslint-disable */
......
...@@ -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-09-03 15:37:12 * @LastEditTime: 2021-09-06 09:35:36
* @LastEditors: shangshunli * @LastEditors: shangshunli
* @Description:信息化登录页; * @Description:信息化登录页;
*/ */
...@@ -43,10 +43,10 @@ class InfoLogin extends React.Component{ ...@@ -43,10 +43,10 @@ class InfoLogin extends React.Component{
loginStyle:!this.state.loginStyle, loginStyle:!this.state.loginStyle,
ddOrWeixin:ddOrWeixin ? '':'dingding' ddOrWeixin:ddOrWeixin ? '':'dingding'
},()=>{ },()=>{
Cookies.set('loginMode', `${ddOrWeixin ? 'pdw' : 'dingding'}`, { Cookies.set('loginMode', `${this.state.ddOrWeixin ? 'dingding' : 'pdw'}`, {
path: '/', path: '/',
}); });
if (ddOrWeixin==='dingding'){ if (this.state.ddOrWeixin==='dingding'){
let action=new LoginAction(this.props,false,true) let action=new LoginAction(this.props,false,true)
action.loginByDD() action.loginByDD()
} }
...@@ -100,6 +100,7 @@ changeQrCode=(item)=>{ ...@@ -100,6 +100,7 @@ changeQrCode=(item)=>{
this.loginEvent(action) this.loginEvent(action)
} }
// 登录成功事件
loginEvent(action){ loginEvent(action){
action.globalConfig = this.props.global; action.globalConfig = this.props.global;
this.props.updateCurrentIndex && this.props.updateCurrentIndex(-1); this.props.updateCurrentIndex && this.props.updateCurrentIndex(-1);
......
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