|
@@ -492,9 +492,9 @@
|
|
|
</slider-panel-v2>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import wepy from '@wepy/core';
|
|
|
-import { checkLogin } from '@/service/user';
|
|
|
-import { isWithinLocation } from '@/service/location';
|
|
|
+import wepy from '@wepy/core'
|
|
|
+import { checkLogin } from '@/service/user'
|
|
|
+import { isWithinLocation } from '@/service/location'
|
|
|
|
|
|
import {
|
|
|
getSpaceLightsHttp,
|
|
@@ -503,31 +503,31 @@ import {
|
|
|
getAirConditionStatusHttp,
|
|
|
changeAirconditionHttp,
|
|
|
checkChangeLightStatusSuccessHttp
|
|
|
-} from '@/packagesEnv/api/intelligentControl';
|
|
|
-import utils from '@/common/utils';
|
|
|
-
|
|
|
-const panel = wx.createSelectorQuery().select('.panel-intelligent-control');
|
|
|
-let lightsStatusTimer;
|
|
|
-let oldAirconditinStatus;
|
|
|
-let airconditionCoutdownTimer;
|
|
|
-let changeAirconditionTimer;
|
|
|
-let windspeedTimer;
|
|
|
-let changewindspeedTimer;
|
|
|
-let setWeedInitTimer;
|
|
|
-
|
|
|
-let airConditionStatusTimer;
|
|
|
-let startCheckLightsTime = 0;
|
|
|
-let envInfoTimer;
|
|
|
+} from '@/packagesEnv/api/intelligentControl'
|
|
|
+import utils from '@/common/utils'
|
|
|
+
|
|
|
+const panel = wx.createSelectorQuery().select('.panel-intelligent-control')
|
|
|
+let lightsStatusTimer
|
|
|
+let oldAirconditinStatus
|
|
|
+let airconditionCoutdownTimer
|
|
|
+let changeAirconditionTimer
|
|
|
+let windspeedTimer
|
|
|
+let changewindspeedTimer
|
|
|
+let setWeedInitTimer
|
|
|
+
|
|
|
+let airConditionStatusTimer
|
|
|
+let startCheckLightsTime = 0
|
|
|
+let envInfoTimer
|
|
|
|
|
|
// 注意单位都是rpx
|
|
|
// 伸展状态下的面板高度
|
|
|
-const expandPanelHeight = 407 * 2;
|
|
|
+const expandPanelHeight = 407 * 2
|
|
|
// 收缩状态下的面板高度
|
|
|
-const foldPanelHeight = 96 * 2;
|
|
|
+const foldPanelHeight = 96 * 2
|
|
|
|
|
|
-import config from '@/config';
|
|
|
+import config from '@/config'
|
|
|
|
|
|
-let h5StaticPath = config.h5StaticPath + '/page-intelligent-control/';
|
|
|
+let h5StaticPath = config.h5StaticPath + '/page-intelligent-control/'
|
|
|
let defaultEnvIitems = [
|
|
|
{
|
|
|
title: 'PM 2.5',
|
|
@@ -557,7 +557,7 @@ let defaultEnvIitems = [
|
|
|
des: '',
|
|
|
id: 'humidity'
|
|
|
}
|
|
|
-];
|
|
|
+]
|
|
|
wepy.component({
|
|
|
data: {
|
|
|
h5StaticPath: h5StaticPath,
|
|
@@ -582,10 +582,10 @@ wepy.component({
|
|
|
selectedControlOption: 'equipment',
|
|
|
toplightOpened: true,
|
|
|
spotlightOpened: true,
|
|
|
- airConditionStatus: 1, //空调默认状态,为开启
|
|
|
+ airConditionStatus: 1, // 空调默认状态,为开启
|
|
|
airConditionStatusText: '',
|
|
|
- airConditioningSwitchStatus: 'closed', //open-开启 openOperating-打开中 closedOperating-关闭中 closed-关闭
|
|
|
- windspeedStatus: 'init', //init-初始状态 minimizing-调小中 minied-继续调小
|
|
|
+ airConditioningSwitchStatus: 'closed', // open-开启 openOperating-打开中 closedOperating-关闭中 closed-关闭
|
|
|
+ windspeedStatus: 'init', // init-初始状态 minimizing-调小中 minied-继续调小
|
|
|
environmentItems: [...defaultEnvIitems],
|
|
|
countdownText: 3,
|
|
|
windCountdownText: 3,
|
|
@@ -614,163 +614,163 @@ wepy.component({
|
|
|
watch: {
|
|
|
spaceId: function(newSpaceId, oldSpaceId) {
|
|
|
if (oldSpaceId !== newSpaceId) {
|
|
|
- this.reset();
|
|
|
- this.getPanelInfo();
|
|
|
+ this.reset()
|
|
|
+ this.getPanelInfo()
|
|
|
}
|
|
|
},
|
|
|
pageHide: function(newValue, oldValue) {
|
|
|
if (oldValue !== newValue) {
|
|
|
if (newValue == true) {
|
|
|
- this.reset();
|
|
|
+ this.reset()
|
|
|
} else if (oldValue == true && newValue == false) {
|
|
|
- this.getPanelInfo();
|
|
|
+ this.getPanelInfo()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
detached: function() {
|
|
|
// 在组件实例被从页面节点树移除时执行
|
|
|
- this.reset();
|
|
|
+ this.reset()
|
|
|
},
|
|
|
methods: {
|
|
|
vibrateShort() {
|
|
|
if (wx.canIUse('vibrateShort')) {
|
|
|
- wx.vibrateShort();
|
|
|
+ wx.vibrateShort()
|
|
|
}
|
|
|
},
|
|
|
changeControlOption(value) {
|
|
|
- this.selectedControlOption = value;
|
|
|
+ this.selectedControlOption = value
|
|
|
},
|
|
|
changeTopLightStatus(event) {
|
|
|
- isWithinLocation().then(() => {
|
|
|
- const light = event.currentTarget.dataset.light;
|
|
|
- let { lights } = this;
|
|
|
-
|
|
|
- lightsStatusTimer = clearInterval(lightsStatusTimer); //先关闭轮询,然后再重启
|
|
|
- this.vibrateShort();
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- //查询等状态
|
|
|
- getSpaceLightsHttp(this.spaceId, this.companyId)
|
|
|
+ // isWithinLocation().then(() => {
|
|
|
+ const light = event.currentTarget.dataset.light
|
|
|
+ let { lights } = this
|
|
|
+
|
|
|
+ lightsStatusTimer = clearInterval(lightsStatusTimer) // 先关闭轮询,然后再重启
|
|
|
+ this.vibrateShort()
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ // 查询等状态
|
|
|
+ getSpaceLightsHttp(this.spaceId, this.companyId)
|
|
|
.then(
|
|
|
res => {
|
|
|
- const result = JSON.parse(res.data);
|
|
|
- const data = (result && result.content) || [];
|
|
|
- let lights = this.convertLightStatus(data);
|
|
|
+ const result = JSON.parse(res.data)
|
|
|
+ const data = (result && result.content) || []
|
|
|
+ let lights = this.convertLightStatus(data)
|
|
|
|
|
|
- let currentLights = lights.filter(item => item.id == light.id)[0];
|
|
|
+ let currentLights = lights.filter(item => item.id == light.id)[0]
|
|
|
if (currentLights && currentLights.opened == light.opened) {
|
|
|
- return setSpaceLightHttp(light.id, !light.opened, this.companyId);
|
|
|
+ return setSpaceLightHttp(light.id, !light.opened, this.companyId)
|
|
|
} else {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
wx.showToast({
|
|
|
title: '已' + (!light.opened ? '开' : '关') + '灯',
|
|
|
duration: 2000
|
|
|
- });
|
|
|
- this.setLightStatus(light.id);
|
|
|
- return Promise.reject();
|
|
|
+ })
|
|
|
+ this.setLightStatus(light.id)
|
|
|
+ return Promise.reject()
|
|
|
}
|
|
|
},
|
|
|
res => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
// 不是网络错误的情况下继续刷
|
|
|
if (res && res.reason != 'wxRequestFail') {
|
|
|
- this.startLightsStatusTimer();
|
|
|
+ this.startLightsStatusTimer()
|
|
|
}
|
|
|
- return Promise.reject(res);
|
|
|
+ return Promise.reject(res)
|
|
|
}
|
|
|
)
|
|
|
.then(
|
|
|
res => {
|
|
|
// 当网络异常的时候,没有数据返回,也不进行之后的操作
|
|
|
if (res) {
|
|
|
- return this.judgeChangeResponeseSuccess(res);
|
|
|
+ return this.judgeChangeResponeseSuccess(res)
|
|
|
}
|
|
|
},
|
|
|
res => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
if (res && res.reason != 'wxRequestFail') {
|
|
|
- this.startLightsStatusTimer();
|
|
|
+ this.startLightsStatusTimer()
|
|
|
}
|
|
|
- return Promise.reject(res);
|
|
|
+ return Promise.reject(res)
|
|
|
}
|
|
|
)
|
|
|
.then(
|
|
|
res => {
|
|
|
if (!(res && res.status)) {
|
|
|
- wx.hideLoading();
|
|
|
- return;
|
|
|
+ wx.hideLoading()
|
|
|
+ return
|
|
|
}
|
|
|
switch (res.status) {
|
|
|
case 'success':
|
|
|
// 去更改灯的状态
|
|
|
- wx.hideLoading();
|
|
|
- this.setLightStatus(light.id);
|
|
|
- this.startLightsStatusTimer();
|
|
|
- break;
|
|
|
+ wx.hideLoading()
|
|
|
+ this.setLightStatus(light.id)
|
|
|
+ this.startLightsStatusTimer()
|
|
|
+ break
|
|
|
case 'processing':
|
|
|
// 继续查询
|
|
|
- startCheckLightsTime = new Date().getTime();
|
|
|
+ startCheckLightsTime = new Date().getTime()
|
|
|
return this.checkChangeLightStatusSuccess(
|
|
|
light.id,
|
|
|
!light.opened,
|
|
|
res.data.orderSeqNum
|
|
|
- );
|
|
|
- break;
|
|
|
+ )
|
|
|
+ break
|
|
|
default:
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
}
|
|
|
},
|
|
|
(res) => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
wx.showToast({
|
|
|
title: '操作失败,请重试',
|
|
|
icon: 'none'
|
|
|
- });
|
|
|
+ })
|
|
|
// 不是网络错误的情况下继续刷
|
|
|
if (res && res.reason != 'wxRequestFail') {
|
|
|
- this.startLightsStatusTimer();
|
|
|
+ this.startLightsStatusTimer()
|
|
|
}
|
|
|
}
|
|
|
- );
|
|
|
- });
|
|
|
+ )
|
|
|
+ // });
|
|
|
},
|
|
|
judgeChangeResponeseSuccess(res) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- let response = JSON.parse(res.data);
|
|
|
- let result = response.content[0];
|
|
|
+ let response = JSON.parse(res.data)
|
|
|
+ let result = response.content[0]
|
|
|
|
|
|
if (result.result == 'success') {
|
|
|
if (result.state == 200 && result.exeResult == 'success') {
|
|
|
- resolve({ status: 'success', data: result });
|
|
|
+ resolve({ status: 'success', data: result })
|
|
|
} else if (
|
|
|
(result.state == 200 && result.exeResult == 'processing:rcvd') ||
|
|
|
(result.state == 202 && !result.exeResult)
|
|
|
) {
|
|
|
- //查询数据
|
|
|
- resolve({ status: 'processing', data: result });
|
|
|
+ // 查询数据
|
|
|
+ resolve({ status: 'processing', data: result })
|
|
|
} else {
|
|
|
- reject();
|
|
|
+ reject()
|
|
|
}
|
|
|
} else {
|
|
|
- reject();
|
|
|
+ reject()
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
checkChangeLightStatusSuccess(lightId, status, orderSeqNum) {
|
|
|
// 判断是否已到五秒,到达5s则不去处理了
|
|
|
- let now = new Date().getTime();
|
|
|
+ let now = new Date().getTime()
|
|
|
if (now - startCheckLightsTime >= 5 * 1000) {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
setTimeout(() => {
|
|
|
wx.showToast({
|
|
|
title: '网络故障,请重试',
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
- });
|
|
|
- }, 200);
|
|
|
+ })
|
|
|
+ }, 200)
|
|
|
} else {
|
|
|
checkChangeLightStatusSuccessHttp({
|
|
|
lightId: lightId,
|
|
@@ -778,437 +778,437 @@ wepy.component({
|
|
|
orderSeqNum
|
|
|
})
|
|
|
.then(res => {
|
|
|
- return this.judgeChangeResponeseSuccess(res);
|
|
|
+ return this.judgeChangeResponeseSuccess(res)
|
|
|
})
|
|
|
.then(
|
|
|
res => {
|
|
|
switch (res.status) {
|
|
|
case 'success':
|
|
|
// 去更改灯的状态
|
|
|
- wx.hideLoading();
|
|
|
- this.setLightStatus(lightId);
|
|
|
- break;
|
|
|
+ wx.hideLoading()
|
|
|
+ this.setLightStatus(lightId)
|
|
|
+ break
|
|
|
case 'processing':
|
|
|
// 继续查询
|
|
|
- let result = res.data;
|
|
|
+ let result = res.data
|
|
|
this.checkChangeLightStatusSuccess(
|
|
|
lightId,
|
|
|
status,
|
|
|
result.orderSeqNum
|
|
|
- );
|
|
|
- break;
|
|
|
+ )
|
|
|
+ break
|
|
|
}
|
|
|
},
|
|
|
() => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
setTimeout(() => {
|
|
|
wx.showToast({
|
|
|
title: '操作失败,请重试',
|
|
|
icon: 'fail',
|
|
|
duration: 2000
|
|
|
- });
|
|
|
- }, 0);
|
|
|
+ })
|
|
|
+ }, 0)
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
}
|
|
|
},
|
|
|
setLightStatus(lightId) {
|
|
|
- let { lights } = this;
|
|
|
+ let { lights } = this
|
|
|
lights.find(item => {
|
|
|
if (item.id == lightId) {
|
|
|
- item.opened = !item.opened;
|
|
|
+ item.opened = !item.opened
|
|
|
}
|
|
|
- });
|
|
|
- this.lights = [...lights];
|
|
|
+ })
|
|
|
+ this.lights = [...lights]
|
|
|
},
|
|
|
changeSpotLightStatus() {
|
|
|
- this.spotlightOpened = !this.spotlightOpened;
|
|
|
+ this.spotlightOpened = !this.spotlightOpened
|
|
|
},
|
|
|
changeAircondition() {
|
|
|
- isWithinLocation().then(() => {
|
|
|
- this.vibrateShort();
|
|
|
- airConditionStatusTimer = clearInterval(airConditionStatusTimer);
|
|
|
- let airConditioningSwitchStatus = this.airConditioningSwitchStatus;
|
|
|
- if (airConditioningSwitchStatus == 'open') {
|
|
|
- this.setAirconditionOperting('open', 'closed');
|
|
|
- } else if (airConditioningSwitchStatus.indexOf('Operating') !== -1) {
|
|
|
- this.airConditioningSwitchStatus = oldAirconditinStatus;
|
|
|
- this.clearAirconditionCutdownTimer();
|
|
|
- this.startAirConditionStatusTimer();
|
|
|
- } else if (airConditioningSwitchStatus == 'closed') {
|
|
|
- this.setAirconditionOperting('closed', 'open');
|
|
|
- }
|
|
|
- });
|
|
|
+ // isWithinLocation().then(() => {
|
|
|
+ this.vibrateShort()
|
|
|
+ airConditionStatusTimer = clearInterval(airConditionStatusTimer)
|
|
|
+ let airConditioningSwitchStatus = this.airConditioningSwitchStatus
|
|
|
+ if (airConditioningSwitchStatus == 'open') {
|
|
|
+ this.setAirconditionOperting('open', 'closed')
|
|
|
+ } else if (airConditioningSwitchStatus.indexOf('Operating') !== -1) {
|
|
|
+ this.airConditioningSwitchStatus = oldAirconditinStatus
|
|
|
+ this.clearAirconditionCutdownTimer()
|
|
|
+ this.startAirConditionStatusTimer()
|
|
|
+ } else if (airConditioningSwitchStatus == 'closed') {
|
|
|
+ this.setAirconditionOperting('closed', 'open')
|
|
|
+ }
|
|
|
+ // })
|
|
|
},
|
|
|
clearAirconditionCutdownTimer() {
|
|
|
- this.countdownText = 3;
|
|
|
- airconditionCoutdownTimer = clearInterval(airconditionCoutdownTimer);
|
|
|
- changeAirconditionTimer = clearTimeout(changeAirconditionTimer);
|
|
|
+ this.countdownText = 3
|
|
|
+ airconditionCoutdownTimer = clearInterval(airconditionCoutdownTimer)
|
|
|
+ changeAirconditionTimer = clearTimeout(changeAirconditionTimer)
|
|
|
},
|
|
|
setAirconditionOperting(oldStatus, newStatus) {
|
|
|
- this.clearAirconditionCutdownTimer();
|
|
|
- oldAirconditinStatus = oldStatus;
|
|
|
- this.airConditioningSwitchStatus = newStatus + 'Operating';
|
|
|
+ this.clearAirconditionCutdownTimer()
|
|
|
+ oldAirconditinStatus = oldStatus
|
|
|
+ this.airConditioningSwitchStatus = newStatus + 'Operating'
|
|
|
// 开启倒计时
|
|
|
airconditionCoutdownTimer = setInterval(() => {
|
|
|
if (this.countdownText > 1) {
|
|
|
- this.countdownText = --this.countdownText;
|
|
|
+ this.countdownText = --this.countdownText
|
|
|
}
|
|
|
- }, 1000);
|
|
|
+ }, 1000)
|
|
|
|
|
|
- //开启3s后自动调节成功
|
|
|
+ // 开启3s后自动调节成功
|
|
|
changeAirconditionTimer = setTimeout(() => {
|
|
|
- this.doChangeAircondition(newStatus);
|
|
|
- }, 3000);
|
|
|
+ this.doChangeAircondition(newStatus)
|
|
|
+ }, 3000)
|
|
|
},
|
|
|
doChangeAircondition(newStatus) {
|
|
|
- let httStatus = newStatus == 'closed' ? 10 : 12; // 10 是关闭,12是开启
|
|
|
+ let httStatus = newStatus == 'closed' ? 10 : 12 // 10 是关闭,12是开启
|
|
|
wx.showLoading({
|
|
|
- title: '加载中...', //提示的内容,
|
|
|
- mask: true //显示透明蒙层,防止触摸穿透
|
|
|
- });
|
|
|
+ title: '加载中...', // 提示的内容,
|
|
|
+ mask: true // 显示透明蒙层,防止触摸穿透
|
|
|
+ })
|
|
|
|
|
|
- this.clearAirconditionCutdownTimer();
|
|
|
+ this.clearAirconditionCutdownTimer()
|
|
|
changeAirconditionHttp(this.spaceId, httStatus, this.companyId).then(
|
|
|
() => {
|
|
|
this.getAirConditionStatus().then(
|
|
|
afterChangeStatus => {
|
|
|
- wx.hideLoading();
|
|
|
- this.setAirconditionDatavalue(afterChangeStatus);
|
|
|
- this.startAirConditionStatusTimer();
|
|
|
+ wx.hideLoading()
|
|
|
+ this.setAirconditionDatavalue(afterChangeStatus)
|
|
|
+ this.startAirConditionStatusTimer()
|
|
|
},
|
|
|
() => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
},
|
|
|
() => {
|
|
|
- wx.hideLoading();
|
|
|
- //失败需要回退
|
|
|
- this.startAirConditionStatusTimer();
|
|
|
- this.setAirconditionDatavalue(oldAirconditinStatus);
|
|
|
+ wx.hideLoading()
|
|
|
+ // 失败需要回退
|
|
|
+ this.startAirConditionStatusTimer()
|
|
|
+ this.setAirconditionDatavalue(oldAirconditinStatus)
|
|
|
}
|
|
|
- );
|
|
|
- this.countdownText = 3;
|
|
|
- //如果关闭,同时关闭调小风速倒计是
|
|
|
+ )
|
|
|
+ this.countdownText = 3
|
|
|
+ // 如果关闭,同时关闭调小风速倒计是
|
|
|
if (newStatus == 'closed') {
|
|
|
- this.cancelWindSpeedMinimzing();
|
|
|
+ this.cancelWindSpeedMinimzing()
|
|
|
}
|
|
|
},
|
|
|
setAirconditionDatavalue(switcStatus) {
|
|
|
- let showStatus = switcStatus == 'closed' ? 0 : 1;
|
|
|
- this.airConditionStatus = showStatus;
|
|
|
- this.airConditionStatusText = this.getAirConditionStatusText(showStatus); //设置提示文案
|
|
|
- this.airConditioningSwitchStatus = switcStatus;
|
|
|
+ let showStatus = switcStatus == 'closed' ? 0 : 1
|
|
|
+ this.airConditionStatus = showStatus
|
|
|
+ this.airConditionStatusText = this.getAirConditionStatusText(showStatus) // 设置提示文案
|
|
|
+ this.airConditioningSwitchStatus = switcStatus
|
|
|
},
|
|
|
changeWindspeed() {
|
|
|
- isWithinLocation().then(() => {
|
|
|
- this.vibrateShort();
|
|
|
- let windspeedStatus = this.windspeedStatus;
|
|
|
- if (windspeedStatus === 'init') {
|
|
|
- this.setWindSpeedMinimzing();
|
|
|
- } else if (windspeedStatus === 'minimizing') {
|
|
|
- this.cancelWindSpeedMinimzing();
|
|
|
- } else if (windspeedStatus === 'minied') {
|
|
|
- clearTimeout(setWeedInitTimer);
|
|
|
- this.setWindSpeedMinimzing();
|
|
|
- }
|
|
|
- });
|
|
|
+ // isWithinLocation().then(() => {
|
|
|
+ this.vibrateShort()
|
|
|
+ let windspeedStatus = this.windspeedStatus
|
|
|
+ if (windspeedStatus === 'init') {
|
|
|
+ this.setWindSpeedMinimzing()
|
|
|
+ } else if (windspeedStatus === 'minimizing') {
|
|
|
+ this.cancelWindSpeedMinimzing()
|
|
|
+ } else if (windspeedStatus === 'minied') {
|
|
|
+ clearTimeout(setWeedInitTimer)
|
|
|
+ this.setWindSpeedMinimzing()
|
|
|
+ }
|
|
|
+ // })
|
|
|
},
|
|
|
setWindSpeedMinimzing() {
|
|
|
- this.windspeedStatus = 'minimizing';
|
|
|
- this.openWindCountdown();
|
|
|
- this.setWindMinied();
|
|
|
+ this.windspeedStatus = 'minimizing'
|
|
|
+ this.openWindCountdown()
|
|
|
+ this.setWindMinied()
|
|
|
},
|
|
|
cancelWindSpeedMinimzing() {
|
|
|
- setWeedInitTimer = clearTimeout(setWeedInitTimer);
|
|
|
- windspeedTimer = clearInterval(windspeedTimer);
|
|
|
- changewindspeedTimer = clearInterval(changewindspeedTimer);
|
|
|
- this.windspeedStatus = 'init';
|
|
|
- this.windCountdownText = 3;
|
|
|
+ setWeedInitTimer = clearTimeout(setWeedInitTimer)
|
|
|
+ windspeedTimer = clearInterval(windspeedTimer)
|
|
|
+ changewindspeedTimer = clearInterval(changewindspeedTimer)
|
|
|
+ this.windspeedStatus = 'init'
|
|
|
+ this.windCountdownText = 3
|
|
|
},
|
|
|
openWindCountdown() {
|
|
|
windspeedTimer = setInterval(() => {
|
|
|
if (this.windCountdownText > 1) {
|
|
|
- this.windCountdownText = --this.windCountdownText;
|
|
|
+ this.windCountdownText = --this.windCountdownText
|
|
|
}
|
|
|
- }, 1000);
|
|
|
+ }, 1000)
|
|
|
},
|
|
|
setWindMinied() {
|
|
|
- //开启3s后自动调节成功
|
|
|
+ // 开启3s后自动调节成功
|
|
|
changewindspeedTimer = setTimeout(() => {
|
|
|
- windspeedTimer = clearInterval(windspeedTimer);
|
|
|
+ windspeedTimer = clearInterval(windspeedTimer)
|
|
|
this.changeWindspeedHttp().then(() => {
|
|
|
- //开启15s后回复初始状态
|
|
|
+ // 开启15s后回复初始状态
|
|
|
setWeedInitTimer = setTimeout(() => {
|
|
|
- this.windspeedStatus = 'init';
|
|
|
- }, 15000);
|
|
|
- });
|
|
|
- }, 3000);
|
|
|
+ this.windspeedStatus = 'init'
|
|
|
+ }, 15000)
|
|
|
+ })
|
|
|
+ }, 3000)
|
|
|
},
|
|
|
changeWindspeedHttp() {
|
|
|
wx.showLoading({
|
|
|
- title: '加载中...', //提示的内容,
|
|
|
- mask: true //显示透明蒙层,防止触摸穿透
|
|
|
- });
|
|
|
- return changeAirconditionHttp(this.spaceId, 5, this.companyId).then(
|
|
|
+ title: '加载中...', // 提示的内容,
|
|
|
+ mask: true // 显示透明蒙层,防止触摸穿透
|
|
|
+ })
|
|
|
+ return changeAirconditionHttp(this.spaceId, 5, this.companyId).then(
|
|
|
() => {
|
|
|
- this.windspeedStatus = 'minied';
|
|
|
- this.windCountdownText = 3;
|
|
|
- wx.hideLoading();
|
|
|
+ this.windspeedStatus = 'minied'
|
|
|
+ this.windCountdownText = 3
|
|
|
+ wx.hideLoading()
|
|
|
|
|
|
- //toast 提示调小成功
|
|
|
+ // toast 提示调小成功
|
|
|
wx.showToast({
|
|
|
title: '已调小',
|
|
|
duration: 1000,
|
|
|
icon: 'none'
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
() => {
|
|
|
- this.windspeedStatus = 'init';
|
|
|
- this.windCountdownText = 3;
|
|
|
- wx.hideLoading();
|
|
|
+ this.windspeedStatus = 'init'
|
|
|
+ this.windCountdownText = 3
|
|
|
+ wx.hideLoading()
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
},
|
|
|
foldPanel() {
|
|
|
- this.$emit('component-control-panel-fold');
|
|
|
+ this.$emit('component-control-panel-fold')
|
|
|
},
|
|
|
expandPanel() {
|
|
|
- this.$emit('component-control-panel-expand');
|
|
|
+ this.$emit('component-control-panel-expand')
|
|
|
},
|
|
|
showFallPanel() {
|
|
|
- isWithinLocation().then(() => {
|
|
|
- this.temperturePanelType = 'down';
|
|
|
- this.showTemperturePanel = true;
|
|
|
- });
|
|
|
+ // isWithinLocation().then(() => {
|
|
|
+ this.temperturePanelType = 'down'
|
|
|
+ this.showTemperturePanel = true
|
|
|
+ // })
|
|
|
},
|
|
|
showUpPanel() {
|
|
|
- isWithinLocation().then(() => {
|
|
|
- this.temperturePanelType = 'up';
|
|
|
- this.showTemperturePanel = true;
|
|
|
- });
|
|
|
+ // isWithinLocation().then(() => {
|
|
|
+ this.temperturePanelType = 'up'
|
|
|
+ this.showTemperturePanel = true
|
|
|
+ // })
|
|
|
},
|
|
|
hideTemperturePanelFun(newTemperture) {
|
|
|
- this.showTemperturePanel = false;
|
|
|
+ this.showTemperturePanel = false
|
|
|
if (newTemperture.level == 0) {
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
- this.changeAircondBySlide(newTemperture);
|
|
|
+ this.changeAircondBySlide(newTemperture)
|
|
|
},
|
|
|
startAirConditionStatusTimer() {
|
|
|
if (airConditionStatusTimer) {
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
airConditionStatusTimer = setInterval(() => {
|
|
|
- this.getAirConditionStatus();
|
|
|
- }, 1 * 1000); //10描刷接口
|
|
|
+ this.getAirConditionStatus()
|
|
|
+ }, 1 * 1000) // 10描刷接口
|
|
|
},
|
|
|
startLightsStatusTimer() {
|
|
|
if (lightsStatusTimer) {
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
lightsStatusTimer = setInterval(() => {
|
|
|
- this.getLights();
|
|
|
- }, 1 * 1000); //10描刷接口
|
|
|
+ this.getLights()
|
|
|
+ }, 1 * 1000) // 10描刷接口
|
|
|
},
|
|
|
startEnvInfoTimer() {
|
|
|
if (envInfoTimer) {
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
envInfoTimer = setInterval(() => {
|
|
|
- this.getEnvironmentInfo();
|
|
|
- }, 1 * 1000); //10描刷接口
|
|
|
+ this.getEnvironmentInfo()
|
|
|
+ }, 1 * 1000) // 10描刷接口
|
|
|
},
|
|
|
cancelEnvInfoTimer() {
|
|
|
- envInfoTimer = clearInterval(envInfoTimer);
|
|
|
+ envInfoTimer = clearInterval(envInfoTimer)
|
|
|
},
|
|
|
getPanelInfo() {
|
|
|
- this.getLights();
|
|
|
- this.getEnvironmentInfo();
|
|
|
- this.getAirConditionStatus();
|
|
|
+ this.getLights()
|
|
|
+ this.getEnvironmentInfo()
|
|
|
+ this.getAirConditionStatus()
|
|
|
// this.startLightsStatusTimer();
|
|
|
// this.startAirConditionStatusTimer();
|
|
|
// this.startEnvInfoTimer();
|
|
|
},
|
|
|
getLights() {
|
|
|
return getSpaceLightsHttp(this.spaceId, this.companyId).then(res => {
|
|
|
- const result = JSON.parse(res.data);
|
|
|
- const data = (result && result.content) || [];
|
|
|
- this.lights = this.convertLightStatus(data);
|
|
|
- });
|
|
|
+ const result = JSON.parse(res.data)
|
|
|
+ const data = (result && result.content) || []
|
|
|
+ this.lights = this.convertLightStatus(data)
|
|
|
+ })
|
|
|
},
|
|
|
convertLightStatus(data) {
|
|
|
- const lights = [];
|
|
|
+ const lights = []
|
|
|
data.forEach(item => {
|
|
|
lights.push({
|
|
|
id: item.id,
|
|
|
- opened: item.runStatus >= 1 ? true : false,
|
|
|
+ opened: item.runStatus >= 1,
|
|
|
lampType: item.lampType
|
|
|
- });
|
|
|
- });
|
|
|
- return lights;
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return lights
|
|
|
},
|
|
|
getEnvironmentInfo() {
|
|
|
checkLogin()
|
|
|
.then(() => {
|
|
|
- return getEnvironmentInfoHttp(this.spaceId, this.companyId);
|
|
|
+ return getEnvironmentInfoHttp(this.spaceId, this.companyId)
|
|
|
})
|
|
|
.then(res => {
|
|
|
- const result = JSON.parse(res.data);
|
|
|
- const data = (result && result.content && result.content[0]) || {};
|
|
|
+ const result = JSON.parse(res.data)
|
|
|
+ const data = (result && result.content && result.content[0]) || {}
|
|
|
|
|
|
- let { environmentItems } = this;
|
|
|
- let hcho;
|
|
|
+ let { environmentItems } = this
|
|
|
+ let hcho
|
|
|
environmentItems.forEach(item => {
|
|
|
let id = item.id,
|
|
|
- des;
|
|
|
+ des
|
|
|
item.value =
|
|
|
- utils.formateEnvIndicatorValue(id, data[id] || '') || '--';
|
|
|
- des = utils.getEnvIndectorDesc(id, item.value);
|
|
|
- item.des = des || '';
|
|
|
+ utils.formateEnvIndicatorValue(id, data[id] || '') || '--'
|
|
|
+ des = utils.getEnvIndectorDesc(id, item.value)
|
|
|
+ item.des = des || ''
|
|
|
if (id == 'hcho') {
|
|
|
hcho = {
|
|
|
value: item.value,
|
|
|
text: des
|
|
|
- };
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- this.environmentItems = environmentItems;
|
|
|
- this.hcho = hcho;
|
|
|
+ })
|
|
|
+ this.environmentItems = environmentItems
|
|
|
+ this.hcho = hcho
|
|
|
this.temperature =
|
|
|
- data['temperature'] && data['temperature'].toString();
|
|
|
- });
|
|
|
+ data['temperature'] && data['temperature'].toString()
|
|
|
+ })
|
|
|
},
|
|
|
getAirConditionStatus() {
|
|
|
return checkLogin()
|
|
|
.then(() => {
|
|
|
- return getAirConditionStatusHttp(this.spaceId, this.companyId);
|
|
|
+ return getAirConditionStatusHttp(this.spaceId, this.companyId)
|
|
|
})
|
|
|
.then(res => {
|
|
|
- const result = JSON.parse(res.data);
|
|
|
- const data = (result && result.content && result.content[0]) || {};
|
|
|
+ const result = JSON.parse(res.data)
|
|
|
+ const data = (result && result.content && result.content[0]) || {}
|
|
|
let airConditionStatusText = this.getAirConditionStatusText(
|
|
|
data.stateId
|
|
|
- );
|
|
|
+ )
|
|
|
if (data) {
|
|
|
- this.airConditionStatus = data.stateId;
|
|
|
- this.airConditionStatusText = airConditionStatusText;
|
|
|
+ this.airConditionStatus = data.stateId
|
|
|
+ this.airConditionStatusText = airConditionStatusText
|
|
|
this.airConditioningSwitchStatus =
|
|
|
- data.stateId == 0 ? 'closed' : 'open';
|
|
|
+ data.stateId == 0 ? 'closed' : 'open'
|
|
|
this.temperature =
|
|
|
- data['temperature'] && data['temperature'].toString();
|
|
|
+ data['temperature'] && data['temperature'].toString()
|
|
|
}
|
|
|
- return this.airConditioningSwitchStatus || 'open';
|
|
|
- });
|
|
|
+ return this.airConditioningSwitchStatus || 'open'
|
|
|
+ })
|
|
|
},
|
|
|
judgeNeedOpenAircond() {
|
|
|
// 开启空调并发送
|
|
|
if (this.airConditioningSwitchStatus === 'closed') {
|
|
|
return changeAirconditionHttp(this.spaceId, 12, this.companyId).then(() => {
|
|
|
- this.airConditioningSwitchStatus = 'open';
|
|
|
- });
|
|
|
+ this.airConditioningSwitchStatus = 'open'
|
|
|
+ })
|
|
|
} else {
|
|
|
- return Promise.resolve();
|
|
|
+ return Promise.resolve()
|
|
|
}
|
|
|
},
|
|
|
changeAircondBySlide(temperature) {
|
|
|
- //先关闭空调轮询,再设置空调状态,当设置完成后再开启
|
|
|
+ // 先关闭空调轮询,再设置空调状态,当设置完成后再开启
|
|
|
wx.showLoading({
|
|
|
- title: '加载中...', //提示的内容,
|
|
|
- mask: true //显示透明蒙层,防止触摸穿透
|
|
|
- });
|
|
|
+ title: '加载中...', // 提示的内容,
|
|
|
+ mask: true // 显示透明蒙层,防止触摸穿透
|
|
|
+ })
|
|
|
|
|
|
- airConditionStatusTimer = clearInterval(airConditionStatusTimer);
|
|
|
+ airConditionStatusTimer = clearInterval(airConditionStatusTimer)
|
|
|
this.judgeNeedOpenAircond().then(
|
|
|
() => {
|
|
|
- //根据手动操作的值,对应去先显示请求
|
|
|
- let airConditionStatus, airConditionStatusText;
|
|
|
- let httpSetStatus;
|
|
|
+ // 根据手动操作的值,对应去先显示请求
|
|
|
+ let airConditionStatus, airConditionStatusText
|
|
|
+ let httpSetStatus
|
|
|
|
|
|
if (temperature.type == 'down') {
|
|
|
- airConditionStatus = temperature.level == 1 ? 2 : 4;
|
|
|
- httpSetStatus = temperature.level == 1 ? 3 : 4;
|
|
|
+ airConditionStatus = temperature.level == 1 ? 2 : 4
|
|
|
+ httpSetStatus = temperature.level == 1 ? 3 : 4
|
|
|
} else if (temperature.type == 'up') {
|
|
|
- airConditionStatus = temperature.level == 1 ? 3 : 5;
|
|
|
- httpSetStatus = temperature.level == 1 ? 1 : 2;
|
|
|
+ airConditionStatus = temperature.level == 1 ? 3 : 5
|
|
|
+ httpSetStatus = temperature.level == 1 ? 1 : 2
|
|
|
}
|
|
|
|
|
|
changeAirconditionHttp(this.spaceId, httpSetStatus, this.companyId)
|
|
|
.then(
|
|
|
() => {
|
|
|
- return this.getAirConditionStatus();
|
|
|
+ return this.getAirConditionStatus()
|
|
|
},
|
|
|
() => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
}
|
|
|
)
|
|
|
.then(
|
|
|
res => {
|
|
|
- wx.hideLoading();
|
|
|
- this.startAirConditionStatusTimer();
|
|
|
+ wx.hideLoading()
|
|
|
+ this.startAirConditionStatusTimer()
|
|
|
},
|
|
|
() => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
},
|
|
|
() => {
|
|
|
- wx.hideLoading();
|
|
|
+ wx.hideLoading()
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
},
|
|
|
reset() {
|
|
|
// 重制正在开启空调,或者调下风速节面倒计时
|
|
|
- this.cancelWindSpeedMinimzing();
|
|
|
- this.clearAirconditionCutdownTimer();
|
|
|
- this.cancelEnvInfoTimer();
|
|
|
+ this.cancelWindSpeedMinimzing()
|
|
|
+ this.clearAirconditionCutdownTimer()
|
|
|
+ this.cancelEnvInfoTimer()
|
|
|
// 定时刷新任务空调信息
|
|
|
- airConditionStatusTimer = clearInterval(airConditionStatusTimer);
|
|
|
+ airConditionStatusTimer = clearInterval(airConditionStatusTimer)
|
|
|
// 定时刷灯状态
|
|
|
- lightsStatusTimer = clearInterval(lightsStatusTimer);
|
|
|
+ lightsStatusTimer = clearInterval(lightsStatusTimer)
|
|
|
this.environmentItems = this.environmentItems.map(item => {
|
|
|
- return { ...item, value: '' };
|
|
|
- });
|
|
|
+ return { ...item, value: '' }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
getAirConditionStatusText(status) {
|
|
|
- status = Number(status);
|
|
|
+ status = Number(status)
|
|
|
|
|
|
- let msg = '';
|
|
|
+ let msg = ''
|
|
|
switch (status) {
|
|
|
case 0:
|
|
|
- msg = '空调未开启';
|
|
|
- break;
|
|
|
+ msg = '空调未开启'
|
|
|
+ break
|
|
|
case 1:
|
|
|
- msg = '恒温保持中';
|
|
|
- break;
|
|
|
+ msg = '恒温保持中'
|
|
|
+ break
|
|
|
|
|
|
case 2:
|
|
|
- msg = '正在降温..';
|
|
|
- break;
|
|
|
+ msg = '正在降温..'
|
|
|
+ break
|
|
|
|
|
|
case 4:
|
|
|
- msg = '正在快速降温..';
|
|
|
- break;
|
|
|
+ msg = '正在快速降温..'
|
|
|
+ break
|
|
|
case 3:
|
|
|
- msg = '正在逐步升温..';
|
|
|
- break;
|
|
|
+ msg = '正在逐步升温..'
|
|
|
+ break
|
|
|
case 5:
|
|
|
- msg = '正在快速升温..';
|
|
|
- break;
|
|
|
+ msg = '正在快速升温..'
|
|
|
+ break
|
|
|
}
|
|
|
- return msg;
|
|
|
+ return msg
|
|
|
},
|
|
|
clickUncontrolLight() {
|
|
|
wx.showToast({
|
|
|
title: '请使用墙上开关',
|
|
|
duration: 2000,
|
|
|
icon: 'none'
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
-});
|
|
|
+})
|
|
|
</script>
|
|
|
<config>
|
|
|
{
|