|
@@ -1,6 +1,7 @@
|
|
import Vue from 'vue';
|
|
import Vue from 'vue';
|
|
import Vuex from 'vuex';
|
|
import Vuex from 'vuex';
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
|
+const jwt = require('jsonwebtoken');
|
|
Vue.use(Vuex);
|
|
Vue.use(Vuex);
|
|
const api = {
|
|
const api = {
|
|
interface: `/api/achieve/v0/achieveExpert`,
|
|
interface: `/api/achieve/v0/achieveExpert`,
|
|
@@ -29,6 +30,15 @@ const actions = {
|
|
const res = await this.$axios.$delete(`${api.interface}/${payload}`);
|
|
const res = await this.$axios.$delete(`${api.interface}/${payload}`);
|
|
return res;
|
|
return res;
|
|
},
|
|
},
|
|
|
|
+ async login({ commit }, payload) {
|
|
|
|
+ const res = await this.$axios.$post(`${api.interface}/login`, payload);
|
|
|
|
+ if (res.errcode === 0) {
|
|
|
|
+ localStorage.setItem('token', res.data);
|
|
|
|
+ let user = jwt.decode(res.data);
|
|
|
|
+ commit('setUser', user, { root: true });
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ },
|
|
};
|
|
};
|
|
export default {
|
|
export default {
|
|
namespaced: true,
|
|
namespaced: true,
|