common.js
947 Bytes
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
import { NativeApi } from '@/api/NativeApis'
const AppInfo = {
versionCode: 100,
versionName: '2.1',
statusBarHeight: 0,
sourceFlag: false
}
export default {
namespaced: true,
state: {
AppInfo: { ...AppInfo }
},
mutations: {
MSetAppInfo (state, data) {
Object.assign(state.AppInfo, data)
}
},
actions: {
AGetAppInfo ({ state, commit }) {
if (state.AppInfo.sourceFlag) {
return
}
NativeApi.nativeAppInfo({}).then(res => {
if (res.data) {
Object.assign(res.data, { sourceFlag: true })
}
commit('MSetAppInfo', res.data)
}).catch(e => {
commit('MSetAppInfo', AppInfo)
})
}
},
getters: {
GStatusBarHeight (state) {
return state.AppInfo.statusBarHeight
}
}
}