top-window.vue 2.9 KB

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