top-window.vue 2.9 KB

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