dockVip.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. const jwt = require('jsonwebtoken');
  5. Vue.use(Vuex);
  6. const api = {
  7. dockInfo: `/api/live/v0/dock/dockVip`,
  8. };
  9. const state = () => ({});
  10. const mutations = {};
  11. const actions = {
  12. async query({ commit }, { skip = 0, limit, ...info } = {}) {
  13. const res = await this.$axios.$get(`${api.dockInfo}`, {
  14. skip,
  15. limit,
  16. ...info,
  17. });
  18. return res;
  19. },
  20. async create({ commit }, payload) {
  21. const res = await this.$axios.$post(`${api.dockInfo}`, payload);
  22. return res;
  23. },
  24. async fetch({ commit }, payload) {
  25. const res = await this.$axios.$get(`${api.dockInfo}/${payload}`);
  26. return res;
  27. },
  28. async update({ commit }, { id, ...data }) {
  29. const res = await this.$axios.$post(`${api.dockInfo}/update/${id}`, data);
  30. return res;
  31. },
  32. async delete({ commit }, payload) {
  33. const res = await this.$axios.$delete(`${api.dockInfo}/${payload}`);
  34. return res;
  35. },
  36. async login({ commit }, payload) {
  37. const res = await this.$axios.$post(`${api.dockInfo}/login`, payload);
  38. if (res.errcode === 0) {
  39. localStorage.setItem('token', res.data);
  40. const user = jwt.decode(res.data);
  41. commit('setUser', user, { root: true });
  42. }
  43. return res;
  44. },
  45. };
  46. export default {
  47. namespaced: true,
  48. state,
  49. mutations,
  50. actions,
  51. };