1234567891011121314151617181920212223242526272829303132333435363738 |
- import Vue from 'vue';
- import Vuex from 'vuex';
- import {
- getUserInfo
- } from '../api';
- Vue.use(Vuex);
- const store = new Vuex.Store({
- state: {
- userInfo: uni.getStorageSync('userInfo'),
- userId: uni.getStorageSync('userId'),
- isLogin: uni.getStorageSync('isLogin'),
- },
- mutations: {
- changeIsLogin(state, bol) {
- state.isLogin = bol;
- },
- changeUserInfo(state, value) {
- state.userInfo = value;
- },
- changeUserId(state, value) {
- state.userId = value;
- },
- },
- actions: {
- resetUserInfo({
- commit
- }) {
- return getUserInfo().then((res) => {
- const {user} = res.data;
- commit('changeUserInfo', user);
- return Promise.resolve(user);
- })
- },
- }
- })
- export default store;
|