index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view>
  3. <Nav title="消息详情" isBack @goBack="handelBack" />
  4. <view class="content">
  5. <view class="section" v-if="msg">
  6. <view class="title">
  7. <h2>{{msg.noticeTitle}}</h2>
  8. </view>
  9. <view>
  10. <view class="time">发布日期:{{msg.createTime}}</view>
  11. </view>
  12. <view class="cont">
  13. <text>{{msg.noticeContent}}</text>
  14. </view>
  15. <view class="empty" v-if="!this.msg">
  16. <u-empty mode="data" icon="../../static/data.png">
  17. </u-empty>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getToken
  26. } from "@/utils/auth.js"
  27. export default {
  28. data() {
  29. return {
  30. id: null,
  31. state: null,
  32. msg: null,
  33. }
  34. },
  35. onLoad(options) {
  36. this.id = options.id
  37. this.state = options.state
  38. if (this.id) {
  39. this.getMsg()
  40. }
  41. if (this.id && this.state === '0') {
  42. this.msgStatus()
  43. }
  44. },
  45. methods: {
  46. //返回按钮
  47. handelBack() {
  48. uni.switchTab({
  49. url: '/pages/message/index'
  50. });
  51. },
  52. //消息详情接口
  53. getMsg() {
  54. uni.$http.get('/messageNotice/getMessageNoticeById', {
  55. id: this.id
  56. }).then(res => {
  57. const data = res.data
  58. if (data.code === 200) {
  59. this.msg = data.data
  60. }
  61. })
  62. },
  63. //改变消息已读状态
  64. msgStatus() {
  65. uni.$http.post('/messageNotice/readMessageNoticeById?id=' + this.id)
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .content {
  72. padding: 25rpx;
  73. .section {
  74. position: relative;
  75. text-align: center;
  76. .title {
  77. margin-bottom: 40rpx;
  78. word-wrap: break-word
  79. }
  80. .time {
  81. font-size: 31rpx;
  82. color: #9fa297;
  83. }
  84. .cont {
  85. margin-top: 60rpx;
  86. text-align: left;
  87. word-wrap: break-word
  88. }
  89. .empty {
  90. position: absolute;
  91. top: 0;
  92. right: 0;
  93. left: 0;
  94. bottom: 0;
  95. }
  96. }
  97. }
  98. </style>