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

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

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		token		: uni.getStorageSync('token') || '',
		refresh		: 0,
		available	: "",
		orderId		: null,
	},
	getters: {
		getToken: state => {
			return state.token
		},
		getRefresh: state => {
			return state.refresh
		},
		getUser: state => {
			return state.available
		},
		getOrderId: state => {
			return state.orderId
		}
	},
	mutations: {
		setToken(state, tokenString) {
			state.token = tokenString
			uni.setStorageSync('token', tokenString)
		},
		setRefresh(state, value) {
			state.refresh = value
		},
		setUser(state, value) {
			state.available = value
		},
		setOrderId(state, value) {
			state.orderId = value
		}
	}
})
