detail.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="page">
  3. <view class="notice-title">{{ detail.title }}</view>
  4. <view class="notice-content"><rich-text :nodes="content"></rich-text></view>
  5. <view class="notice-meta">
  6. <text class="notice-time">发表时间: {{ $util.timeStampTurnTime(detail.create_time) }}</text>
  7. </view>
  8. <loading-cover ref="loadingCover"></loading-cover>
  9. </view>
  10. </template>
  11. <script>
  12. import htmlParser from '@/common/js/html-parser';
  13. export default {
  14. data() {
  15. return {
  16. notice_id: 0,
  17. content: '',
  18. detail: {}
  19. };
  20. },
  21. onLoad(option) {
  22. option.notice_id ? (this.notice_id = option.notice_id) : this.$util.redirectTo('/pages/notice/list', {}, 'redirectTo');
  23. this.$api.sendRequest({
  24. url: '/shopapi/notice/detail',
  25. data: {
  26. id: this.notice_id
  27. },
  28. success: res => {
  29. if (res.code == 0 && res.data) {
  30. this.detail = res.data;
  31. this.content = htmlParser(res.data.content);
  32. if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
  33. } else {
  34. this.$util.showToast({
  35. title: res.message
  36. });
  37. setTimeout(() => {
  38. this.$util.redirectTo('/pages/notice/list', {}, 'redirectTo');
  39. }, 1000);
  40. }
  41. }
  42. });
  43. },
  44. onShareAppMessage(res) {
  45. var title = '[公告]' + this.detail.title;
  46. var path = '/pages/notice/detail?notice_id=' + this.notice_id;
  47. return {
  48. title: title,
  49. path: path,
  50. success: res => {},
  51. fail: res => {}
  52. };
  53. }
  54. };
  55. </script>
  56. <style lang="scss">
  57. .page {
  58. width: 100%;
  59. height: 100%;
  60. padding: 30rpx;
  61. box-sizing: border-box;
  62. background-color: #fff;
  63. }
  64. .notice-title {
  65. font-size: $font-size-toolbar;
  66. text-align: center;
  67. }
  68. .notice-content {
  69. margin-top: $margin-updown;
  70. word-break: break-all;
  71. font-size: $font-size-base;
  72. }
  73. .notice-meta {
  74. text-align: right;
  75. margin-top: $margin-updown;
  76. color: $color-tip;
  77. .notice-time {
  78. font-size: $font-size-tag;
  79. }
  80. }
  81. </style>