cwg-notice-drawer.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <uni-popup ref="popupRef" type="right" background-color="#fff">
  3. <view class="right-drawer">
  4. <view class="notification-list" v-if="list.length">
  5. <view v-for="item in list" :key="item.id" class="notification-item" @click="goPages(item)">
  6. <view class="item-content">
  7. <view class="item-title">{{ item.subject }}</view>
  8. <view class="item-time">{{ item.addTime }}</view>
  9. </view>
  10. <view class="item-badge" v-if="item.read == 0">
  11. <view class="dot"></view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="list-empty-state drawer-empty-state" v-else>
  16. <cwg-empty-state />
  17. </view>
  18. <view class="logout-wrap">
  19. <view class="logout-btn" @click="goMore">
  20. <cwg-icon name="logout" :size="16" color="#97A1C0" />
  21. <text v-t="'News.More'" />
  22. </view>
  23. </view>
  24. </view>
  25. </uni-popup>
  26. </template>
  27. <script setup lang="ts">
  28. import { computed, ref, onMounted } from 'vue'
  29. import { newsApi } from '@/service/news'
  30. import { useI18n } from "vue-i18n";
  31. const { locale } = useI18n();
  32. import useRouter from "@/hooks/useRouter";
  33. const router = useRouter();
  34. const popupRef = ref<any>(null)
  35. const list = ref([])
  36. const getList = async () => {
  37. const res = await newsApi.newsNoticeList({
  38. page: { current: 1, row: 10 },
  39. lang: locale.value
  40. })
  41. if (res.data && res.code == 200) {
  42. list.value = res.data
  43. } else {
  44. list.value = []
  45. }
  46. }
  47. function open() {
  48. popupRef.value?.open()
  49. getList()
  50. }
  51. function close() {
  52. popupRef.value?.close()
  53. }
  54. const goPages = (e) => {
  55. router.push({
  56. path: '/pages/analytics/detail',
  57. query: {
  58. id: e.id,
  59. type: 7
  60. }
  61. })
  62. close()
  63. }
  64. const goMore = () => {
  65. router.push({
  66. path: '/pages/common/notice'
  67. })
  68. close()
  69. }
  70. function handleLogout() {
  71. close()
  72. }
  73. defineExpose({
  74. open,
  75. close
  76. })
  77. </script>
  78. <style scoped lang="scss">
  79. @import "@/uni.scss";
  80. .right-drawer {
  81. width: 300px;
  82. height: 100vh;
  83. display: flex;
  84. flex-direction: column;
  85. padding: 20px 16px;
  86. }
  87. .notification-list {
  88. width: 100%;
  89. flex: 1;
  90. overflow-y: auto;
  91. }
  92. .drawer-empty-state {
  93. flex: 1;
  94. min-height: px2rpx(240);
  95. }
  96. .notification-item {
  97. display: flex;
  98. align-items: center;
  99. justify-content: space-between;
  100. padding: px2rpx(12) px2rpx(16);
  101. border-bottom: 1px solid var(--bs-border-color);
  102. cursor: pointer;
  103. .item-content {
  104. flex: 1;
  105. .item-title {
  106. font-size: px2rpx(14);
  107. color: var(--bs-heading-color);
  108. line-height: 1.4;
  109. margin-bottom: px2rpx(4);
  110. }
  111. .item-time {
  112. font-size: px2rpx(12);
  113. color: var(--bs-heading-color);
  114. }
  115. }
  116. .item-badge {
  117. margin-left: px2rpx(12);
  118. .dot {
  119. width: px2rpx(8);
  120. height: px2rpx(8);
  121. background-color: #f56c6c;
  122. border-radius: 50%;
  123. }
  124. }
  125. }
  126. .logout-wrap {
  127. margin-top: auto;
  128. padding: 20px 16px;
  129. margin-bottom: 20px;
  130. }
  131. .logout-btn {
  132. height: 44px;
  133. background: #f4eadf;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. gap: 8px;
  138. color: #fff;
  139. font-weight: 600;
  140. cursor: pointer;
  141. }
  142. </style>