Commit f3aa509c77a761aedbb50be69a5508d489477415

Authored by fengwotao
1 parent 9534a3ef

feat: mp android app两端,新增首页下拉刷新,优化首页部分代码

... ... @@ -16,7 +16,7 @@
16 16 "path": "pages/index/index",
17 17 "style": {
18 18 "navigationBarTitleText": "首页",
19   - "disableScroll": true
  19 + "enablePullDownRefresh": true
20 20 }
21 21 },
22 22 {
... ...
... ... @@ -21,13 +21,13 @@
21 21 </view>
22 22 <view @click="navigatorDeviceStatus('OFFLINE')" class="u-flex sigle-child">
23 23 <view class="sigle-text">
24   - <text class="home-text-total">{{ deviceData.unLine }}</text>
  24 + <text class="home-text-total">{{ deviceData.offLine }}</text>
25 25 </view>
26 26 <view class="sigle-value"><text class="home-text-total-bottom">离线</text></view>
27 27 </view>
28 28 <view @click="navigatorDeviceStatus('INACTIVE')" class="u-flex sigle-child">
29 29 <view class="sigle-text">
30   - <text class="home-text-total">{{ deviceData.noActive }}</text>
  30 + <text class="home-text-total">{{ deviceData.inActive }}</text>
31 31 </view>
32 32 <view class="sigle-value"><text class="home-text-total-bottom">待激活</text></view>
33 33 </view>
... ... @@ -42,19 +42,19 @@
42 42 <view @click="navigatorAlarmStatus(['ACTIVE_UNACK', 'ACTIVE_ACK'])"
43 43 class="u-flex sigle-child">
44 44 <view class="sigle-text">
45   - <text class="home-text-total">{{ alertData.noHandle }}</text>
  45 + <text class="home-text-total">{{ alertData.activedAlarm }}</text>
46 46 </view>
47 47 <view class="sigle-value"><text class="home-text-total-bottom">未处理</text></view>
48 48 </view>
49 49 <view @click="navigatorAlarmStatus('CLEARED_ACK')" class="u-flex sigle-child">
50 50 <view class="sigle-text">
51   - <text class="home-text-total">{{ alertData.doneHandle }}</text>
  51 + <text class="home-text-total">{{ alertData.clearedAck }}</text>
52 52 </view>
53 53 <view class="sigle-value"><text class="home-text-total-bottom">已处理</text></view>
54 54 </view>
55 55 <view @click="navigatorAlarmStatus('CLEARED_UNACK')" class="u-flex sigle-child">
56 56 <view class="sigle-text">
57   - <text class="home-text-total">{{ alertData.errorReport }}</text>
  57 + <text class="home-text-total">{{ alertData.clearedUnack }}</text>
58 58 </view>
59 59 <view class="sigle-value"><text class="home-text-total-bottom">误报</text></view>
60 60 </view>
... ... @@ -105,7 +105,8 @@
105 105 import {
106 106 mapActions
107 107 } from 'vuex';
108   - import api from '@/api/index.js'
  108 + import api from '@/api/index.js'
  109 + import { useNavigateTo } from '@/plugins/utils.js'
109 110
110 111 export default {
111 112 components: {
... ... @@ -115,13 +116,13 @@
115 116 return {
116 117 deviceData: {
117 118 onLine: 0,
118   - unLine: 0,
119   - noActive: 0
  119 + offLine: 0,
  120 + inActive: 0
120 121 },
121 122 alertData: {
122   - noHandle: 0,
123   - doneHandle: 0,
124   - errorReport: 0
  123 + activedAlarm: 0,
  124 + clearedAck: 0,
  125 + clearedUnack: 0
125 126 }
126 127 };
127 128 },
... ... @@ -133,18 +134,21 @@
133 134 isConfiguration: false
134 135 });
135 136 uni.removeStorageSync('getConfiguration');
  137 + },
  138 + onPullDownRefresh() {
  139 + this.getDeviceTotalData();
  140 + setTimeout(function () {
  141 + uni.stopPullDownRefresh();
  142 + uni.$u.toast('下拉刷新成功...');
  143 + }, 1000);
136 144 },
137 145 methods: {
138 146 ...mapActions(['updateBadgeTotal']),
139 147 async getDeviceTotalData() {
140 148 const res = await api.homeApi.getHomeStatisticsApi()
141   - if (res) {
142   - this.deviceData.onLine = res.totalDevice?.onLine;
143   - this.deviceData.unLine = res.totalDevice?.offLine;
144   - this.deviceData.noActive = res.totalDevice?.inActive;
145   - this.alertData.noHandle = res.totalAlarm?.activedAlarm;
146   - this.alertData.doneHandle = res.totalAlarm?.clearedAck;
147   - this.alertData.errorReport = res.totalAlarm?.clearedUnack;
  149 + if (res) {
  150 + for(let i in this.deviceData) Reflect.set(this.deviceData,i,res.totalDevice[i])
  151 + for(let i in this.alertData) Reflect.set(this.alertData,i,res.totalAlarm[i])
148 152 //异步实时更新告警徽标数
149 153 this.updateBadgeTotal(res.totalAlarm?.activedAlarm);
150 154 }
... ... @@ -152,15 +156,11 @@
152 156 showToastWip() {
153 157 uni.$u.toast('拼命开发中 ...');
154 158 },
155   - openCamera() {
156   - uni.navigateTo({
157   - url: 'camera/camera'
158   - });
  159 + openCamera() {
  160 + useNavigateTo('camera/camera')
159 161 },
160   - openOrgStatus() {
161   - uni.navigateTo({
162   - url: 'configuration/configuration'
163   - });
  162 + openOrgStatus() {
  163 + useNavigateTo('configuration/configuration')
164 164 },
165 165 //告警状态查询
166 166 navigatorAlarmStatus(e) {
... ...
... ... @@ -147,7 +147,13 @@ export function formatToDate(date = undefined, format = DATE_TIME_FORMAT) {
147 147 //封装uniapp跳转 navigateTo
148 148 export const useNavigateTo=(path,param)=>{
149 149 if (!path) return
150   - uni.navigateTo({
151   - url: path + encodeURIComponent(JSON.stringify(param))
152   - });
  150 + if(param){
  151 + uni.navigateTo({
  152 + url: path + encodeURIComponent(JSON.stringify(param))
  153 + });
  154 + }else{
  155 + uni.navigateTo({
  156 + url:path
  157 + });
  158 + }
153 159 }
\ No newline at end of file
... ...