ads.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import axios from "axios";
  2. export const state = () => ({
  3. ads: []
  4. });
  5. export const mutations = {
  6. SET_ADS(state, ads) {
  7. state.ads = ads;
  8. }
  9. };
  10. export const actions = {
  11. async getAds({ commit }) {
  12. await axios.get("https://api.amic.ru/api/v1/advertising/active").then(res => {
  13. commit("SET_ADS", res.data.data)
  14. return true
  15. })
  16. }
  17. };
  18. export const getters = {
  19. headerAds: s => s.ads.filter(obj => { return obj.advertising_section_code == 'header_banner'})[0],
  20. mainAds: s => s.ads.filter(obj => { return obj.advertising_section_code == 'main_banner'})[0],
  21. sideAds: s => s.ads.filter(obj => { return obj.advertising_section_code == 'side_banner'})[0],
  22. partners1: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners1'})[0],
  23. partners2: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners2'})[0],
  24. partners3: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners3'})[0],
  25. partners4: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners4'})[0],
  26. partners5: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners5'})[0]
  27. };
  28. export default {
  29. namespaced: true,
  30. state,
  31. getters,
  32. actions,
  33. mutations
  34. }