|
@@ -1,6 +1,9 @@
|
|
import Vue from 'vue';
|
|
import Vue from 'vue';
|
|
import Vuex from 'vuex';
|
|
import Vuex from 'vuex';
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
|
+import { Notification } from 'element-ui';
|
|
|
|
+const jwt = require('jsonwebtoken');
|
|
|
|
+Vue.use(Vuex);
|
|
Vue.use(Vuex);
|
|
Vue.use(Vuex);
|
|
const api = {
|
|
const api = {
|
|
channelInfo: `/api/live/channel`,
|
|
channelInfo: `/api/live/channel`,
|
|
@@ -36,32 +39,22 @@ const actions = {
|
|
},
|
|
},
|
|
async login({ commit, dispatch }, { user, router, path = '/', needReturn = false, typeCheck = false, isWx = false, needNotice = true }) {
|
|
async login({ commit, dispatch }, { user, router, path = '/', needReturn = false, typeCheck = false, isWx = false, needNotice = true }) {
|
|
let res = await this.$axios.$post(`${api.logininfo}`, user);
|
|
let res = await this.$axios.$post(`${api.logininfo}`, user);
|
|
- // const setUser = async (token, commit) => {
|
|
|
|
- // localStorage.setItem('token', token);
|
|
|
|
- // let userInfo = await dispatch('toGetUser');
|
|
|
|
- // return userInfo;
|
|
|
|
- // };
|
|
|
|
- // let userInfo = {};
|
|
|
|
- // if (res.errcode == '0') {
|
|
|
|
- // userInfo = await setUser(res.data.key, commit);
|
|
|
|
- // Notification({
|
|
|
|
- // title: '登录成功',
|
|
|
|
- // // message: `欢迎,${user.user_name}`,
|
|
|
|
- // type: 'success',
|
|
|
|
- // duration: 2000,
|
|
|
|
- // offset: 50,
|
|
|
|
- // });
|
|
|
|
- // return userInfo;
|
|
|
|
- // } else {
|
|
|
|
- // if (needReturn) return res;
|
|
|
|
- // else {
|
|
|
|
- // Notification({
|
|
|
|
- // title: '登录失败',
|
|
|
|
- // message: `失败原因:${res.errmsg || '登陆失败'}`,
|
|
|
|
- // type: 'error',
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ commit('setUser', res.data, { root: true });
|
|
|
|
+ Notification({
|
|
|
|
+ title: '登录成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ duration: 2000,
|
|
|
|
+ offset: 50,
|
|
|
|
+ });
|
|
|
|
+ return res;
|
|
|
|
+ } else {
|
|
|
|
+ Notification({
|
|
|
|
+ title: '登录失败',
|
|
|
|
+ message: `失败原因:${res.errmsg || '登陆失败'}`,
|
|
|
|
+ type: 'error',
|
|
|
|
+ });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
};
|
|
};
|
|
export default {
|
|
export default {
|