/**
 * Web唐明明
 * 匆匆数载恍如梦，岁月迢迢华发增。
 * 碌碌无为枉半生，一朝惊醒万事空。
 */

import Vue from 'vue'
import Vuex from 'vuex'
import im from './modules/im.js'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        token: uni.getStorageSync('token') || '',
        address: {},
        refresh: 0
    },
    getters: {
        getToken: state => {
            return state.token
        },
        getAddress: state => {
            return state.address
        },
        getRefresh: state => {
            return state.refresh
        }
    },
    mutations: {
        setToken(state, tokenString) {
            state.token = tokenString
            uni.setStorageSync('token', tokenString)
        },
        setAddress(state, value) {
            state.address = value
        },
        setRefresh(state, value) {
            state.refresh = value
        }
    },
    modules: {
        im
    }
})
