
/**
 * 手太欠
 * 愿这世界都如故事里一样 美好而动人~
 */

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		token 		: uni.getStorageSync('token') || '',
		openID		: uni.getStorageSync('openId') || ''
	},
	getters: {
		getToken: state => {
			return state.token
		},
		getOpenId: state => {
			return state.openID
		}
	},
	mutations: {
		setToken(state, tokenString) {
			state.token = tokenString
			uni.setStorageSync('token', tokenString)
		},
		setOpenid(state, openid) {
			state.openID = openid
			uni.setStorageSync('openId', openid)
		}
	}
})
