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
| import Vue from 'vue'
| import Vuex from 'vuex'
| import config from '@/common/config/index.js'
| import apis from '@/common/api/index.js'
| let $state
| let messageTimer
|
| Vue.use(Vuex)
|
|
| const store = new Vuex.Store({
| state: {
| userInfo: {}, //用户信息
| isLogin: false,
| systemInfo: {}, //系统信息
| position:{
| latitude: 33.011699,// 纬度
| longitude: 114.022000 // 经度
| },
| },
| getters: {
| userInfo(state){
| return state.userInfo
| },
| isLogin(state){
| return state.isLogin
| },
| position(state){
| return state.position
| },
| },
| mutations: {
| setUserInfo(state, option) {
| $state = state
| state.userInfo = option
| state.isLogin = true
| uni.setStorageSync('userInfo', option)
| },
| setSystemInfo(state, option) {
| state.systemInfo = option
| },
| setPosition(state,option){
| state.position = option
| uni.setStorageSync('position',option)
| },
| loginOut(state){
| uni.removeStorageSync('userInfo')
| uni.removeStorageSync('token')
| state.userInfo = {}
| state.isLogin = false
| uni.reLaunch({
| url:'/pages/login/index'
| })
| },
| }
| })
|
| export default store
|
| function getMessageNum(){
| apis.user.getUserInfo().then(res=>{
| if(res.data.msgNum>0){
| $state.unReadMessage = true
| }else{
| $state.unReadMessage = false
| }
| })
| }
|
|