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

fix: 站点获取修改

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