import Vue from "vue" import Vuex from "vuex" Vue.use(Vuex) const store = new Vuex.Store({ state:{ isLogin: false, userInfo: null, token:"", }, mutations:{ login(state, provider) { console.log("登陆成功 缓存数据...",provider) state.isLogin = true; state.userInfo = provider; uni.setStorage({ key: "userInfo", data: provider, success: (res) => { console.log("存储成功 key---->userInfo",provider) }, fail: (res) => {1 console.log("存储失败 key ---- userInfo", res) } }) uni.setStorage({ key: "token", data: provider.accessToken, success: (res) => { console.log("存储成功 key---->token",provider.accessToken) } }) console.log("看看存到本地去没有",uni.getStorageSync('userInfo')) }, loginOut(state) { console.log("退出登录成功,清除缓存...") state.isLogin = false; state.userInfo = {}; uni.removeStorage({ key: "userInfo" }) uni.removeStorage({ key: "token" }) uni.redirectTo({ url:"../login/login", success: (res) => { } }) } } }) export default store