cashBack.js 1.2 KB

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