cwg-notice.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <view class="pc-header-btn" :class="{ 'has-dot': isRed }">
  3. <cwg-icon name="xxtz" color="#141d22" @click="openNotice" />
  4. </view>
  5. </template>
  6. <script setup lang="ts">
  7. import { ref, onMounted } from 'vue'
  8. import { useI18n } from 'vue-i18n'
  9. const { t, locale } = useI18n()
  10. import { newsApi } from '@/service/news'
  11. import { userToken } from "@/composables/config";
  12. const isRed = ref(false)
  13. function openNotice() {
  14. uni.$emit('open-notice-drawer')
  15. }
  16. const getData = async () => {
  17. const res = await newsApi.newsNoticeRead({
  18. read: 0
  19. })
  20. if (res.data && res.code == 200) {
  21. isRed.value = true
  22. } else {
  23. isRed.value = false
  24. }
  25. }
  26. onMounted(() => {
  27. if (!userToken.value) return
  28. getData()
  29. })
  30. </script>
  31. <style scoped lang="scss">
  32. @import "@/uni.scss";
  33. .pc-header-btn {
  34. position: relative;
  35. &::after {
  36. content: '';
  37. position: absolute;
  38. top: px2rpx(4);
  39. right: px2rpx(4);
  40. width: px2rpx(8);
  41. height: px2rpx(8);
  42. background-color: #f56c6c;
  43. border-radius: 50%;
  44. }
  45. &.has-dot::after {
  46. display: block;
  47. }
  48. }
  49. </style>