|
|
@@ -2,7 +2,7 @@
|
|
|
<view class="content">
|
|
|
<view class="header" style="margin:0;padding: 0px;">
|
|
|
|
|
|
- <view class="bg" style="position: fixed;top:0px;bottom:0px;left:0px;right:0px;background-image: url('/static/images/device/bg.png');background-size: 100% 100%;padding:0 40rpx">
|
|
|
+ <view class="bg" style="position: fixed;top:0px;bottom:0px;left:0px;right:0px;background-image: url('https://hyscancode.oss-cn-hangzhou.aliyuncs.com/jianyaoji/images/device/bg.png');background-size: 100% 100%;padding:0 40rpx">
|
|
|
<view style="position: absolute;right:10rpx;top:30rpx;z-index: 9999">
|
|
|
<u-button @click="reportError" color="#EC6D2F" text="上报异常" type="error" size="mini"></u-button>
|
|
|
</view>
|
|
|
@@ -408,17 +408,20 @@ export default {
|
|
|
location:{},
|
|
|
sysDept:null,
|
|
|
timeobj:{alltime:0,avgtime:0},
|
|
|
+ publishMsg:false,
|
|
|
+ checkTimer:null,
|
|
|
}
|
|
|
},
|
|
|
onLoad: function(opt) {
|
|
|
this.id = opt.id;
|
|
|
- this.id = 61;
|
|
|
+ // this.id = 61;
|
|
|
this.connectMqtt();
|
|
|
this.getDetail();
|
|
|
},
|
|
|
destroyed() {
|
|
|
// 取消订阅主题
|
|
|
this.mqttUnSubscribe(this.deviceInfo);
|
|
|
+ clearInterval(this.checkTimer);
|
|
|
},
|
|
|
methods:{
|
|
|
checkItemValue(item){
|
|
|
@@ -666,6 +669,7 @@ export default {
|
|
|
await this.$mqttTool.connect(this.vuex_token);
|
|
|
}
|
|
|
this.mqttCallback();
|
|
|
+ this.startCheck();
|
|
|
},
|
|
|
/** Mqtt订阅主题 */
|
|
|
mqttSubscribe(device) {
|
|
|
@@ -895,6 +899,7 @@ export default {
|
|
|
}
|
|
|
if (topic != "") {
|
|
|
// 发布
|
|
|
+ let self = this;
|
|
|
this.$mqttTool.publish(topic, message, model.name).then(res => {
|
|
|
this.notifySuccess(res);
|
|
|
}).catch(res => {
|
|
|
@@ -902,6 +907,40 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ startCheck(){
|
|
|
+ let self = this;
|
|
|
+ this.checkTimer = setInterval(function (){
|
|
|
+ self.sendHeart();
|
|
|
+ },20000);
|
|
|
+ },
|
|
|
+ checkActive(){
|
|
|
+ let self = this;
|
|
|
+ setTimeout(function (){
|
|
|
+ if(self.publishMsg){
|
|
|
+ self.resetConn()
|
|
|
+ }
|
|
|
+ },3000);
|
|
|
+ },
|
|
|
+ sendHeart(){
|
|
|
+ console.log("发送心跳")
|
|
|
+ let device = this.deviceInfo;
|
|
|
+ let self = this;
|
|
|
+ let topic = "/property-offline/post";
|
|
|
+ self.publishMsg = true;
|
|
|
+ self.checkActive();
|
|
|
+ this.$mqttTool.publish(topic, "ok", "heart").then(res => {
|
|
|
+ self.publishMsg = false;
|
|
|
+ }).catch(res => {
|
|
|
+ self.publishMsg = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ resetConn(){
|
|
|
+ console.log("检测异常,重连")
|
|
|
+ this.$mqttTool.end();
|
|
|
+ this.$mqttTool.client = null;
|
|
|
+ this.connectMqtt();
|
|
|
+ this.getDetail();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|