_id.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div class="client-details-page">
  3. <!-- 详情页 -->
  4. <div class="client-details-box">
  5. <!--行业资讯详情-->
  6. <div class="client-details-wrap">
  7. <h1>{{infoData.title}}</h1>
  8. <p class="details-visits-box"><span style="margin-right:10px;">发布时间:</span><span>{{infoData.startTime}}</span><i type="eyes"></i><span>{{infoData.visits}}</span>
  9. </p>
  10. <div class="client-content-box" v-html="infoData.content"></div>
  11. <!-- 关键字 -->
  12. <div class="client-link-json" v-if="linkJson.length">
  13. <span>关键词:</span>
  14. <a :href="item.url" v-for="item in linkJson">{{item.text}}</a>
  15. </div>
  16. <div class="client-details-pagination">
  17. <a v-show="infoData.lastId" :href="`${baseUrl}/news/${infoData.lastId}`">
  18. <span class="mta-hidden-xs" @click.prevent="changeNews(infoData.lastId)" :title="'上一篇:'+infoData.lastName">上一篇:{{infoData.lastName}}</span>
  19. <span class="mta-hidden-sm details-phone-btn" @click.prevent="changeNews(infoData.lastId)">上一篇</span>
  20. </a>
  21. <a v-show="infoData.nextId" :href="`${baseUrl}/news/${infoData.nextId}`">
  22. <span class="mta-hidden-xs" @click.prevent="changeNews(infoData.nextId)" :title="'下一篇:'+infoData.nextName">下一篇:{{infoData.nextName}}</span>
  23. <span class="mta-hidden-sm details-phone-btn" @click.prevent="changeNews(infoData.lastId)">下一篇</span>
  24. </a>
  25. </div>
  26. </div>
  27. <!-- 最新新闻 -->
  28. <div class="latest-news-box mta-hidden-xs">
  29. <h4>近期推荐</h4>
  30. <ul class="latest-news-list">
  31. <li v-for="(item, index) in newestData" :key="index">
  32. <a :href="`${baseUrl}/news/${item.code}`">
  33. <span> {{changeDate(item.startTime)}} </span> <span @click.prevent="changeNews(item.code)" :title="item.title">{{item.title}}</span>
  34. </a>
  35. </li>
  36. </ul>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import { mapGetters } from 'vuex';
  43. export default {
  44. name: 'news_id',
  45. layout: 'templateB',
  46. async asyncData({ params, $axios, store }) {
  47. // 设置选中菜单
  48. store.commit('setActiveNav', '/news');
  49. try {
  50. const url = '/home/news/info';
  51. const opt = {
  52. code: params.id,
  53. };
  54. const res = await $axios.post(url, opt);
  55. const url2 = '/home/news/newest';
  56. const res2 = await $axios.post(url2);
  57. const linkJson = res.data.data['linkJson'] ? JSON.parse(res.data.data['linkJson']) : [];
  58. return {
  59. infoData: res.data.data,
  60. newestData: res2.data.data.data,
  61. linkJson
  62. };
  63. } catch (e) {
  64. return {};
  65. }
  66. },
  67. head(){
  68. return {
  69. title: this.infoData.title,
  70. meta: [
  71. {
  72. hid: this.infoData.keyword,
  73. name: 'description',
  74. content: this.infoData.intro
  75. }
  76. ],
  77. }
  78. },
  79. computed: {
  80. baseUrl() {
  81. return this.getBaseUrl;
  82. },
  83. ...mapGetters(['getBaseUrl']),
  84. },
  85. methods: {
  86. changeDate(myDate) {
  87. const result = new Date(myDate);
  88. const curMonth = (result.getMonth()+1).toString().padStart(2,'0');
  89. const curDay = result.getDate().toString().padStart(2,'0');
  90. return `${curMonth}-${curDay}`
  91. },
  92. changeNews(id) {
  93. this.$router.push({ name: 'news-id', params: { id } });
  94. },
  95. },
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. .client-link-json {
  100. margin-bottom: 10px;
  101. span {
  102. color: #333;
  103. display: inline-block;
  104. margin-left: 10px;
  105. font-weight: 800;
  106. font-size: 14px;
  107. }
  108. a {
  109. color: #00b96b;
  110. display: inline-block;
  111. margin-right: 10px;
  112. font-weight: 400;
  113. font-size: 14px;
  114. }
  115. }
  116. .client-details-page div.latest-news-box {
  117. h4 {
  118. border-left: 3px solid #00b96b;
  119. padding-left: 10px;
  120. }
  121. }
  122. i[type='eyes'] {
  123. background-image: url("~static/gangweiIcon/z147.png");
  124. background-size: contain;
  125. background-position: center;
  126. background-repeat: no-repeat;
  127. }
  128. .client-details-page .client-details-wrap .client-details-pagination a {
  129. color: #2C3E50;
  130. &:hover {
  131. color: #00b96b;
  132. }
  133. @media (max-width: 768px) {
  134. color: #2C3E50;
  135. border-color: #2C3E50;
  136. }
  137. }
  138. </style>