guhongwei 4 years ago
parent
commit
2d14b4804a

BIN
src/assets/noImg.jpg


+ 4 - 1
src/store/index.js

@@ -1,5 +1,6 @@
 import Vue from 'vue';
 import Vue from 'vue';
 import Vuex from 'vuex';
 import Vuex from 'vuex';
+import refute from './refute';
 
 
 Vue.use(Vuex);
 Vue.use(Vuex);
 
 
@@ -7,5 +8,7 @@ export default new Vuex.Store({
   state: {},
   state: {},
   mutations: {},
   mutations: {},
   actions: {},
   actions: {},
-  modules: {},
+  modules: {
+    refute,
+  },
 });
 });

+ 40 - 0
src/store/refute.js

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

+ 2 - 2
src/views/index.vue

@@ -63,7 +63,7 @@ export default {
   .top {
   .top {
     height: 40px;
     height: 40px;
     overflow: hidden;
     overflow: hidden;
-    border-bottom: 1px solid #ccc;
+    border-bottom: 1px solid #f1f1f1;
   }
   }
   .info {
   .info {
     overflow-y: auto;
     overflow-y: auto;
@@ -71,7 +71,7 @@ export default {
   .foot {
   .foot {
     height: 50px;
     height: 50px;
     overflow: hidden;
     overflow: hidden;
-    border-top: 1px solid #ccc;
+    border-top: 1px solid #f1f1f1;
   }
   }
 }
 }
 </style>
 </style>

+ 14 - 12
src/views/refute/detail.vue

@@ -5,9 +5,7 @@
         <el-col :span="24" class="top">
         <el-col :span="24" class="top">
           <top topType="2" @upBack="upBack"></top>
           <top topType="2" @upBack="upBack"></top>
         </el-col>
         </el-col>
-        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }" @scroll.native="scrollEvent">
-          内容
-        </el-col>
+        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }" @scroll.native="scrollEvent"> </el-col>
       </el-col>
       </el-col>
     </el-row>
     </el-row>
   </div>
   </div>
@@ -16,6 +14,7 @@
 <script>
 <script>
 import top from '@/layout/common/top.vue';
 import top from '@/layout/common/top.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapRefute } = createNamespacedHelpers('refute');
 export default {
 export default {
   name: 'index',
   name: 'index',
   props: {},
   props: {},
@@ -35,7 +34,13 @@ export default {
     this.$set(this, `clientHeight`, clientHeight);
     this.$set(this, `clientHeight`, clientHeight);
   },
   },
   methods: {
   methods: {
-    search() {},
+    ...mapRefute(['fetch']),
+    async search() {
+      if (this.id) {
+        let res = await this.fetch(this.id);
+        console.log(res);
+      }
+    },
     // 返回上一页
     // 返回上一页
     upBack() {
     upBack() {
       this.$router.push({ path: '/refute/index' });
       this.$router.push({ path: '/refute/index' });
@@ -43,17 +48,14 @@ export default {
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
   },
   },
   metaInfo() {
   metaInfo() {
     return { title: this.$route.meta.title };
     return { title: this.$route.meta.title };
   },
   },
-  watch: {
-    test: {
-      deep: true,
-      immediate: true,
-      handler(val) {},
-    },
-  },
+  watch: {},
 };
 };
 </script>
 </script>
 
 
@@ -62,7 +64,7 @@ export default {
   .top {
   .top {
     height: 40px;
     height: 40px;
     overflow: hidden;
     overflow: hidden;
-    border-bottom: 1px solid #ccc;
+    border-bottom: 1px solid #f1f1f1;
   }
   }
   .info {
   .info {
     overflow-y: auto;
     overflow-y: auto;

+ 10 - 2
src/views/refute/index.vue

@@ -21,6 +21,8 @@ import list from './parts/list.vue';
 import top from '@/layout/common/top.vue';
 import top from '@/layout/common/top.vue';
 import page from '@/layout/common/page.vue';
 import page from '@/layout/common/page.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapRefute } = createNamespacedHelpers('refute');
+
 export default {
 export default {
   name: 'index',
   name: 'index',
   props: {},
   props: {},
@@ -99,8 +101,14 @@ export default {
     this.$set(this, `clientHeight`, clientHeight);
     this.$set(this, `clientHeight`, clientHeight);
   },
   },
   methods: {
   methods: {
-    search({ skip = 0, limit = 10, searchName, ...info } = {}) {
-      console.log(searchName);
+    ...mapRefute(['query']),
+    async search({ skip = 0, limit = 5, searchName, ...info } = {}) {
+      if (searchName) info.title = searchName;
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `refuteList`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     },
     // 详情
     // 详情
     detailBtn(data) {
     detailBtn(data) {

+ 13 - 3
src/views/refute/parts/list.vue

@@ -4,7 +4,11 @@
       <el-col :span="24" class="main">
       <el-col :span="24" class="main">
         <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item)">
         <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item)">
           <el-col :span="8" class="image">
           <el-col :span="8" class="image">
-            <el-image :src="item.imgUrl"></el-image>
+            <el-image :src="item.imgUrl">
+              <div slot="error" class="image-slot">
+                <img :src="noImg" alt="" />
+              </div>
+            </el-image>
           </el-col>
           </el-col>
           <el-col :span="16" class="info">
           <el-col :span="16" class="info">
             <el-col :span="24" class="title">
             <el-col :span="24" class="title">
@@ -12,7 +16,7 @@
             </el-col>
             </el-col>
             <el-col :span="24" class="date">
             <el-col :span="24" class="date">
               <span>{{ item.renew_time }}</span>
               <span>{{ item.renew_time }}</span>
-              <span>阅读:{{ item.num >= 10000 ? '1万+' : item.num }}</span>
+              <span>阅读:{{ item.read >= 10000 ? '1万+' : item.read }}</span>
             </el-col>
             </el-col>
           </el-col>
           </el-col>
         </el-col>
         </el-col>
@@ -30,7 +34,9 @@ export default {
   },
   },
   components: {},
   components: {},
   data: function() {
   data: function() {
-    return {};
+    return {
+      noImg: require('@a/noImg.jpg'),
+    };
   },
   },
   created() {},
   created() {},
   methods: {
   methods: {
@@ -68,6 +74,10 @@ export default {
         height: 100%;
         height: 100%;
         border-radius: 5px;
         border-radius: 5px;
       }
       }
+      /deep/.image-slot img {
+        width: 100%;
+        height: 100%;
+      }
     }
     }
     .info {
     .info {
       padding: 0 8px;
       padding: 0 8px;

+ 1 - 1
vue.config.js

@@ -22,7 +22,7 @@ module.exports = {
         target: 'http://broadcast.waityou24.cn',
         target: 'http://broadcast.waityou24.cn',
       },
       },
       '/api': {
       '/api': {
-        target: 'http://broadcast.waityou24.cn',
+        target: 'http://192.168.1.19:10010',
         changeOrigin: true,
         changeOrigin: true,
         ws: true,
         ws: true,
       },
       },