cwg-notice-drawer.vue 3.3 KB

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