index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!-- @format -->
  2. <script setup lang="ts">
  3. import { useUserStore } from '@/stores/modules/user'
  4. import { useCommonStore } from '@/stores/modules/common'
  5. const commonStore = useCommonStore()
  6. const userStore = useUserStore()
  7. const { isLogin } = storeToRefs(userStore)
  8. const { noticeRemind } = storeToRefs(commonStore)
  9. const hoverStatus = ref<any>()
  10. const { openLoginModal } = useLoginModal()
  11. commonStore.getNoticeRemind()
  12. // const { locale, setLocale } = useI18nLocale()
  13. // function handleClick({ key }: any) {
  14. // setLocale(key)
  15. // }
  16. async function clickLogin() {
  17. try {
  18. const { status } = await openLoginModal()
  19. if (status)
  20. location.reload()
  21. }
  22. catch (error) {
  23. console.log(error)
  24. }
  25. }
  26. async function onSelected(command: string | number | object) {
  27. if (command === 'signOut') {
  28. // 退出登录
  29. try {
  30. userStore.logout()
  31. }
  32. catch (error) {
  33. console.log(error, 'error')
  34. }
  35. }
  36. }
  37. </script>
  38. <template>
  39. <div>
  40. <div v-if="!isLogin">
  41. <el-button
  42. class="b-solid b-1px b-#AB7045 custom-btn-login !text-#AB7045 !w-100px !h-34px !text-16px !b-rd-150px"
  43. @mouseover="hoverStatus = '!fill-#fff'" @mouseleave="hoverStatus = '!fill-#CC9879'" @click="clickLogin"
  44. >
  45. <template #icon>
  46. <svgo-user :class="hoverStatus" class="w-24px h-24px" :filled="true" />
  47. </template> Log In
  48. </el-button>
  49. </div>
  50. <div v-else>
  51. <el-dropdown :hide-on-click="false" placement="bottom-end" popper-class="custom-dropdown" @command="onSelected">
  52. <template #default>
  53. <svgo-user class="!w-30px !h-30px !fill-#5B463E" :filled="true" />
  54. </template>
  55. <template #dropdown>
  56. <div class="flex items-center ">
  57. <svgo-user-avatar class="!w-20px !h-20px" />
  58. <span class="text-20px fw-500 text-#333 ml-20px">
  59. {{ userStore.userInfo.firstName }}
  60. {{ userStore.userInfo.lastName }}
  61. </span>
  62. </div>
  63. <div class="text-16px text-#999 mt-10px">
  64. {{ userStore.userInfo.email }}
  65. </div>
  66. <!-- <div class="w-full bg-#D8D8D8 h-1px my-20px" />
  67. <div class="text-16px text-#333">
  68. Unlock <span class="text-#AB7045">$ 8000</span> Buy Now Pay Later Limit (60 day terms)
  69. </div> -->
  70. <div class="w-full bg-#D8D8D8 h-1px my-20px" />
  71. <el-dropdown-menu>
  72. <el-dropdown-item command="dashboard">
  73. <NuxtLink to="/account/panel" class="flex items-center text-16px">
  74. <svgo-dashboard class="!w-22px !h-22px mr-16px" /> Dashboard
  75. </NuxtLink>
  76. </el-dropdown-item>
  77. <el-dropdown-item command="message">
  78. <NuxtLink to="/account/rfqs" class="flex items-center text-16px">
  79. <svgo-rfqs class="!w-20px !h-20px mr-18px" />
  80. RFQS
  81. </NuxtLink>
  82. </el-dropdown-item>
  83. <el-dropdown-item command="favorites">
  84. <NuxtLink to="/account/favourites?tab=products" class="flex items-center text-16px">
  85. <svgo-favorite class="!w-22px !h-22px mr-16px" />
  86. Favourites
  87. </NuxtLink>
  88. </el-dropdown-item>
  89. <el-dropdown-item command="orders">
  90. <NuxtLink to="/account/orders?tab=submitted" class="flex items-center text-16px">
  91. <svgo-order class="!w-22px !h-22px mr-16px" />
  92. Orders
  93. </NuxtLink>
  94. </el-dropdown-item>
  95. <!-- <el-dropdown-item command="message">
  96. <NuxtLink to="/account/messages" class="flex items-center text-16px">
  97. <svgo-message class="!w-22px !h-22px mr-16px" />
  98. Messages
  99. </NuxtLink>
  100. </el-dropdown-item> -->
  101. <el-dropdown-item command="message">
  102. <NuxtLink to="/account/notice" class="flex items-center text-16px pos-relative">
  103. <svgo-notice class="!w-22px !h-22px mr-16px" />
  104. <div v-if="noticeRemind" class="pos-absolute top-0 left-20px bg-primary w-5px h-5px b-rd-50%" />
  105. Notice
  106. </NuxtLink>
  107. </el-dropdown-item>
  108. <el-dropdown-item command="setting">
  109. <NuxtLink to="/account/settings?tab=profile" class="flex items-center text-16px">
  110. <svgo-setting class="!w-22px !h-22px mr-16px" />
  111. Settings
  112. </NuxtLink>
  113. </el-dropdown-item>
  114. <div class="w-full bg-#D8D8D8 h-1px mb-20px" />
  115. <el-dropdown-item command="signOut">
  116. <div class=" flex items-center text-16px">
  117. <svgo-logout class="!w-22px !h-22px mr-16px" />
  118. Sign out
  119. </div>
  120. </el-dropdown-item>
  121. </el-dropdown-menu>
  122. </template>
  123. </el-dropdown>
  124. </div>
  125. </div>
  126. </template>
  127. <style lang="less">
  128. .custom-btn-login {
  129. .el-icon{
  130. font-size: 24px;
  131. }
  132. }
  133. .custom-dropdown {
  134. &.el-dropdown__popper{
  135. border-radius: 10px;
  136. .el-scrollbar{
  137. .el-dropdown__list{
  138. width: 415px;
  139. padding: 30px!important;
  140. }
  141. .el-dropdown-menu {
  142. .el-dropdown-menu__item{
  143. padding-bottom: 20px;
  144. padding-left: 0 !important;
  145. padding-right: 0 !important;
  146. padding-top: 0 !important;
  147. &:last-child{
  148. padding-bottom: 0;
  149. }
  150. }}
  151. }}
  152. }
  153. </style>