lrf402788946 5 yıl önce
ebeveyn
işleme
496d7047fe
5 değiştirilmiş dosya ile 69 ekleme ve 19 silme
  1. 3 0
      src/components/index.vue
  2. 6 6
      src/router/index.js
  3. 39 0
      src/store/advert.js
  4. 13 11
      src/store/index.js
  5. 8 2
      src/views/index.vue

+ 3 - 0
src/components/index.vue

@@ -54,6 +54,9 @@
         <el-col :span="24" class="main_5">
           <recruit :recruitList="recruitList" :zixunList="zixunList"></recruit>
         </el-col>
+        <el-col :span="24" class="main_3">
+          <weilai :pic="info.advert" :advertlink="info.advertlink"></weilai>
+        </el-col>
         <div class="w_1270">
           <el-col :span="24" class="login">
             <login></login>

+ 6 - 6
src/router/index.js

@@ -99,12 +99,12 @@ const router = new Router({
     },
   ],
 });
-// router.beforeEach((to, from, next) => {
-//   let fPath = from.path;
-//   let tPath = to.fullPath;
-//   if (fPath === '/index') window.open(tPath);
-//   else next();
-// });
+router.beforeEach((to, from, next) => {
+  let fPath = from.path;
+  let tPath = to.fullPath;
+  if (fPath === '/index') window.open(`.${tPath}`);
+  else next();
+});
 router.afterEach((to, from, next) => {
   window.scrollTo(0, 0);
 });

+ 39 - 0
src/store/advert.js

@@ -0,0 +1,39 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  query: `/api/cms/advert/query`,
+  fetch: id => `/api/cms/advert/fetch/${id}`,
+  create: '/api/cms/advert/create',
+  update: id => `/api/cms/advert/update/${id}`,
+  delete: id => `/api/cms/advert/delete/${id}`,
+};
+export const state = () => ({});
+
+export const mutations = {};
+
+export const actions = {
+  async advQuery({ commit }, { page = 1, size = 10, ...info }) {
+    const skip = Math.max(0, (page - 1) * size);
+    let options = { skip, limit: size };
+    let res = await this.$axios.$get(api.query, { ...options, ...info });
+    return res;
+  },
+  // async fetch({ commit }, payload) {
+  //   let res = await this.$axios.$get(api.fetch(payload));
+  //   return res;
+  // },
+  // async create({ commit }, payload) {
+  //   let res = await this.$axios.$post(api.create, payload);
+  //   return res;
+  // },
+  // async update({ commit }, { id, ...payload }) {
+  //   let res = await this.$axios.$post(api.update(id), payload);
+  //   return res;
+  // },
+  // async delete({ commit }, payload) {
+  //   let res = await this.$axios.$post(api.delete(payload));
+  //   return res;
+  // },
+};

+ 13 - 11
src/store/index.js

@@ -11,6 +11,7 @@ import * as linkCor from './link-cor';
 import * as jobfair from './jobfair';
 import * as talk from './talk';
 import * as corp from './corp';
+import * as advert from './advert';
 
 Vue.use(Vuex);
 
@@ -19,16 +20,17 @@ export default new Vuex.Store({
   mutations: {},
   actions: {},
   modules: {
-    site: site,
-    menu: menu,
-    modules: modules,
-    column: column,
-    news: news,
-    jobinfo: jobinfo,
-    posts: posts,
-    linkCor: linkCor,
-    jobfair: jobfair,
-    talk: talk,
-    corp: corp,
+    site,
+    menu,
+    modules,
+    column,
+    news,
+    jobinfo,
+    posts,
+    linkCor,
+    jobfair,
+    talk,
+    corp,
+    advert,
   },
 });

+ 8 - 2
src/views/index.vue

@@ -24,7 +24,7 @@
 <script>
 import indexDetail from '@/components/index.vue';
 import { urlList } from '@/config/url';
-import { mapActions, mapState } from 'vuex';
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
 import _ from 'lodash';
 export default {
   metaInfo() {
@@ -105,12 +105,13 @@ export default {
     this.loadMenu(); //获取菜单信息
     this.toGetModule(); //获取模块信息
     this.toGetJobInfo(); //获取招聘信息
+    this.getAdv();
     // this.toGetLinks(); //招聘信息+网站链接
     // this.self();
   },
   computed: {},
   methods: {
-    ...mapActions(['getSite', `getMenu`, 'getColumn', 'getAllNews', 'getAllColumn', 'getModule', 'getNews', 'getJobInfo', 'getPosts', 'getLink']),
+    ...mapActions(['getSite', `getMenu`, 'getColumn', 'getAllNews', 'getAllColumn', 'getModule', 'getNews', 'getJobInfo', 'getPosts', 'getLink', 'advQuery']),
     //站点信息
     async toGetSite() {
       let site = sessionStorage.getItem('site');
@@ -283,6 +284,11 @@ export default {
         this.$router.push({ path: '/quiet', query: { title: title } });
       }
     },
+    //请求广告列表
+    async getAdv() {
+      let res = await this.advQuery({ skip: 0, limit: 2 });
+      console.log(res);
+    },
   },
 };
 </script>