header.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div>
  3. <!-- <img src="../../assets/images/logoHeader.png" /> -->
  4. <img src="../../assets/images/headLogo.jpg" />
  5. <span>云融</span>
  6. <!-- <span>深圳市多元世纪信息技术股份有限公司</span> -->
  7. </div>
  8. <div class="m-layout-header-right">
  9. <div @click="openDrawer">
  10. <span>{{ getUserName() }},您好!</span>
  11. </div>
  12. <div class="relative">
  13. <!-- <a-input-search ref="userNameInput"
  14. class="searchInput"
  15. readonly
  16. placeholder="请输入代码/名称"
  17. @pressEnter="search">
  18. </a-input-search>-->
  19. <!-- <a-icon type="search" /> -->
  20. </div>
  21. <div class="news-container">
  22. <a-badge @click="openNotice" :dot="getUnReadNoticeLength() > 0">
  23. <svg class="icon svg-icon" aria-hidden="true">
  24. <use xlink:href="#icon-xiaoxi" />
  25. </svg>
  26. </a-badge>
  27. </div>
  28. <div>
  29. <a-popover v-model:visible="visible" trigger="click" placement="bottomRight">
  30. <template #content>
  31. <div
  32. v-for="item in setMenu"
  33. @click="chooseSetMenu(item.path)"
  34. :key="item.path"
  35. >{{ item.name }}</div>
  36. </template>
  37. <a-avatar :size="24">
  38. <template #icon>
  39. <!-- <SettingFilled /> -->
  40. <svg class="icon svg-icon" aria-hidden="true">
  41. <use xlink:href="#icon-yonghu4" />
  42. </svg>
  43. </template>
  44. </a-avatar>
  45. </a-popover>
  46. <Setting />
  47. </div>
  48. </div>
  49. </template>
  50. <script lang="ts">
  51. import { defineComponent, ref, provide } from 'vue';
  52. import { openModal } from '@/common/setup/modal/index';
  53. import { UserOutlined } from '@ant-design/icons-vue';
  54. import Setting from '@/views/setting/index.vue';
  55. import { getUserName } from '@/services/bus/user';
  56. import { logout } from '@/services/bus/login';
  57. import APP from '@/services';
  58. import Router from '@/router';
  59. import { handleNotice } from '@/views/setting/notice/setup';
  60. // 设置
  61. const setFn = () => {
  62. const visible = ref<boolean>(false);
  63. const chooseSetupItem = ref<string>('');
  64. provide('ControlModal', chooseSetupItem);
  65. const setMenu = [
  66. // { name: '修改密码', path: 'password' },
  67. // { name: '收货地址', path: 'addresss' },
  68. // // {name: '发票', path: 'setup-password'},
  69. // { name: '手机号码绑定/解绑', path: 'phone' },
  70. // { name: '关于我们', path: 'aboutUs' },
  71. { name: '退出', path: 'logout' },
  72. ];
  73. const { openAction } = openModal('logout');
  74. function chooseSetMenu(path: string) {
  75. if (path === 'logout') {
  76. logout();
  77. APP.closeServer();
  78. Router.replace('/login');
  79. } else {
  80. openAction();
  81. }
  82. visible.value = false;
  83. }
  84. return { visible, setMenu, chooseSetMenu };
  85. };
  86. // 搜索
  87. const onSearch = () => {
  88. function search(value: string) {}
  89. return { search };
  90. };
  91. export default defineComponent({
  92. components: {
  93. UserOutlined,
  94. Setting,
  95. },
  96. props: {
  97. collapsed: {
  98. default: true,
  99. type: Boolean,
  100. },
  101. },
  102. setup() {
  103. const { openAction: openNotice } = openModal('notice');
  104. const { getUnReadNoticeLength } = handleNotice();
  105. return {
  106. openNotice,
  107. getUserName,
  108. getUnReadNoticeLength,
  109. ...setFn(),
  110. ...onSearch(),
  111. };
  112. },
  113. });
  114. </script>