zhangxiaoxu123456
2022-04-25 82997f69728d163157a80360689874bddf16b26f
src/store/modules/user.js
@@ -1,42 +1,33 @@
/**
 * 用户登录组件
 */
import {login} from '@/api/index'
import {getStore,setStore} from "../../libs/store";
const user = {
    state: {
        menus: [
            {
                icon: "sound",
                index: "/index",
                title: "视频管理",
                subs: [
                    {
                        icon: "area-chart",
                        index: "index",
                        title: "Dashboard",
                    },
                ],
            },
            {
                icon: "setting",
                index: "/wechat",
                title: "系统",
                subs: [
                    {
                        icon: "setting",
                        index: "admin_user",
                        title: "帐号管理",
                    },
                ],
            }
        ]
      token: getStore('token') || ''
    },
    mutations: {
        SET_MENUS: (state, action) => {
            // state.menus = !state.isCollapse
        },
      SET_TOKEN: (state, token) => {
        state.token = token
        console.log(token,'token----set')
        setStore('token',state.token)
      }
    },
    actions: {
      login({commit}, userInfo) {
         return new Promise((resolve, reject) => {
           login(userInfo).then(response => {
             console.log('response----',response)
             commit('SET_TOKEN',response.obj.token)
             resolve()
           }).catch(error => {
             reject(error)
           })
         })
      }
    }
}
export default user;