info.vue
2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
<div>
<topTab ref="tabRefs" @changeTabItem="changeTabItem">
<template #replay>
<replay />
</template>
<template #monitor>
<MonitorPage ref="monitorRefs" />
</template>
<template #resident>
<resident />
</template>
<template #share>
<share>
<van-overlay
:show="showOverlay"
@click="showOverlay = false"
:z-index="100000"
>
<span class="icon icon-share"></span>
<p class="tip">
点击右上角“ <span class="fle"
><span class="sharebtn"></span
><span class="sharebtn middle"></span
><span class="sharebtn"></span></span
> ”转发/分享
</p>
</van-overlay>
</share>
</template>
<template #fence>
<fence />
</template>
<template #freq>
<freq ref="freqRefs" />
</template>
</topTab>
</div>
</template>
<script>
import {
defineComponent,
onMounted,
ref,
getCurrentInstance,
nextTick,
onUnmounted,
} from "vue";
import topTab from "@/components/top-tab.vue";
import replay from "./replay.vue";
import MonitorPage from "./monitor.vue";
import resident from "./resident.vue";
import fence from "./fence.vue";
import share from "./share.vue";
import freq from "./freq.vue";
import wx from "wx";
export default defineComponent({
name: "InfoPage",
components: {
topTab,
replay,
MonitorPage,
resident,
fence,
share,
freq,
},
setup() {
const showOverlay = ref(true);
const tabRefs = ref(null);
const monitorRefs = ref(null);
const instance = getCurrentInstance();
onMounted(() => {
nextTick(() => {
monitorRefs.value = instance.refs.monitorRefs;
});
let carInfo = JSON.parse(localStorage.getItem("carInfo"));
wx.miniProgram.postMessage({
data: {
carInfo: carInfo,
},
});
});
const changeTabItem = (e) => {
// 切换tab 清除定时器
if (e.name !== "monitor") {
instance.refs.monitorRefs &&
instance.refs.monitorRefs.timeoutId &&
clearTimeout(instance.refs.monitorRefs.timeoutId);
if (e.name === "freq") {
// 获取最新的设备调频数据
instance.refs.freqRefs && instance.refs.freqRefs.getInfoData();
}
if (e.name === "share") {
showOverlay.value = true;
}
} else {
instance.refs.monitorRefs && instance.refs.monitorRefs.getData();
}
};
onUnmounted(() => {
monitorRefs.value &&
monitorRefs.value.timeoutId &&
clearTimeout(monitorRefs.value.timeoutId);
});
return {
changeTabItem,
showOverlay,
tabRefs,
};
},
});
</script>
<style lang="scss" scoped>
.info-content {
height: 100%;
}
@import "@/assets/css/share.scss";
</style>