Commit 3b631478 authored by 杨思琦's avatar 杨思琦

fix: 企业微信跳转修复

parent b6706791
Pipeline #63498 passed with stages
......@@ -20,8 +20,8 @@ const ValidContainer = props => {
const [needChangePassword, setNeedChangePassword] = useState(false);
const [form] = Form.useForm();
// eslint-disable-next-line react/no-this-in-sfc
const password = localStorage.getItem('password_token');
let rules = localStorage.getItem('password_pwdRegex') ? localStorage.getItem('password_pwdRegex') : '';
const check = localStorage.getItem('password_token');
const rulesTip = localStorage.getItem('password_pwdRegexTip') ? localStorage.getItem('password_pwdRegexTip') : '';
let reg;
try {
......@@ -36,7 +36,7 @@ const ValidContainer = props => {
const tk = global.token;
// eslint-disable-next-line no-eval
if (tk) {
if (rules && rules !== '' && !reg.test(password)) {
if (check) {
setNeedChangePassword(true);
}
}
......@@ -48,7 +48,7 @@ const ValidContainer = props => {
.validateFields()
.then(res => {
const params = {
password, // 拼接默认密码
password: res.oldPwd, // 拼接默认密码
newpassword: res.newPwd,
token: window.globalConfig.token,
ignoreSite: true,
......@@ -95,6 +95,19 @@ const ValidContainer = props => {
<span>用户首次登录之前必须修改密码</span>
</div>
<Form labelAlign="left" {...formItemLayout} form={form}>
<Form.Item
name="oldPwd"
label="原密码"
rules={[
{
required: true,
message: '请输入原始密码',
},
]}
hasFeedback
>
<Input.Password />
</Form.Item>
<Form.Item
name="newPwd"
label="新密码"
......
......@@ -216,6 +216,7 @@ export function logout(data) {
path: '/',
});
localStorage.removeItem('access_token');
localStorage.removeItem('password_token');
// eslint-disable-next-line no-undef,no-restricted-globals
createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
// eslint-disable-next-line no-undef,no-restricted-globals
......@@ -233,9 +234,9 @@ export function logout(data) {
if (products) {
Object.keys(products).forEach(item => {
window[products[item]] &&
window[products[item]] &&
window[products[item]].unmount &&
window[products[item]].unmount({ store });
window[products[item]] &&
window[products[item]].unmount &&
window[products[item]].unmount({ store });
});
}
......
......@@ -3,7 +3,7 @@ import _, { isEmpty, isString } from 'lodash';
import MqttClient from 'mqtt-client';
import { isJSON } from '@wisdom-utils/components/lib/AppLayout/helpers/index';
import { api } from './api';
import { replaceSpeak, generatedId, parseContentToJSON } from './utils';
import { replaceSpeak, generatedId } from './utils';
import { postInformationStatus } from './api/service';
import {
DEFAULT_KEEPLIVE,
......@@ -248,9 +248,7 @@ class Notifier {
mqttConfig.NginxStart = self._siteConfig.NginxStart = data.NginxStart;
mqttConfig.mqtt_mess.TcpIP = self._siteConfig.TcpIP = self._siteConfig.mqtt_mess.TcpIP =
window.location.hostname;
mqttConfig.mqtt_mess.TcpPort = self._siteConfig.TcpPort = self._siteConfig.mqtt_mess.TcpPort = parseInt(
window.location.port,
);
mqttConfig.mqtt_mess.TcpPort = self._siteConfig.TcpPort = self._siteConfig.mqtt_mess.TcpPort = parseInt(window.location.port) || 443;
mqttConfig.mqtt_path = self._siteConfig.mqtt_path = '/ws/';
} else {
mqttConfig.nginxStart = data.NginxStart;
......
......@@ -164,7 +164,6 @@ class Login {
}
});
}
if (
!flag &&
this.isSignIn &&
......@@ -490,7 +489,7 @@ class Login {
id: 'wxlogin_container',
appid: 'wxec56ca668e7f9155',
agentid: '1000083',
redirect_uri: encodeURIComponent(window.location.href),
redirect_uri: encodeURIComponent(window.location.href.replace('#/', '')),
href: 'https://mis.panda-water.cn/web4/styles/wx.css',
});
}
......@@ -763,7 +762,6 @@ class Login {
};
self.updateConfig && self.updateConfig(self.globalConfig);
}
if (self.isSignIn || !!industry) {
// eslint-disable-next-line no-undef
getUserInfo({
......@@ -831,7 +829,7 @@ class Login {
}
}
transformLoginHander(response, isRememberPWD) {
transformLoginHander(response, isRememberPWD, pwd) {
const self = this;
const token =
response &&
......@@ -843,10 +841,20 @@ class Login {
if (token) {
const exp = 86400000;
self.globalConfig.token = token;
if (response.access_token !== '') {
self.globalConfig.access_token = response.access_token;
localStorage.setItem('access_token', response.access_token);
localStorage.setItem('password_token', self.globalConfig.password);
if (response.token !== '') {
self.globalConfig.access_token = response.token;
self.updateConfig && self.updateConfig(self.globalConfig);
let rules = localStorage.getItem('password_pwdRegex') ? localStorage.getItem('password_pwdRegex') : '';
let reg;
try {
reg = new RegExp(rules);
} catch (error) {
rules = '';
reg = new RegExp(rules);
}
const check = rules && rules !== '' && !reg.test(pwd)
localStorage.setItem('access_token', response.token);
localStorage.setItem('password_token', check);
Cookies.set('client', self.globalConfig.client, {
expires: exp / (24 * 60 * 60 * 1000),
path: '/',
......@@ -878,7 +886,6 @@ class Login {
login(usr, pwd, userPhone, isRememberPWD, mode = SERVICE_APP_LOGIN_MODE.password) {
this.globalConfig = getGlobalConfig();
const self = this;
self.globalConfig.password = pwd;
if (window.globalConfig && window.globalConfig.hasGateWay) {
usr = userPhone ? userPhone : usr;
appService
......@@ -895,7 +902,7 @@ class Login {
self.updateConfig(
Object.assign({}, self.globalConfig, {
access_token: data.access_token,
token: data.user_token,
token: data.user_token
}),
);
return data;
......@@ -909,7 +916,7 @@ class Login {
}
})
.then(res => {
self.transformLoginHander(res, isRememberPWD);
self.transformLoginHander(res, isRememberPWD, pwd);
});
} else {
appService
......@@ -928,7 +935,7 @@ class Login {
generateType: params.getParams('generateType') || '',
})
.then(response => {
self.transformLoginHander(response, isRememberPWD);
self.transformLoginHander(response, isRememberPWD, pwd);
})
.catch(error => {
self.hasTry = true;
......
import React, { useEffect, useState } from 'react';
import { encode } from 'js-base64';
import Cookies from 'js-cookie';
import { LOGIN_WAY } from '@/constants';
import { WECOM_APPID, AGENTID_CLOUD } from '@/constants';
import { LOGIN_WAY, WECOM_APPID, AGENTID_CLOUD } from '@/constants';
import styles from './index.less';
const useWeCom = props => {
......@@ -11,7 +10,7 @@ const useWeCom = props => {
id: props.container || 'wxlogin_container',
appid: props.appid || WECOM_APPID,
agentid: props.agentid || AGENTID_CLOUD,
redirect_uri: props.redirect_uri || encodeURIComponent(window.location.href),
redirect_uri: props.redirect_uri || encodeURIComponent(window.location.href.replace('#/', '')),
href: props.href || 'https://panda-water.cn/web4/styles/wx.css',
self_redirect: false,
state: props.state || 'STATE',
......@@ -32,11 +31,11 @@ const useIOTQRCode = () => {
const redirectURI = function() {
let redirectUri = window.location.href;
if(redirectUri.indexOf('loginWay') > -1) return redirectUri;
if(redirectUri.indexOf('?') > -1) redirectUri += `&loginWay=${LOGIN_WAY.WeCom}`;
if (redirectUri.indexOf('loginWay') > -1) return redirectUri;
if (redirectUri.indexOf('?') > -1) redirectUri += `&loginWay=${LOGIN_WAY.WeCom}`;
else redirectUri += `?loginWay=${LOGIN_WAY.WeCom}`;
return redirectUri;
}
};
const props = Object.assign(
{},
{
......@@ -49,9 +48,7 @@ const useIOTQRCode = () => {
},
);
useWeCom(props);
return (
<div id="wxlogin_container" className={styles.wxlogin_container}></div>
);
return <div id="wxlogin_container" className={styles.wxlogin_container} />;
};
export default useIOTQRCode;
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