Browse Source

接口更新

guhongwei 3 years ago
parent
commit
76085e54af
4 changed files with 39 additions and 9 deletions
  1. 1 1
      src/components/admin-frame/Header.vue
  2. 2 2
      src/layout/deploy/menu.js
  3. 30 0
      src/store/login.js
  4. 6 6
      src/store/test.js

+ 1 - 1
src/components/admin-frame/Header.vue

@@ -12,7 +12,7 @@
           </el-col>
           <el-col :span="12" class="right">
             <i class="el-icon-user-solid"></i>
-            <span>{{ user&&user.name || '游客' }}</span>
+            <span>{{ (user && user.name) || '游客' }}</span>
             <el-button type="danger" size="mini" @click="logout">退出登录</el-button>
           </el-col>
         </el-col>

+ 2 - 2
src/layout/deploy/menu.js

@@ -2,7 +2,7 @@ export const system = [{ icon: 'icon-shouye', index: '/adminCenter/homeIndex', t
 export const userMenu = [
   {
     icon: 'icon-ceshi',
-    index: '/adminCenter/test/index',
-    title: '测试',
+    index: '/adminCenter/user/index',
+    title: '用户管理',
   },
 ];

+ 30 - 0
src/store/login.js

@@ -0,0 +1,30 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+const jwt = require('jsonwebtoken');
+Vue.use(Vuex);
+const api = {
+  info: `/api/hc/user`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async login({ commit }, { user }) {
+    const res = await this.$axios.$post(`${api.info}/login`, user);
+    if (res.errcode === 0) {
+      console.log(res);
+      localStorage.setItem('user', JSON.stringify(res.data));
+      // // user = jwt.decode(res.data);
+      commit('setUser', user, { root: true });
+      res.user = user;
+    }
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 6 - 6
src/store/test.js

@@ -3,14 +3,14 @@ import Vuex from 'vuex';
 import _ from 'lodash';
 Vue.use(Vuex);
 const api = {
-  test: `/api/serviceStudy/test`,
+  info: `/api/hc/user`,
 };
 const state = () => ({});
 const mutations = {};
 
 const actions = {
   async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.test}`, {
+    const res = await this.$axios.$get(`${api.info}`, {
       skip,
       limit,
       ...info,
@@ -18,20 +18,20 @@ const actions = {
     return res;
   },
   async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.test}`, payload);
+    const res = await this.$axios.$post(`${api.info}`, payload);
     return res;
   },
   async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.test}/${payload}`);
+    const res = await this.$axios.$get(`${api.info}/${payload}`);
     return res;
   },
   async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.test}/update/${id}`, data);
+    const res = await this.$axios.$post(`${api.info}/update/${id}`, data);
     return res;
   },
 
   async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.test}/${payload}`);
+    const res = await this.$axios.$delete(`${api.info}/${payload}`);
     return res;
   },
 };