index.vue
4.63 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<template>
<view class="index-page">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view>
<!-- 基础统计 -->
<view class="basic-sty">
<view class="basic-text"><text class="text text-bold">基础统计</text></view>
<view class="basic">
<view class="basic-item" v-for="(item,index) in basicStatistics" :key="index">
<view class="item-child-top u-flex">
<image class="item-image" :src="item.icon"></image>
<text class="item-text home-text-muted">{{item.text}}</text>
</view>
<view class="item-child-bottom u-flex">
<view @click="navigatorPage(item,item.leftParam)" class="u-flex sigle-child">
<view class="sigle-text">
<text class="home-text-total">{{item.value.leftValue}}</text>
</view>
<view class="sigle-value"><text
class="home-text-total-bottom">{{item.label.leftText}}</text></view>
</view>
<view @click="navigatorPage(item,item.centerParam)" class="u-flex sigle-child">
<view class="sigle-text">
<text class="home-text-total">{{item.value.centerValue}}</text>
</view>
<view class="sigle-value"><text
class="home-text-total-bottom">{{item.label.centerText}}</text></view>
</view>
<view @click="navigatorPage(item,item.rightParam)" class="u-flex sigle-child">
<view class="sigle-text">
<text class="home-text-total">{{item.value.rightrValue}}</text>
</view>
<view class="sigle-value"><text
class="home-text-total-bottom">{{item.label.rightText}}</text></view>
</view>
</view>
</view>
</view>
</view>
<!-- 网格信息 -->
<view class="grid-container">
<view v-for="(item,index) in basicGridList" :key="index" @click="handleEvent(item.event)"
class="grid-item">
<view class="item-center">
<view class="center">
<image class="image" :src="item.icon"></image>
</view>
<view class="center-text"><text class="text text-muted" style="">{{item.text}}</text></view>
</view>
</view>
</view>
</view>
<f-tabbar></f-tabbar>
</view>
</template>
<script>
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import {
mapActions
} from 'vuex';
import api from '@/api/index.js'
import {
useNavigateTo
} from '@/plugins/utils.js'
import {
basicGridList,
basicStatistics
} from './config/data.js'
export default {
components: {
fTabbar
},
data() {
return {
basicGridList,
basicStatistics,
};
},
onLoad() {
// 隐藏原生的tabbar
uni.hideTabBar();
if (getApp().getBindNot()) {
return
}
this.getDeviceTotalData();
uni.setStorageSync('getConfiguration', {
isConfiguration: false
});
uni.removeStorageSync('getConfiguration');
},
onPullDownRefresh() {
this.getDeviceTotalData();
setTimeout(function() {
uni.stopPullDownRefresh();
uni.$u.toast('下拉刷新成功...');
}, 800);
},
methods: {
...mapActions(['updateBadgeTotal']),
async getDeviceTotalData() {
const res = await api.homeApi.getHomeStatisticsApi()
if (res) {
this.basicStatistics[0].value.leftValue = res.totalDevice.onLine
this.basicStatistics[0].value.centerValue = res.totalDevice.offLine
this.basicStatistics[0].value.rightrValue = res.totalDevice.inActive
this.basicStatistics[1].value.leftValue = res.totalAlarm.activedAlarm
this.basicStatistics[1].value.centerValue = res.totalAlarm.clearedAck
this.basicStatistics[1].value.rightrValue = res.totalAlarm.clearedUnack
//异步实时更新告警徽标数
this.updateBadgeTotal(res.totalAlarm?.activedAlarm);
}
},
openCamera() {
useNavigateTo('camera/camera')
},
openConfiguration() {
useNavigateTo('configuration/configuration')
},
handleEvent(event) {
if (event === 'openCamera') {
this.openCamera()
} else {
this.openConfiguration()
}
},
navigatorPage(item, type) {
const {
text
} = item
if (text === '设备统计') {
this.navigatorDeviceStatus(type)
} else {
this.navigatorAlarmStatus(type)
}
},
//告警状态查询
navigatorAlarmStatus(e) {
uni.reLaunch({
url: '../alarm/alarm?type=' + JSON.stringify(e)
});
},
//设备状态查询
navigatorDeviceStatus(e) {
uni.reLaunch({
url: '../device/device?deviceState=' + JSON.stringify(e)
});
}
}
};
</script>
<style lang="scss" scoped>
@import './static/index.scss';
</style>