noticeItem.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <uni-swipe-action>
  3. <uni-swipe-action-item>
  4. <view class="notice-item" @click="handleToDetail">
  5. <view class="content">
  6. <view class="left">
  7. {{ itemData.title }}
  8. </view>
  9. <view v-if="itemData.isRead === 0" class="right dot" />
  10. </view>
  11. <view class="time">
  12. {{ itemData.createTime }}
  13. </view>
  14. </view>
  15. <view
  16. slot="right"
  17. class="control-box"
  18. @click="handleDelete">
  19. 删除
  20. </view>
  21. </uni-swipe-action-item>
  22. </uni-swipe-action>
  23. </template>
  24. <script>
  25. import { ReadMessage } from 'API/admin'
  26. export default {
  27. name: 'NoticeItem',
  28. props: {
  29. itemData: {
  30. type: Object,
  31. required: true
  32. }
  33. },
  34. data() {
  35. return {}
  36. },
  37. methods: {
  38. async handleToDetail() {
  39. try {
  40. await this.readMessage()
  41. } catch {
  42. return
  43. }
  44. this.$Router.navigateTo({
  45. url: '/pages_oa/notice/detail',
  46. query: {
  47. id: this.itemData.typeId
  48. }
  49. })
  50. },
  51. readMessage() {
  52. return new Promise((resolve, reject) => {
  53. ReadMessage({
  54. messageId: this.itemData.messageId
  55. }).then(() => {
  56. resolve(true)
  57. }).catch(() => {
  58. reject(false)
  59. })
  60. })
  61. },
  62. handleDelete(evt) {
  63. this.$emit('delete', evt)
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. .notice-item {
  70. width: 100%;
  71. padding: 15rpx 32rpx;
  72. background-color: white;
  73. border-bottom: 1rpx solid $border-color;
  74. overflow: hidden;
  75. .content {
  76. width: 100%;
  77. margin: 5px 0;
  78. @include left;
  79. .left {
  80. flex: 1;
  81. font-size: $wk-font-medium;
  82. color: $dark;
  83. text-overflow: ellipsis;
  84. white-space: nowrap;
  85. overflow: hidden;
  86. }
  87. .dot {
  88. width: 15rpx;
  89. height: 15rpx;
  90. background-color: red;
  91. border-radius: 50%;
  92. margin-left: 15rpx;
  93. }
  94. }
  95. .time {
  96. width: 100%;
  97. color: $light;
  98. font-size: $wk-font-sm;
  99. text-align: right;
  100. }
  101. }
  102. .control-box {
  103. width: 150rpx;
  104. color: white;
  105. font-size: $wk-font-base;
  106. background-color: #E60000;
  107. @include center;
  108. }
  109. </style>