Commit 9ca98570 authored by 杨思琦's avatar 杨思琦

fix: 更新登录接口

parent 9b142ce2
Pipeline #69233 passed with stages
/* eslint-disable no-undef */
import React from 'react';
import { Anchor, message } from 'antd';
......@@ -35,12 +36,7 @@ class Site {
initWeatherCity() {
try {
if (
navigator.onLine &&
this.globalConfig &&
this.globalConfig.userInfo &&
this.globalConfig.userInfo.site
) {
if (navigator.onLine && this.globalConfig && this.globalConfig.userInfo && this.globalConfig.userInfo.site) {
// eslint-disable-next-line no-undef
appService.getCity().then(res => {
// eslint-disable-next-line no-restricted-globals
......@@ -58,13 +54,13 @@ class Site {
}
getCityStationsForUser() {
const { loginName } = this.globalConfig.userInfo;
const { token } = this.globalConfig.userInfo;
const self = this;
return new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
appService
.getAllGroupsInfoForUser({
loginName,
token,
'request.preventCache': new Date().getTime(),
ignoreSite: true,
})
......@@ -77,17 +73,9 @@ class Site {
self.globalConfig.userInfo.Groups = result;
// eslint-disable-next-line no-array-constructor
self.globalConfig.userInfo.Industries = new Array();
if (
self.globalConfig.userInfo.Groups &&
self.globalConfig.userInfo.Groups.length
) {
if (self.globalConfig.userInfo.Groups && self.globalConfig.userInfo.Groups.length) {
self.globalConfig.userInfo.Groups.forEach(group => {
if (
group.industry &&
self.globalConfig.userInfo.Industries.indexOf(
group.industry,
) < 0
)
if (group.industry && self.globalConfig.userInfo.Industries.indexOf(group.industry) < 0)
self.globalConfig.userInfo.Industries.push(group.industry);
});
}
......@@ -111,12 +99,8 @@ class Site {
let projectStation = [];
self.showStations = [];
if (self.globalConfig.Industry) {
allStation = result.filter(
item => item.industry === self.globalConfig.Industry,
);
self.showStations = allStation.filter(
item => item.promoteIndex && item.promoteIndex > 0,
);
allStation = result.filter(item => item.industry === self.globalConfig.Industry);
self.showStations = allStation.filter(item => item.promoteIndex && item.promoteIndex > 0);
projectStation = allStation.filter(item => !item.promoteIndex);
} else {
allStation = result;
......@@ -140,10 +124,7 @@ class Site {
}
// eslint-disable-next-line no-underscore-dangle
let _enterprise = null;
if (
self.globalConfig.userInfo.site &&
self.globalConfig.userInfo.site.length
) {
if (self.globalConfig.userInfo.site && self.globalConfig.userInfo.site.length) {
_enterprise = allStation.filter(
enterprise =>
// eslint-disable-next-line eqeqeq
......@@ -198,10 +179,7 @@ class Site {
const firtValue = res.getMe[0];
if (firtValue.cityName) {
const text = firtValue.forcastFirst.split(' ')[1];
const imgPath = firtValue.presentPictureFirst.replace(
'gif',
'svg',
);
const imgPath = firtValue.presentPictureFirst.replace('gif', 'svg');
resolve({
stations,
allStation,
......@@ -351,19 +329,29 @@ class Site {
// 切换站点后,重置掉三级菜单
const homeType = self.globalConfig.homeType || 'civweb4';
const homePath = self.globalConfig.homepage ? self.globalConfig.homepage.startsWith(homeType) ? self.globalConfig.homepage: `/${homeType}/${self.globalConfig.homepage}`: `/${homeType}`;
window.share && window.share.event && window.share.event.emit('event:favitor', {
const homePath = self.globalConfig.homepage
? self.globalConfig.homepage.startsWith(homeType)
? self.globalConfig.homepage
: `/${homeType}/${self.globalConfig.homepage}`
: `/${homeType}`;
window.share &&
window.share.event &&
window.share.event.emit('event:favitor', {
name: '首页',
path: homePath,
icon: null,
});
actionRef && actionRef.current && actionRef.current.reload()
});
actionRef && actionRef.current && actionRef.current.reload();
// 重新加载订阅消息铃铛
window.share && window.share.event && window.share.event.emit('reloadNotice');
const config = self.globalConfig;
let url = !config.home ? ((config.homepage === '' || _.isNull(config.homepage)) ? `/civweb4`: `/${config.homepage.replace(/^\//, '')}`) : `/${config.homepage.replace(/^\//, '')}`;
const url = !config.home
? config.homepage === '' || _.isNull(config.homepage)
? `/civweb4`
: `/${config.homepage.replace(/^\//, '')}`
: `/${config.homepage.replace(/^\//, '')}`;
self.props.history && self.props.history.push(url);
self.props && self.props.updateCollapsed && self.props.updateCollapsed(false);
window.share.event.emit('triggerMicro', this.props.global);
......@@ -373,28 +361,17 @@ class Site {
}
changeGroup(event, item, onChangeVisible, actionRef) {
debugger
// debugger
event.persist();
const site = item ? item.site : event.target.dataset.site;
const { loginName } = this.globalConfig.userInfo;
const { token } = this.globalConfig.userInfo;
this.setLoading(true);
// eslint-disable-next-line no-undef
appService
.generateTokenQuick({
loginName,
ignoreSite: true,
})
.then(res => {
// eslint-disable-next-line no-debugger
const { token } = res;
if (token) {
this.beforeChangeCheck(token, site, onChangeVisible, actionRef);
}
})
.catch(error => {
this.setLoading(false);
message.warning('切换企业失败');
});
if (token) {
this.beforeChangeCheck(token, site, onChangeVisible, actionRef);
} else {
this.setLoading(false);
message.warning('切换企业失败');
}
}
beforeChangeCheck(token, site, onChangeVisible, actionRef) {
......@@ -520,21 +497,14 @@ class Site {
event.persist();
const self = this;
if (item) {
// eslint-disable-next-line no-undef
appService
.generateTokenQuick({
loginName: self.globalConfig.userInfo.loginName,
ignoreSite: true,
})
.then(res => {
const { token } = res;
if (token) {
self.beforeChangeCheck(token, item.site);
}
})
.catch(error => {
message.warning('切换企业失败');
});
const { token } = self.globalConfig.userInfo;
this.setLoading(true);
if (token) {
this.beforeChangeCheck(token, item.site);
} else {
this.setLoading(false);
message.warning('切换企业失败');
}
}
};
......@@ -544,13 +514,7 @@ class Site {
cityOption: this.getNumberofRegion(data, 1),
siteOption: data,
};
return (
<CitySelector
simple
Clickable={options}
handEnd={(event, item) => this.handEnd(event, item)}
/>
);
return <CitySelector simple Clickable={options} handEnd={(event, item) => this.handEnd(event, item)} />;
}
buildCitySelectTemple(data) {
......@@ -616,12 +580,7 @@ class Site {
children.push(
<div key={j}>
<a
className={styles.letter}
href={`${item.letter}`}
title={item.letter}
id={item.letter}
>
<a className={styles.letter} href={`${item.letter}`} title={item.letter} id={item.letter}>
{item.letter}
</a>
{item.data.map((k, i) => {
......@@ -640,10 +599,7 @@ class Site {
{city.stations.map((item, index) => (
<li key={item.cityName + index}>
<a
className={classNames(
styles.city_select,
!item.isDeployed ? styles.noData : '',
)}
className={classNames(styles.city_select, !item.isDeployed ? styles.noData : '')}
title={item.cityName}
onClick={event => this.changeGroup(event, item)}
>
......
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