const auth = {
	state: {
		hasLogin:false,
		userToken:{},
		userInfo:{}
	},
	mutations: {
		doLogin(state, data) {
			state.hasLogin = true;
			state.userToken = data;
			uni.setStorage({
				key: 'userToken',
				data: data
			})
		},
		logout(state) {
			state.hasLogin = false;
			state.userInfo = {};
			state.userToken = {};
			// uni.clearStorageSync();
			const resStorage = uni.getStorageInfoSync();
			console.log("获取到缓存信息",resStorage)
			resStorage.keys.forEach((item)=>{
				if(item!="username" && item!="password" && item!="phonenumber"){
					uni.removeStorageSync(item);
				}
			})
		},
	},
	actions:{
		setLogin({ commit }, token){
			commit('doLogin', token);
		},
	}
}

export default auth;