From 1714ea49fbbeb8bcb9f9f896ffb873362e8cdca8 Mon Sep 17 00:00:00 2001
From: 明梦爽 <2972214568@qq.com>
Date: 星期四, 18 十一月 2021 10:47:59 +0800
Subject: [PATCH] 动态获取

---
 src/components/page/introduce.vue |  130 ++++++++++++++++++++++++++++++++----------
 1 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/src/components/page/introduce.vue b/src/components/page/introduce.vue
index e00f011..45694b9 100644
--- a/src/components/page/introduce.vue
+++ b/src/components/page/introduce.vue
@@ -4,27 +4,52 @@
       <globalTitle />
     </el-row>
     <el-row class="mart10">
-     <el-col :span="4" class="marr10">
-       <ul>
-        <li
-          v-for="(item, index) in menuList"
-          :key="index"
-          class="liStylenone liPointer marb10"
-          @click="changeMenu(item.name)"
-        >
-          <b :class="cont == item.name?'ft-blue':'ft-black'">{{ item.name }}</b>
-        </li>
-      </ul>
-     </el-col>
-    <el-col :span="18">
-      <div v-html="cont"></div>
-    </el-col>
+      <!-- 灏忔爣棰� -->
+      <el-col :span="4" class="marr10">
+        <ul>
+          <li
+            v-for="(item, index) in menuList"
+            :key="index"
+            class="liStylenone liPointer marb10"
+            @click="changeMenu(item)"
+          >
+            <b :class="cont == item.categoryName ? 'ft-blue' : 'ft-black'">{{
+              item.categoryName
+            }}</b>
+          </li>
+        </ul>
+      </el-col>
+      <el-card class="box-card">
+        <el-col :span="18">
+          <div>
+            <el-row
+              class="marb10"
+              :key="index"
+              v-for="(item, index) in newsList"
+            >
+              {{ item.title }}
+            </el-row>
+          </div>
+          <!-- 鍒嗛〉 -->
+          <div>
+            <el-pagination
+              @current-change="handleCurrentChange"
+              :current-page.sync="currentPage"
+              :page-size="20"
+              layout="total, pager, next"
+              :total="total"
+            >
+            </el-pagination>
+          </div>
+        </el-col>
+      </el-card>
     </el-row>
   </div>
 </template>
 
 <script>
 import globalTitle from '../globalTitle.vue'
+import { getMinTitle, getNewsList } from '../../api/api'
 export default {
   name: 'introduce',
   components: {
@@ -32,28 +57,69 @@
   },
   data() {
     return {
-      cont:'',
-      menuList: [
-        { name: '绠�浠�' },
-        { name: '绔犵▼' },
-        { name: '缁勭粐鏈烘瀯' },
-        { name: '宸ヤ綔鑱岃矗' },
-        { name: '涓撹亴浜哄憳' }
-      ]
+      cont: '',
+      menuList: [],
+      newsList: [],
+      total: 0,
+      currentPage: 1
     }
   },
-  mounted(){
-    this.cont = this.menuList[0].name;
+  created() {
+    this.getMinTitleList()
   },
-  methods:{
-    changeMenu(val){
-      this.cont = val;
+  mounted() {},
+  watch: {
+    menuList(newval, oldval) {
+      this.getAllNewsList(this.menuList[0])
+      this.cont = this.menuList[0].categoryName
+    }
+  },
+  methods: {
+    handleCurrentChange(val) {
+      console.log(`褰撳墠椤�: ${val}`)
     },
+    changeMenu(val) {
+      this.getAllNewsList(val)
+      this.cont = val.categoryName
+    },
+    getMinTitleList() {
+      const data = {
+        contypeId: this.$route.query.id,
+        p: 1
+      }
+      getMinTitle(data)
+        .then((res) => {
+          console.log('res', res)
+          if (res.code == 200) {
+            this.menuList = res.data.records
+          }
+        })
+        .catch((err) => {
+          console.log('err', err)
+        })
+    },
+    getAllNewsList(item) {
+      const data = {
+        categoryId: item.id,
+        contypeId: item.contypeId,
+        p: this.currentPage
+      }
+      getNewsList(data)
+        .then((res) => {
+          console.log('res', res)
+          if (res.code == 200) {
+            this.newsList = res.data.records
+            this.total = Number(res.data.total)
+          }
+        })
+        .catch((err) => {
+          console.log('err', err)
+        })
+    }
   }
 }
 </script>
 <style lang="less" scoped>
-
 ul {
   width: 200px;
   li {
@@ -63,10 +129,10 @@
     text-align: center;
   }
 }
-.ft-blue{
-  color:rgb(9, 143, 252);
+.ft-blue {
+  color: rgb(9, 143, 252);
 }
-.ft-black{
+.ft-black {
   color: #000;
 }
 </style>
\ No newline at end of file

--
Gitblit v1.8.0