| | |
| | | /** |
| | | * 用户登录组件 |
| | | */ |
| | | |
| | | |
| | | 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; |