cwg-notice.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. const isRed = ref(false)
  12. function openNotice() {
  13. uni.$emit('open-notice-drawer')
  14. }
  15. const getData = async () => {
  16. const res = await newsApi.newsNoticeRead({
  17. read: 0
  18. })
  19. if (res.data && res.code == 200) {
  20. isRed.value = true
  21. } else {
  22. isRed.value = false
  23. }
  24. }
  25. onMounted(() => {
  26. getData()
  27. })
  28. </script>
  29. <style scoped lang="scss">
  30. @import "@/uni.scss";
  31. .pc-header-btn {
  32. position: relative;
  33. &::after {
  34. content: '';
  35. position: absolute;
  36. top: px2rpx(4);
  37. right: px2rpx(4);
  38. width: px2rpx(8);
  39. height: px2rpx(8);
  40. background-color: #f56c6c;
  41. border-radius: 50%;
  42. }
  43. &.has-dot::after {
  44. display: block;
  45. }
  46. }
  47. </style>