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. })
  63. },
  64. // 预览文件
  65. open_file(path) {
  66. uni.downloadFile({
  67. url: path,
  68. success: function(res) {
  69. var filePath = res.tempFilePath;
  70. uni.openDocument({
  71. filePath: filePath,
  72. success: function(res) {
  73. console.log('打开文档成功');
  74. }
  75. });
  76. }
  77. });
  78. },
  79. }
  80. }
  81. </script>
  82. <style lang="scss">
  83. .content {
  84. width: 749rpx;
  85. box-sizing: border-box;
  86. padding: 24rpx;
  87. }
  88. .title {
  89. line-height: 30px;
  90. }
  91. .time {
  92. line-height: 30px;
  93. font-size: 14px;
  94. color: #999;
  95. }
  96. .line {
  97. line-height: 30px;
  98. font-size: 16px;
  99. }
  100. .inner {
  101. margin: 20px 0;
  102. text-indent: 2rem;
  103. word-break: break-all;
  104. overflow: hidden;
  105. line-height: 1.5;
  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>