|
@@ -58,9 +58,23 @@ export default ({ spaceId, projectId }) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const changeSwitch = () => {
|
|
|
- const itemIdSum = !isOpen ? 12 : 10; // 10关闭 12开启
|
|
|
+ function changeSwitch(val) {
|
|
|
+ const itemIdSum = val ? 12 : 10; // 10关闭 12开启
|
|
|
changeAir(itemIdSum);
|
|
|
+ setIsOpen(val);
|
|
|
+ }
|
|
|
+
|
|
|
+ const getAirInfo = () => {
|
|
|
+ const paramsObj = {
|
|
|
+ objectId: spaceId,
|
|
|
+ projectId: projectId,
|
|
|
+ };
|
|
|
+ getFeedbackDocumentsHttp(paramsObj).then((res) => {
|
|
|
+ const val = res.icon == 7 ? false : true;
|
|
|
+ setIsOpen(val); // 开关
|
|
|
+ setStatusText(res.spaceStatus); // 状态文案
|
|
|
+ statusImg(res.icon); // icon
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const changeAir = (itemId) => {
|
|
@@ -76,33 +90,18 @@ export default ({ spaceId, projectId }) => {
|
|
|
getAirInfo();
|
|
|
}, 500);
|
|
|
} else {
|
|
|
- getAirInfo();
|
|
|
- // message.error('操作失败,请重试');
|
|
|
+ message.error('操作失败,请重试');
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const getAirInfo = () => {
|
|
|
- const paramsObj = {
|
|
|
- objectId: spaceId,
|
|
|
- projectId: projectId,
|
|
|
- };
|
|
|
- getFeedbackDocumentsHttp(paramsObj).then((res) => {
|
|
|
- const val = res.icon == 7 ? false : true;
|
|
|
- setIsOpen(val); // 开关
|
|
|
- setStatusText(res.spaceStatus); // 状态文案
|
|
|
- statusImg(res.icon); // icon
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
- getAirInfo();
|
|
|
- timer.current = setInterval(() => {
|
|
|
- getAirInfo(); // 获取空调状态
|
|
|
- }, 1000);
|
|
|
- return () => {
|
|
|
- clearInterval(timer.current);
|
|
|
- };
|
|
|
+ // timer = setInterval(() => {
|
|
|
+ getAirInfo(); // 获取空调状态
|
|
|
+ // }, 1000);
|
|
|
+ // return () => {
|
|
|
+ // clearInterval(timer);
|
|
|
+ // };
|
|
|
}, []);
|
|
|
|
|
|
const AirExpend = () => {
|
|
@@ -152,8 +151,8 @@ export default ({ spaceId, projectId }) => {
|
|
|
<div className={styles.envRight}>
|
|
|
<img className={styles.roomAirImg} src={isOpen ? airOpen : airClose} />
|
|
|
</div>
|
|
|
- <div className={commonStyles.eqBtn} onClick={changeSwitch}>
|
|
|
- <AnSwitch isOpen={isOpen} />
|
|
|
+ <div className={commonStyles.eqBtn}>
|
|
|
+ <AnSwitch isOpen={isOpen} changeSwitch={changeSwitch} />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|