_id.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="client-details-page">
  3. <div :style="{backgroundImage: 'url(' + bannerDefault + ')'}" class="client-banner-box"></div>
  4. <!-- 详情页 -->
  5. <div class="client-details-box">
  6. <div class="client-container">
  7. <!--行业资讯详情-->
  8. <h1>{{infoData.title}}</h1>
  9. <p class="details-visits-box"><i></i><span>{{infoData.createDate}}</span>
  10. </p>
  11. <div class="client-content-box" v-html="infoData.content"></div>
  12. <div class="client-details-pagination">
  13. <a v-show="infoData.lastId" :href="`${baseUrl}/news/${infoData.lastId}`">
  14. <span class="mta-hidden-xs" @click.prevent="changeNews(infoData.lastId)" :title="'上一篇:'+infoData.lastTitle">上一篇:{{infoData.lastTitle}}</span>
  15. </a>
  16. <a v-show="infoData.nextId" :href="`${baseUrl}/news/${infoData.nextId}`">
  17. <span class="mta-hidden-xs" @click.prevent="changeNews(infoData.nextId)" :title="'下一篇:'+infoData.nextTitle">下一篇:{{infoData.nextTitle}}</span>
  18. </a>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import { mapGetters } from 'vuex';
  26. export default {
  27. name: 'news_id',
  28. layout: 'templateB',
  29. async asyncData({ params, $axios, store }) {
  30. // 设置选中菜单
  31. store.commit('setActiveNav', '/news');
  32. try {
  33. const url = '/common/client/web/news/info';
  34. const opt = {
  35. id: params.id,
  36. };
  37. const res = await $axios.post(url, opt);
  38. console.log(res);
  39. return {
  40. infoData: res.data.data,
  41. };
  42. } catch (e) {
  43. return {};
  44. }
  45. },
  46. computed: {
  47. baseUrl() {
  48. return this.getBaseUrl;
  49. },
  50. ...mapGetters(['getBaseUrl']),
  51. },
  52. data() {
  53. return {
  54. // banner图
  55. bannerDefault: require(`~/static/images/website/banner/cx-banner-xwzx.png`),
  56. }
  57. },
  58. head(){
  59. return {
  60. title: '家政学',
  61. }
  62. },
  63. methods: {
  64. changeNews(id) {
  65. this.$router.push({ name: 'news-id', params: { id } });
  66. },
  67. },
  68. };
  69. </script>
  70. <style lang="scss">
  71. .client-details-page .client-details-wrap.isRiZhi {
  72. width: 100% !important;
  73. border-right: none;
  74. h1 {
  75. text-align: center;
  76. }
  77. .details-visits-box {
  78. text-align: center;
  79. }
  80. }
  81. </style>