123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import Vue from 'vue';
- import Vuex from 'vuex';
- import _ from 'lodash';
- import { Notification } from 'element-ui';
- const jwt = require('jsonwebtoken');
- Vue.use(Vuex);
- Vue.use(Vuex);
- const api = {
- channelInfo: `/api/live/channel`,
- logininfo: `/api/live/channel/login`,
- };
- const state = () => ({});
- const mutations = {};
- const actions = {
- async query({ commit }, { skip = 0, limit, ...info } = {}) {
- const res = await this.$axios.$get(`${api.channelInfo}`, {
- skip,
- limit,
- ...info,
- });
- return res;
- },
- async create({ commit }, payload) {
- const res = await this.$axios.$post(`${api.channelInfo}`, payload);
- return res;
- },
- async fetch({ commit }, payload) {
- const res = await this.$axios.$get(`${api.channelInfo}/${payload}`);
- return res;
- },
- async update({ commit }, { id, ...data }) {
- const res = await this.$axios.$post(`${api.channelInfo}/update/${id}`, data);
- return res;
- },
- async delete({ commit }, payload) {
- const res = await this.$axios.$delete(`${api.channelInfo}/${payload}`);
- return res;
- },
- async login({ commit, dispatch }, { user, router, path = '/', needReturn = false, typeCheck = false, isWx = false, needNotice = true }) {
- let res = await this.$axios.$post(`${api.logininfo}`, user);
- if (res.errcode == '0') {
- localStorage.setItem('user', JSON.stringify(res.data));
- 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 {
- namespaced: true,
- state,
- mutations,
- actions,
- };
|