From 626cabe8772d16c02584c8b324dd7c45e23002a6 Mon Sep 17 00:00:00 2001 From: zhangxiaoxu123456 <zxx19900626> Date: 星期四, 14 四月 2022 17:36:12 +0800 Subject: [PATCH] 登录接口 --- src/store/modules/user.js | 51 ++++++++++++++++++++------------------------------- 1 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 9ec679d..6d53c1a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,42 +1,31 @@ /** * 鐢ㄦ埛鐧诲綍缁勪欢 */ - - +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 + } + }, + 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; -- Gitblit v1.9.1