明梦爽
2022-08-09 ece9b6bba5a44a06041a8ad4d5f5ac1f14560d3e
src/components/page/introduce.vue
@@ -8,14 +8,14 @@
      <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.name ? 'ft-blue' : 'ft-black'">{{item.name}}</b>
            <b :class="cont == item.name ? 'ft-blue' : 'ft-black'">{{ item.name }}</b>
          </li>
        </ul>
      </el-col>
       <!-- 新闻内容 -->
      <!-- 新闻内容 -->
      <el-card class="box-card">
        <el-col>
          <div v-html="this.new.content"></div>
          <div v-html="this.new.content" class="ql-editor"></div>
        </el-col>
      </el-card>
    </el-row>
@@ -24,7 +24,7 @@
<script>
import globalTitle from '../globalTitle.vue'
import {getMinTitle,getNewsList,getnew} from '../../api/api'
import { getMinTitle, getNewsList, getnew } from '../../api/api'
export default {
  name: 'introduce',
  components: {
@@ -34,67 +34,73 @@
    return {
      cont: '',
      menuList: [],
      newsList:[],
      new:{}  //新闻对象
      newsList: [],
      new: {} //新闻对象
    }
  },
  created() {
  },
  created() {},
  mounted() {
    this.getTitle();
    this.getTitle()
  },
  watch: {
    menuList(n,o){
      this.cont =  this.menuList[0].name;
      this.getnews(this.menuList[0]); //改变对象,菜单栏的东西要写到监听属性里边
    menuList(n, o) {
      this.cont = this.menuList[0].name
      this.getnews(this.menuList[0]) //改变对象,菜单栏的东西要写到监听属性里边
    }
  },
  methods: {
    //获取小标题的id
    getTitle(){
      const data = Number(this.$route.query.id);
      getMinTitle(data).then(res => {
        // console.log(res);
        if(res.code == 200){
          this.menuList = res.data
        }
      }).catch(err => {
        console.log(err);
      })
    getTitle() {
      const data = Number(this.$route.query.id)
      getMinTitle(data)
        .then(res => {
          // console.log(res);
          if (res.code == 200) {
            this.menuList = res.data
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    //小标题菜单的球切换
    changeMenu(val) {
      this.cont = val.name;
      this.cont = val.name
      this.getnews(val)
    },
    //获取到了新闻列表,里边只有一个对象
    getnews(item){
    getnews(item) {
      const data = {
        current:1,
        newsCategoryId:item.id,
        size:5
      };
      getNewsList(data).then(res => {
        // console.log(res);
        if(res.code == 200){
          this.newsList = res.data.records
          this.getalone(this.newsList[0].id)
        }
      }).catch(error => {
        console.log(error);
      })
        current: 1,
        newsCategoryId: item.id,
        size: 5
      }
      getNewsList(data)
        .then(res => {
          // console.log(res);
          if (res.code == 200) {
            this.newsList = res.data.records
            this.getalone(this.newsList[0].id)
          }
        })
        .catch(error => {
          console.log(error)
        })
    },
    //获取新闻内容,得到一个新闻对象
    getalone(id){
      const data = id;
      getnew(data).then(res => {
        // console.log(res);
        if(res.code == 200){
          this.new = res.data;
        }
      }).catch(error => {
        console.log(error);
      })
    getalone(id) {
      const data = id
      getnew(data)
        .then(res => {
          // console.log(res);
          if (res.code == 200) {
            this.new = res.data
            console.log(this.new.content)
          }
        })
        .catch(error => {
          console.log(error)
        })
    }
  }
}
@@ -109,13 +115,13 @@
    text-align: center;
  }
}
.box-card{
  // background-color: rgb(131, 212, 115);
}
.ft-blue {
  color: rgb(9, 143, 252);
}
.ft-black {
  color: #000;
}
</style>
.ql-editor {
  padding: 12px 0px !important;
}
</style>