Browse Source

更新网站+首页最后做

guhongwei 5 years ago
parent
commit
32a1c7dd13
5 changed files with 57 additions and 25 deletions
  1. 1 1
      src/layout/index/dian.vue
  2. 1 1
      src/layout/index/linkInfo.vue
  3. 2 0
      src/store/index.js
  4. 38 0
      src/store/link.js
  5. 15 23
      src/views/index.vue

+ 1 - 1
src/layout/index/dian.vue

@@ -3,7 +3,7 @@
     <el-row>
       <el-col :span="24" class="info">
         <el-col :span="4" class="list" v-for="(item, index) in list" :key="index">
-          <el-link :underline="false" :href="item.url">
+          <el-link :underline="false" :href="item.url" target="_blank">
             <el-image style="width:130px;height:160px;" :src="item.pic"></el-image>
           </el-link>
         </el-col>

+ 1 - 1
src/layout/index/linkInfo.vue

@@ -7,7 +7,7 @@
         </el-col>
         <el-col :span="22">
           <el-col :span="6" class="list" v-for="(item, index) in linkList" :key="index">
-            <el-link :underline="false" :href="item.url">
+            <el-link :underline="false" :href="item.url" target="_blank">
               <el-image style="width:245px;height:53px;" :src="item.pic"></el-image>
             </el-link>
           </el-col>

+ 2 - 0
src/store/index.js

@@ -1,12 +1,14 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
 import site from './site';
+import link from './link';
 
 Vue.use(Vuex);
 
 export default new Vuex.Store({
   modules: {
     site,
+    link,
   },
   state: {},
   mutations: {},

+ 38 - 0
src/store/link.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  links: `/api/setting/link`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.links}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.links}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.links}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.links}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.links}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 15 - 23
src/views/index.vue

@@ -15,8 +15,9 @@
 
 <script>
 import indexDetail from '@/components/index.vue';
-import { createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('site');
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapSite } = createNamespacedHelpers('site');
+const { mapActions: mapLink } = createNamespacedHelpers('link');
 export default {
   name: 'index',
   props: {},
@@ -56,24 +57,7 @@ export default {
         date: '2019-12-25',
       },
     ],
-    linkList: [
-      {
-        url: '',
-        pic: require('@/assets/link1.jpg'),
-      },
-      {
-        url: '',
-        pic: require('@/assets/link2.jpg'),
-      },
-      {
-        url: '',
-        pic: require('@/assets/link3.jpg'),
-      },
-      {
-        url: '',
-        pic: require('@/assets/link3.jpg'),
-      },
-    ],
+    linkList: [],
     xinpinList: [
       {
         title: '尼日利亚传统领袖:尼应学习借鉴中国自贸区建设经验',
@@ -96,12 +80,14 @@ export default {
     ],
   }),
   created() {
-    this.search();
+    this.searchSite();
+    this.searchLink();
   },
   computed: {},
   methods: {
-    ...mapActions(['showInfo']),
-    async search() {
+    ...mapSite(['showInfo']),
+    ...mapLink(['query']),
+    async searchSite() {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
@@ -110,6 +96,12 @@ export default {
         this.$message.error(res.errmsg ? res.errmsg : 'error');
       }
     },
+    async searchLink({ ...info } = {}) {
+      const res = await this.query({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `linkList`, res.data);
+      }
+    },
   },
 };
 </script>