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

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

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		token 		: uni.getStorageSync('token') || '',
		invite		: uni.getStorageSync('invite') || '',
		shareUser	: uni.getStorageSync('shareUser') || '',
		lockId		: uni.getStorageSync('lockId') || '',
		passinfo	: uni.getStorageSync('passinfo') || ''
	},
	getters: {
		getToken: state => {
			return state.token
		},
		getInvite: state => {
			return state.invite
		},
		getShareUser: state => {
			return state.shareUser
		},
		getLockId: state => {
			return state.lockId
		},
		getPassInfo: state => {
			return state.passinfo
		}
	},
	mutations: {
		setToken(state, tokenString) {
			state.token = tokenString
			uni.setStorageSync('token', tokenString)
		},
		setInvite(state, inviteString) {
			state.invite = inviteString
			uni.setStorageSync('invite', inviteString)
		},
		setShareUser(state, shareString) {
			state.shareUser = shareString
			uni.setStorageSync('shareUser', shareString)
		},
		setLockId(state, lockIdString) {
			state.lockId = lockIdString
			uni.setStorageSync('lockId', lockIdString)
		},
		setPassInfo(state, passString) {
			state.passinfo = passString
			uni.setStorageSync('passinfo', JSON.stringify(passString))
		}
	}
})
