user.js
1.25 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
export const state = {
//用户数据
userInfo: {},
//存储告警徽标数据
badgeInfo: 0
};
export const mutations = {
//储存用户信息
setUserInfo(state, data) {
if (data) {
state.userInfo = Object.assign({}, state.userInfo, data);
// #ifdef H5
window.sessionStorage.setItem('userInfo', JSON.stringify(state.userInfo));
// #endif
// #ifndef H5
uni.setStorageSync('userInfo', state.userInfo);
// #endif
}
},
// 退出APP
emptyUserInfo(state) {
state.userInfo = {};
// #ifdef H5
window.sessionStorage.removeItem("userInfo");
// #endif
// #ifndef H5
uni.removeStorageSync("userInfo");
// #endif
},
};
export const actions = {
//更新告警徽标数
updateBadgeTotal({
state,
commit
}, data) {
let httpData = {
page: 1,
pageSize: 10,
status: data.status == 'CLEARED_ACK' ? null : data.status,
startTime: data.startTime,
endTime: data.endTime,
severity: data.severity,
deviceType: data.deviceType,
organizationId: data.organizationId,
alarmType: data.alarmType
};
uni.$u.http
.get('/yt/alarm', {
params: httpData,
custom: {
load: false
}
})
.then(res => {
state.badgeInfo = res.total
})
.catch(e => {
uni.$u.toast(e.data?.message);
});
}
};