message-detail.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="title">{{detail.title}}</view>
  5. <view class="time">{{detail.created_at}}</view>
  6. <view class="line">发送人:{{detail.send_user}}</view>
  7. <view class="line" v-if="detail.scope != 'all'">接收人:{{detail.scope}}</view>
  8. <view class="line" v-if="detail.scope == 'all'">接收人:所有人</view>
  9. <view class="inner" v-html="detail.content"></view>
  10. <view class="section" v-if="detail.files.length > 0">
  11. <view class="title">附件:</view>
  12. <view>
  13. <view class="file_list">
  14. <view class="item" v-for="(item,index) in detail.files" :key="index"
  15. @click="open_file(item.path)">
  16. <view class="left">
  17. <view class="icon"></view>
  18. <view class="info">
  19. <view class="name">{{item.fileName}}</view>
  20. </view>
  21. </view>
  22. <view class="right">
  23. <uni-icons type="arrowright"></uni-icons>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. detail: {}
  37. };
  38. },
  39. onLoad() {
  40. const self = this
  41. const eventChannel = this.getOpenerEventChannel()
  42. // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
  43. eventChannel.on('acceptDataFromOpenerPage', (data) => {
  44. // console.log(data.data)
  45. this.detail = data.data
  46. console.log(this.detail)
  47. })
  48. // 设置标题
  49. uni.setNavigationBarTitle({
  50. title: this.detail.title
  51. })
  52. this.read(this.detail.id)
  53. },
  54. methods: {
  55. // 标为已读
  56. read(id) {
  57. // console.log(this.detail.id)
  58. this.$api.message_read({
  59. id: id
  60. }).then((res) => {
  61. console.log(res)
  62. this.get_message_list()
  63. })
  64. },
  65. // 预览文件
  66. open_file(path) {
  67. uni.downloadFile({
  68. url: path,
  69. success: function(res) {
  70. var filePath = res.tempFilePath;
  71. uni.openDocument({
  72. filePath: filePath,
  73. success: function(res) {
  74. console.log('打开文档成功');
  75. }
  76. });
  77. }
  78. });
  79. },
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .content {
  85. width: 749rpx;
  86. box-sizing: border-box;
  87. padding: 24rpx;
  88. }
  89. .title {
  90. line-height: 30px;
  91. }
  92. .time {
  93. line-height: 30px;
  94. font-size: 14px;
  95. color: #999;
  96. }
  97. .line {
  98. line-height: 30px;
  99. font-size: 16px;
  100. }
  101. .inner {
  102. margin: 20px 0;
  103. text-indent: 2rem;
  104. word-break: break-all;
  105. overflow: hidden;
  106. }
  107. .file_list {
  108. .item {
  109. height: 30px;
  110. display: flex;
  111. justify-content: space-between;
  112. align-items: center;
  113. border-bottom: 1px solid #ECF0F1;
  114. padding: 8px 0;
  115. .left {
  116. display: flex;
  117. .icon {}
  118. .info {
  119. .name {
  120. font-size: 16px;
  121. font-family: MicrosoftYaHei;
  122. color: #2C3E50;
  123. }
  124. }
  125. }
  126. .right {}
  127. }
  128. }
  129. </style>