_id.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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"><i></i><span>{{infoData.startTime}}</span><i type="visits"></i><span>{{infoData.visits}}</span>
  9. </p>
  10. <div class="client-content-box" v-html="infoData.content"></div>
  11. <div class="client-details-pagination">
  12. <a v-show="infoData.lastId" :href="`${baseUrl}/news/${infoData.lastId}`">
  13. <span @click.prevent="changeNews(infoData.lastId)" :title="'上一篇:'+infoData.lastName">上一篇:{{infoData.lastName}}</span>
  14. </a>
  15. <a v-show="infoData.nextId" :href="`${baseUrl}/news/${infoData.nextId}`">
  16. <span @click.prevent="changeNews(infoData.nextId)" :title="'下一篇:'+infoData.nextName">下一篇:{{infoData.nextName}}</span>
  17. </a>
  18. </div>
  19. </div>
  20. <!-- 最新新闻 -->
  21. <div class="latest-news-box">
  22. <h4>最新新闻</h4>
  23. <ul class="latest-news-list">
  24. <li v-for="(item, index) in newestData" :key="index">
  25. <a :href="`${baseUrl}/news/${item.code}`">
  26. <span @click.prevent="changeNews(item.code)" :title="item.title">{{item.title}}</span>
  27. </a>
  28. <p class="details-visits-box"><i></i><span>{{item.startTime}}</span><i type="visits"></i><span>{{item.visits}}</span>
  29. </p>
  30. </li>
  31. </ul>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { mapGetters } from 'vuex';
  38. export default {
  39. name: 'news_id',
  40. layout: 'templateB',
  41. async asyncData({ params, $axios, store }) {
  42. // 设置选中菜单
  43. store.commit('setActiveNav', '/news');
  44. try {
  45. const url = '/home/news/info';
  46. const opt = {
  47. code: params.id,
  48. };
  49. const res = await $axios.post(url, opt);
  50. const url2 = '/home/news/newest';
  51. const res2 = await $axios.post(url2);
  52. console.log(res);
  53. return {
  54. infoData: res.data.data,
  55. newestData: res2.data.data.data,
  56. };
  57. } catch (e) {
  58. return {};
  59. }
  60. },
  61. head(){
  62. return {
  63. title: this.infoData.keyword,
  64. meta: [
  65. {
  66. hid: this.infoData.keyword,
  67. name: 'description',
  68. content: this.infoData.intro
  69. }
  70. ],
  71. }
  72. },
  73. computed: {
  74. baseUrl() {
  75. return this.getBaseUrl;
  76. },
  77. ...mapGetters(['getBaseUrl']),
  78. },
  79. methods: {
  80. changeNews(id) {
  81. this.$router.push({ name: 'news-id', params: { id } });
  82. },
  83. },
  84. };
  85. </script>
  86. <style>
  87. </style>