guhongwei 5 gadi atpakaļ
vecāks
revīzija
7df4d442bf
2 mainītis faili ar 36 papildinājumiem un 1 dzēšanām
  1. 25 0
      src/store.js
  2. 11 1
      src/views/index/request.vue

+ 25 - 0
src/store.js

@@ -35,6 +35,17 @@ const api = {
   // 站点管理
   siteQuery: '/api/cms/site/query',
   siteFetch: `/api/cms/site/config`,
+  // 新闻管理
+  news: '/api/cms/news/create',
+  query: '/api/cms/news/query',
+  fetch: '/api/cms/news/fetch/{id}',
+  update: '/api/cms/news/update/{id}',
+  delete: '/api/cms/news/delete/{id}',
+  // news: '/adminapi/cms/news/create',
+  // query: '/adminapi/cms/news/query',
+  // fetch: id => `/adminapi/cms/news/fetch/${id}`,
+  // update: id => `/adminapi/cms/news/update/${id}`,
+  // delete: id => `/adminapi/cms/news/delete/${id}`,
 };
 
 export default new Vuex.Store({
@@ -284,6 +295,20 @@ export default new Vuex.Store({
       }
       return result;
     },
+    // 新闻管理
+    async newsOperation({ state }, { type, data }) {
+      let { skip, limit } = data;
+      let result;
+      if (type === 'list') {
+        let { site, column } = data;
+        result = await this.$axios.$get(api.query, { site: site, column: column, skip: skip, limit: limit });
+      }
+      if (type === 'search') {
+        let { id } = data;
+        result = await this.$axios.$get(api.fetc, {}, { id: id });
+      }
+      return result;
+    },
   },
 });
 

+ 11 - 1
src/views/index/request.vue

@@ -65,7 +65,7 @@ export default {
   },
   computed: {},
   methods: {
-    ...mapActions(['jobfairOperation', 'postTalksInfo', 'jobinfoOperation', 'getBugInfo', 'siteOperation']),
+    ...mapActions(['jobfairOperation', 'postTalksInfo', 'jobinfoOperation', 'getBugInfo', 'siteOperation', 'newsOperation']),
     async getSite() {
       let site = sessionStorage.getItem('site');
       if (site) {
@@ -78,11 +78,13 @@ export default {
         if (`${result.errcode}` === `0`) {
           sessionStorage.setItem('site', JSON.stringify(result.data));
           this.$set(this, `site`, result.data);
+          console.log(site);
         }
       }
     },
     async search() {
       console.log(this.$site);
+
       // 1直接拿着参数发送请求
       let result = await this.postTalksInfo({ type: 'list', data: { schid: this.$site } });
       if (`${result.errcode}` === '0') {
@@ -112,6 +114,14 @@ export default {
       } else {
         this.$message.error(result.errmsg ? result.errmsg : 'error');
       }
+      result = await this.newsOperation({ type: 'list', data: { site: this.$site, limit: this.limit, skip: 0 } });
+      if (`${result.errcode}` === '0') {
+        //给this=>vue的实例下在中的list属性,赋予result。data的值
+        this.$set(this, 'newList', result.data);
+      } else {
+        this.$message.error(result.errmsg ? result.errmsg : 'error');
+      }
+
       // result = await this.getBugInfo({ data: { skip: 0, limit: this.$limit } });
       // if (`${result.errcode}` === '0') {
       //   //给this=>vue的实例下在中的list属性,赋予result。data的值