theme.js 663 字节
Newer Older
芊里 已提交
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
// 上次启动时的用户信息
let userHistory = uni.getStorageSync('userInfo') || null;

let state = {
		/**
		 * 是否需要强制登录
		 */
		forcedLogin: false,
		hasLogin: Boolean(userHistory),
		info: userHistory
	},
	getters = {
		info(state) {
			return state.info;
		},
		hasLogin(state){
			return state.hasLogin;
		}
	},
	mutations = {
		login(state, info) {
			state.info = info;
			state.hasLogin = true;
			uni.setStorageSync('userInfo', info);
		},
		logout(state) {
			state.info = null;
			state.hasLogin = false;
			uni.setStorageSync('userInfo', null);
		}
	},
	actions = {

	}


export default {
	state,
	getters,
	mutations,
	actions
}