index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // import Vue from 'vue'
  2. // import Vuex from 'vuex'
  3. import axios from 'axios'
  4. // Vue.use(Vuex)
  5. export const state = () => ({
  6. wordpressAPI: 'https://open.api.luojigou.vip',
  7. newsNav: [
  8. // {
  9. // icon: require('~/assets/images/news/cate_01.png'),
  10. // title: '中德资讯',
  11. // id: 1
  12. // },
  13. // {
  14. // icon: require('~/assets/images/news/cate_02.png'),
  15. // title: '行业动态',
  16. // id: 2
  17. // },
  18. // {
  19. // icon: require('~/assets/images/news/cate_03.png'),
  20. // title: '门店动态',
  21. // id: 3
  22. // }
  23. ],
  24. })
  25. export const mutations = {
  26. setNav(state, data){
  27. state.newsNav = data
  28. },
  29. };
  30. export const getters = {
  31. };
  32. export const actions = {
  33. async nuxtServerInit({commit,state,req}) {
  34. let newsNav = [];
  35. const { data } = await axios(`${state.wordpressAPI}/official-api/article/type`);
  36. if(data.status === 200) {
  37. newsNav = data.data;
  38. }
  39. commit('setNav', newsNav);
  40. // //产品导航
  41. // let headProdNav = await axios(`${state.wordpressAPI}/proCategory/showAll/main`);
  42. // commit('setHeadProdNav',headProdNav.data);
  43. // //新闻导航
  44. // let headNewsNav = await axios(`${state.wordpressAPI}/articleCategory/getAll`);
  45. // commit('setHeadNewsNav',headNewsNav.data);
  46. // //招聘导航
  47. // let headJobNav = await axios(`${state.wordpressAPIForJob}/jobClass/getAll`);
  48. // commit('setHeadJobNav',headJobNav.data);
  49. // //友情链接
  50. // let indexLinksData = await axios(`${state.wordpressAPI}/link/selectAll`);
  51. // commit('setIndexLinksData',indexLinksData.data);
  52. }
  53. };
  54. // export default {
  55. // state,
  56. // getters,
  57. // mutations,
  58. // actions
  59. // }
  60. // const store = () => new Vuex.Store({
  61. // state,
  62. // getters,
  63. // mutations,
  64. // actions
  65. // })
  66. // export default store