guhongwei 3 anos atrás
pai
commit
a2bf5f44e1

+ 5 - 4
src/components/admin-frame/Header.vue

@@ -12,8 +12,7 @@
           </el-col>
           <el-col :span="12" class="right">
             <i class="el-icon-user-solid"></i>
-            <!-- <span>{{ user.name || '游客' }}</span> -->
-            <span>游客</span>
+            <span>{{ user.name || '游客' }}</span>
             <el-button type="danger" size="mini" @click="logout">退出登录</el-button>
           </el-col>
         </el-col>
@@ -33,7 +32,9 @@ export default {
   data: function() {
     return { collapse: false, siteInfo: siteInfo };
   },
-  created() {},
+  created() {
+    console.log(this.user);
+  },
   methods: {
     // 侧边栏折叠
     collapseChage() {
@@ -42,7 +43,7 @@ export default {
     },
     // 退出登录
     logout() {
-      localStorage.removeItem('token');
+      localStorage.removeItem('user');
       this.$router.push('/login');
     },
   },

+ 7 - 1
src/layout/deploy/menu.js

@@ -1,2 +1,8 @@
 export const system = [{ icon: 'icon-shouye', index: '/adminCenter/homeIndex', title: '系统首页' }];
-export const userMenu = [{ icon: 'icon-ceshi', index: '/adminCenter/test/index', title: '测试页面' }];
+export const userMenu = [
+  {
+    icon: 'icon-ceshi',
+    index: '/adminCenter/examine/index',
+    title: '审批单',
+  },
+];

+ 43 - 0
src/store/examine.js

@@ -0,0 +1,43 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  info: `/api/hc/examine`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.info}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.info}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.info}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { 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.info}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 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,
+};

+ 1 - 2
src/store/user/mutations.js

@@ -29,6 +29,5 @@ export const setUser = (state, payload) => {
 
 export const deleteUser = (state, payload) => {
   state.user = {};
-  localStorage.removeItem('token');
-  localStorage.removeItem('type');
+  localStorage.removeItem('user');
 };