detail.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="notice-wrap">
  3. <el-breadcrumb separator="/" class="path">
  4. <el-breadcrumb-item :to="{ path: '/' }" class="path-home">首页</el-breadcrumb-item>
  5. <el-breadcrumb-item :to="{ path: '/cms/notice/list' }">公告列表</el-breadcrumb-item>
  6. <el-breadcrumb-item class="path-help">公告详情</el-breadcrumb-item>
  7. </el-breadcrumb>
  8. <div class="notice-detil" v-loading="loading">
  9. <div class="notice-info">
  10. <div class="title">{{ info.title }}</div>
  11. <div class="time">{{ $util.timeStampTurnTime(info.create_time) }}</div>
  12. </div>
  13. <div class="content" v-html="info.content"></div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import { mapGetters } from 'vuex';
  19. import { noticeDetail } from '@/api/cms/notice';
  20. export default {
  21. name: 'notice_detail',
  22. components: {},
  23. data: () => {
  24. return {
  25. info: {},
  26. loading: true
  27. };
  28. },
  29. created() {
  30. this.id = this.$route.query.id;
  31. this.getDetail();
  32. },
  33. computed: {
  34. ...mapGetters(['siteInfo'])
  35. },
  36. watch: {
  37. $route(curr) {
  38. this.id = curr.query.id;
  39. this.getDetail();
  40. }
  41. },
  42. methods: {
  43. getDetail() {
  44. noticeDetail({
  45. id: this.id
  46. })
  47. .then(res => {
  48. if (res.data) {
  49. this.info = res.data;
  50. this.loading = false;
  51. window.document.title = `${this.info.title} - ${this.siteInfo.site_name}`;
  52. } else {
  53. this.$router.push({
  54. path: '/cms/notice/list'
  55. });
  56. }
  57. })
  58. .catch(err => {
  59. this.loading = false;
  60. this.$message.error(err.message);
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss" scoped>
  67. .notice-wrap {
  68. width: $width;
  69. margin: 0 auto 45px;
  70. }
  71. .notice-detil {
  72. background-color: #ffffff;
  73. min-height: 300px;
  74. margin: 10px 0;
  75. padding: 10px;
  76. .title {
  77. text-align: center;
  78. font-size: 18px;
  79. margin: 10px 0;
  80. }
  81. .time {
  82. text-align: center;
  83. color: #838383;
  84. margin-bottom: 17px;
  85. }
  86. .notice-info {
  87. margin: 0 43px;
  88. border-bottom: 1px dotted #e9e9e9;
  89. }
  90. .content {
  91. padding-top: 10px;
  92. margin: 0 65px;
  93. }
  94. }
  95. .path {
  96. padding: 15px 0;
  97. }
  98. </style>