Commit d7d60fc6 authored by 杨思琦's avatar 杨思琦

fix: 站点获取修改

parent 4f07d3f9
Pipeline #78708 passed with stages
...@@ -326,6 +326,7 @@ const Layout = props => { ...@@ -326,6 +326,7 @@ const Layout = props => {
const [cityData, setCityData] = useState({}); const [cityData, setCityData] = useState({});
const [siteLoading, setSiteLoading] = useState(false); const [siteLoading, setSiteLoading] = useState(false);
const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading)); const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading));
const [cityLoading, setCityLoading] = useState(false);
const [menuLoading, setMenuLoading] = useState(true); const [menuLoading, setMenuLoading] = useState(true);
const [subLoading, setSubLoading] = useState(true); const [subLoading, setSubLoading] = useState(true);
const [initWebContent, setInitWebContent] = useState(false); const [initWebContent, setInitWebContent] = useState(false);
...@@ -387,13 +388,15 @@ const Layout = props => { ...@@ -387,13 +388,15 @@ const Layout = props => {
props.global.userInfo && props.global.userInfo &&
props.global.userInfo.token !== null && props.global.userInfo.token !== null &&
props.global.userInfo.loginName && props.global.userInfo.loginName &&
Object.keys(cityData).length === 0 Object.keys(cityData).length === 0 &&
!cityLoading
) { ) {
siteAction.getCityStationsForUser().then(res => { setCityLoading(true);
siteAction.getCityStationsForUser(props.global.userInfo?.Groups).then(res => {
setCityData(res); setCityData(res);
}); });
} }
}, [cityData, props.global, props.global.userInfo, siteAction]); }, [cityData, cityLoading, props.global, props.global.userInfo, siteAction]);
useEffect(() => { useEffect(() => {
if (window?.globalConfig?.isIntegration >= 1) { if (window?.globalConfig?.isIntegration >= 1) {
......
...@@ -53,20 +53,12 @@ class Site { ...@@ -53,20 +53,12 @@ class Site {
} }
} }
getCityStationsForUser() { getCityStationsForUser(response) {
const { token } = this.globalConfig.userInfo;
const self = this; const self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
appService if (response) {
.getAllGroupsInfoForUser({ const result = response || [];
token,
'request.preventCache': new Date().getTime(),
ignoreSite: true,
})
.then(res => {
if (res && res.code === 0) {
const result = res.data || [];
let city = self.weatherCity; let city = self.weatherCity;
let arr = []; let arr = [];
self.globalConfig.userInfo.groupType = ''; self.globalConfig.userInfo.groupType = '';
...@@ -225,7 +217,6 @@ class Site { ...@@ -225,7 +217,6 @@ class Site {
} }
} }
}); });
});
} }
insertYSStation() { insertYSStation() {
......
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