top-window.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <header class="cwg-pc-header bg-body" :class="{ 'dark': isDark }">
  3. <div class="left">
  4. <image class="left-img" v-if="!isDark" src="/static/images/vu/logo-full.svg" mode="widthFix" alt="logo"
  5. @click="openLeftDrawer" />
  6. <image class="left-img" v-else src="/static/images/vu/logo-full-white.svg" mode="widthFix" alt="logo"
  7. @click="openLeftDrawer" />
  8. <div class="cid cursor-pointer" v-if="visible" @click="copy(cId)" :data-tooltip="`${t('vu.tooltip.t2')}-${cId}`">{{t('newSignin.item1')}} {{name?(name + ' - '):''}}{{ cId}}</div>
  9. </div>
  10. <div class="right" v-if="visible">
  11. <cwg-payment />
  12. <cwg-download />
  13. <cwg-system event-source="top"/>
  14. <cwg-language />
  15. <cwg-notice />
  16. <cwg-right-drawer />
  17. <cwg-logout />
  18. </div>
  19. </header>
  20. </template>
  21. <script setup lang="ts">
  22. import { ref, computed, watch, onMounted } from 'vue'
  23. import { storeToRefs } from 'pinia'
  24. import useUserStore from '@/stores/use-user-store'
  25. import { useI18n } from 'vue-i18n'
  26. const userStore = useUserStore()
  27. const { userInfo } = storeToRefs(userStore)
  28. import useGlobalStore from '@/stores/use-global-store'
  29. const globalStore = useGlobalStore()
  30. const isDark = computed(() => globalStore.theme === 'dark')
  31. const visible = ref(true)
  32. const { t } = useI18n()
  33. watch(() => userInfo.value, (val) => {
  34. visible.value = !!val
  35. })
  36. const props = defineProps({
  37. sidebarVisible: {
  38. type: Boolean,
  39. default: false,
  40. },
  41. })
  42. const cId = computed(() => {
  43. const info = userStore.userInfo?.customInfo || {}
  44. return info.cId || info.id || '--'
  45. })
  46. const name = computed(() => {
  47. const info = userStore.userInfo?.customInfo || {}
  48. const firstName = info.firstName || ''
  49. const lastName = info.lastName || ''
  50. return (firstName + ' ' + lastName).trim() || info.name
  51. })
  52. onMounted(()=>{
  53. uni.$emit('updateSystemList','top')
  54. })
  55. // 复制文本
  56. const copy = (text: string) => {
  57. uni.setClipboardData({
  58. data: text,
  59. success: function () {
  60. uni.showToast({
  61. title: t('Btn.item8'),
  62. icon: 'none',
  63. duration: 2000
  64. });
  65. }
  66. });
  67. };
  68. </script>
  69. <style scoped lang="scss">
  70. @import "@/uni.scss";
  71. .cwg-pc-header {
  72. display: flex;
  73. align-items: center;
  74. justify-content: space-between;
  75. height: px2rpx(55);
  76. border-bottom: 1px solid var(--bs-border-color);
  77. padding: 0 px2rpx(16);
  78. position: relative;
  79. z-index: 10;
  80. }
  81. .left {
  82. display: flex;
  83. align-items: center;
  84. .cid{
  85. margin-left: px2rpx(50);
  86. cursor: pointer;
  87. }
  88. }
  89. .center {
  90. flex: 1;
  91. }
  92. .right {
  93. display: flex;
  94. align-items: center;
  95. gap: 0;
  96. }
  97. .bell .dot {
  98. position: absolute;
  99. top: 0;
  100. right: -2px;
  101. width: 7px;
  102. height: 7px;
  103. background: #27ae60;
  104. border-radius: 50%;
  105. display: inline-block;
  106. }
  107. .left-img {
  108. width: px2rpx(120);
  109. }
  110. .avatar .img {
  111. width: 32px;
  112. height: 32px;
  113. border-radius: 50%;
  114. background: #eee;
  115. }
  116. .logo .img {
  117. width: 36px;
  118. height: 36px;
  119. border-radius: 50%;
  120. background: #fff;
  121. }
  122. </style>