pages.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="details">
  3. <breadcrumb ref="breadcrumb"></breadcrumb>
  4. <div class="detailsHome" v-if="pagesItem">
  5. <div class="listBoxLeft">
  6. <letnav ref="letnav" :menuTree="menu"></letnav>
  7. </div>
  8. <div class="listBoxRight">
  9. <h2 class="title">{{ pagesItem.title }}</h2>
  10. <!-- <span class="describe">{{ pagesItem.describe }}</span> -->
  11. <span class="date">发表时间: {{ pagesItem.date | dates }}<span class="visit">访问量: {{ pagesItem.visit }}</span></span>
  12. <div class="content" v-html="pagesItem.content"></div>
  13. </div>
  14. </div>
  15. <el-divider class="divider" v-else>暂无数据</el-divider>
  16. </div>
  17. </template>
  18. <script>
  19. import moment from 'moment';
  20. import letnav from '../components/leftmenu/index.vue';
  21. import breadcrumb from '../components/breadcrumb/index.vue';
  22. import { mapState, mapActions } from 'vuex';
  23. export default {
  24. name: 'pagesHome',
  25. components: {
  26. letnav,
  27. breadcrumb
  28. },
  29. computed: {
  30. ...mapState(['pagesItem', 'menusall'])
  31. },
  32. data() {
  33. return {
  34. id: '',
  35. menu: {}
  36. };
  37. },
  38. async mounted() {
  39. await this.menusQueryAll();
  40. this.code = this.$route.params.code;
  41. await this.pagesFetch({ bind: this.code });
  42. // 顶级菜单参数
  43. this.parentCode = this.$route.query.parentCode;
  44. // 获取一例菜单
  45. this.menu = this.$setChildrenSession({ menus: this.menusall, iscode: this.parentCode });
  46. // 控制左侧菜单当前选项
  47. this.$refs.letnav.setIndex();
  48. },
  49. methods: {
  50. ...mapActions(['pagesFetch', 'menusQueryAll'])
  51. },
  52. filters: {
  53. dates(e) {
  54. return moment(e).format('YYYY-MM-DD');
  55. }
  56. }
  57. };
  58. </script>
  59. <style lang="scss" scoped>
  60. .details {
  61. width: 60%;
  62. margin: 0 auto;
  63. }
  64. .detailsHome {
  65. width: 100%;
  66. display: flex;
  67. margin-bottom: 5%;
  68. .listBoxLeft {
  69. width: 20%;
  70. margin-top: 3%;
  71. margin-right: 5%;
  72. }
  73. .listBoxRight {
  74. width: 75%;
  75. margin-top: 3%;
  76. .thumbnail {
  77. width: 100%;
  78. }
  79. .title, .describe, .content, .date {
  80. width: 100%;
  81. text-align: center;
  82. }
  83. .describe, .date {
  84. display: block;
  85. color: #999;
  86. line-height: 2em;
  87. .visit {
  88. margin-left: 30px;
  89. }
  90. }
  91. .content {
  92. text-align: left;
  93. white-space: pre-wrap;
  94. word-wrap: break-word;
  95. iframe {
  96. width: 70%;
  97. height: 500px;
  98. display: block;
  99. margin: 0 auto;
  100. }
  101. }
  102. }
  103. }
  104. </style>