Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

120 linhas
4.0 KiB

  1. <template>
  2. <el-main class="main-container">
  3. <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
  4. <el-breadcrumb-item class="location">您的位置:</el-breadcrumb-item>
  5. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  6. <el-breadcrumb-item @click.native="goToList()">新闻资讯</el-breadcrumb-item>
  7. <el-breadcrumb-item v-if="isShow">详情</el-breadcrumb-item>
  8. </el-breadcrumb>
  9. <el-row class="card_menu">
  10. <el-col :span="4">
  11. <el-card class="box-card" shadow="never" :body-style="{ padding: '10px 0'}">
  12. <div slot="header">
  13. <span>新闻资讯</span>
  14. </div>
  15. <!-- <div class="menu-item active"><router-link to="/vip-service">会员服务</router-link></div> -->
  16. <div class="menu-item" v-for="(item, index) in titleList" :key="index"
  17. :class="{'active' : (index == activeIndex)}" @click="changeType(index)">
  18. {{item.channelName}}</div>
  19. </el-card>
  20. </el-col>
  21. <el-col :span="20" style="padding: 0 10px;">
  22. <el-card shadow="never" v-if="!isShow">
  23. <ul style="list-style: none">
  24. <li :to='"/detail?id="+item.id' style="padding: 10px;border-bottom: 1px solid #eee;margin: 5px 0"
  25. v-for="(item,index) in dataList" :key="index" @click="goToDetail(item)">
  26. {{ index+1 }}、{{item.title}}
  27. <span style="float:right">{{item.publishTime}}</span></li>
  28. </ul>
  29. <el-pagination
  30. background
  31. layout="prev, pager, next"
  32. :total="total" prev-text="上一页" next-text="下一页" style="float: right;margin: 10px">
  33. </el-pagination>
  34. </el-card>
  35. <el-card class="article" shadow="never" style="border-radius: 8px" v-if="isShow">
  36. <h2 class="title">上海市集成电路行业协会简介</h2>
  37. <div class="info">作者:SICA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;发布日期:2011年12月28日&nbsp;星期三</div>
  38. <div class="content" v-html="activeItem.content"></div>
  39. </el-card>
  40. </el-col>
  41. </el-row>
  42. </el-main>
  43. </template>
  44. <script>
  45. import {getChannelInformationsRequest, getChannelsRequest, getChannelSecond,
  46. getDetailRequest} from "../api/data";
  47. export default {
  48. data () {
  49. return {
  50. titleList: [],
  51. activeIndex: 0,
  52. dataList: [],
  53. total: 0,
  54. isShow: false,
  55. activeItem: {}
  56. }
  57. },
  58. methods: {
  59. goToList(){
  60. this.isShow = false
  61. this.$forceUpdate()
  62. },
  63. goToDetail(item){
  64. this.isShow = true
  65. this.activeItem = {...item}
  66. },
  67. async getChannelsRequest(){
  68. let res = await getChannelsRequest({current:1,size:100})
  69. if(res.code == 200){
  70. res.data.records.map((item) => {
  71. if(item.channelName == '新闻资讯'){
  72. this.getChannelSecond(item.id)
  73. }
  74. })
  75. }
  76. },
  77. async getChannelSecond(id){
  78. let res = await getChannelSecond(id)
  79. if(res.code == 200){
  80. // console.log(JSON.stringify(res.data))
  81. this.titleList = res.data
  82. if(this.titleList && this.titleList[0]){
  83. this.getChannelInformationsRequest(this.titleList[0].id)
  84. }
  85. }
  86. },
  87. async getChannelInformationsRequest(id){
  88. let res = await getChannelInformationsRequest({channelId: id})
  89. if(res.code == 200){
  90. this.dataList = res.data.records
  91. this.total = res.data.total
  92. this.dataList.map((item) => {
  93. item.publishTime = this.$moment().format("YYYY-MM-DD")
  94. })
  95. }
  96. },
  97. changeType(index){
  98. this.activeIndex = index;
  99. this.getChannelInformationsRequest(this.titleList[index].id)
  100. }
  101. },
  102. mounted() {
  103. this.getChannelsRequest()
  104. }
  105. }
  106. </script>
  107. <style>
  108. </style>