Files
Aida_Purchaser_Front/src/views/main-header.vue

291 lines
6.3 KiB
Vue
Raw Normal View History

2026-04-20 11:21:21 +08:00
<template>
<div class="main-header" id="main-header">
<div class="left">
2026-04-20 11:34:54 +08:00
<img class="logo" src="@/assets/images/logo.png" @click="onNavItemClick('/')" />
2026-04-20 11:21:21 +08:00
</div>
<div class="center">
<div
v-for="v in navList1"
:key="v.path"
class="nav-item"
2026-05-12 13:32:47 +08:00
:class="{
active: v.path === '/' ? activePath === v.path : new RegExp(`^${v.path}`).test(activePath)
}"
2026-04-20 11:21:21 +08:00
@click="onNavItemClick(v.path)"
>
<span>{{ v.name }}</span>
</div>
</div>
<div class="right">
<div
class="icon"
v-for="v in navList2"
:key="v.path"
2026-05-12 13:32:47 +08:00
:class="{ active: new RegExp(`^${v.path}`).test(activePath) }"
2026-04-20 11:21:21 +08:00
@click="onNavItemClick(v.path)"
>
<svg-icon :name="activePath === v.path ? v.active_icon : v.icon" size="22" />
</div>
2026-04-21 15:57:59 +08:00
<div class="login" @click="onLogin">Login</div>
<el-popover
ref="profilePopover"
placement="bottom-end"
trigger="click"
:show-arrow="false"
popper-style="width: 24rem; padding: 0; border-radius: 0; right: 2rem; top: 10rem;"
>
<template #reference><div class="profile"></div></template>
<template #default>
<div class="profile-content">
<div class="info">
<img src="@/assets/images/profile-content-bg.jpg" alt="" />
<div class="content">
<div class="profile"></div>
<div class="name">Hi, Alexandra_chen</div>
</div>
</div>
<div class="nav-item" @click="onMyWardrobe">
<div class="icon"><svg-icon name="my_wardrobe" size="18" /></div>
<div class="label">My Wardrobe</div>
</div>
<div class="nav-item" @click="onNotifications">
<div class="icon"><svg-icon name="notifications" size="14" /></div>
<div class="label">Notifications</div>
</div>
<div class="nav-item" @click="onSettings">
<div class="icon"><svg-icon name="settings" size="16" /></div>
<div class="label">Settings</div>
</div>
<div class="hr"></div>
<div class="nav-item logout" @click="onLogout">
<div class="icon"><svg-icon name="logout" size="20" /></div>
<div class="label">Log off</div>
</div>
</div>
</template>
</el-popover>
2026-05-11 13:56:10 +08:00
<div class="language" @click="onLanguageClick">
<span :class="{ active: locale === 'CHINESE_SIMPLIFIED' }"></span> /
<span :class="{ active: locale === 'ENGLISH' }">ENG</span>
</div>
2026-04-20 11:21:21 +08:00
</div>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
2026-04-21 15:57:59 +08:00
import myEvent from '@/utils/myEvent'
2026-05-11 13:56:10 +08:00
import { useI18n } from 'vue-i18n'
const { t, locale } = useI18n()
2026-04-20 11:21:21 +08:00
const router = useRouter()
const route = useRoute()
const activePath = computed(() => route.path)
const navList1 = ref([
{
name: 'Home',
path: '/'
},
{
name: 'Collection Story',
2026-04-20 14:28:13 +08:00
path: '/collectionStory'
2026-04-20 11:21:21 +08:00
},
{
name: 'Brand',
path: '/brand'
},
{
name: 'Digital Item',
2026-04-20 14:28:13 +08:00
path: '/digitalItem'
2026-04-20 11:21:21 +08:00
}
])
const navList2 = ref([
{
icon: 'cart_0',
active_icon: 'cart_1',
2026-04-23 11:48:22 +08:00
path: '/shoppingCart'
2026-04-20 11:21:21 +08:00
},
{
icon: 'user_0',
active_icon: 'user_1',
2026-05-04 15:53:13 +08:00
path: '/account'
2026-04-20 11:21:21 +08:00
}
])
const onNavItemClick = (path: string) => {
if (path === activePath.value) return
router.push(path)
}
2026-04-21 15:57:59 +08:00
const onLogin = () => {
myEvent.emit('openLoginDialog')
}
const profilePopover = ref(null)
const hideProfilePopover = () => {
profilePopover.value?.hide()
}
const onMyWardrobe = () => {
hideProfilePopover()
console.log('my wardrobe')
2026-04-23 15:20:22 +08:00
router.push('/wardrobe')
2026-04-21 15:57:59 +08:00
}
const onNotifications = () => {
hideProfilePopover()
2026-04-23 09:39:12 +08:00
router.push('/notifications')
2026-04-21 15:57:59 +08:00
}
const onSettings = () => {
hideProfilePopover()
2026-04-22 16:11:16 +08:00
router.push('/settings')
2026-04-21 15:57:59 +08:00
}
const onLogout = () => {
hideProfilePopover()
console.log('logout')
}
2026-05-11 13:56:10 +08:00
const onLanguageClick = () => {
locale.value = locale.value === 'ENGLISH' ? 'CHINESE_SIMPLIFIED' : 'ENGLISH'
localStorage.setItem('language', locale.value)
}
2026-04-20 11:21:21 +08:00
</script>
2026-04-23 11:48:22 +08:00
<style lang="less" scoped>
2026-04-20 11:21:21 +08:00
#main-header {
2026-04-21 15:57:37 +08:00
height: var(--header-height);
2026-04-20 11:21:21 +08:00
display: flex;
align-items: center;
justify-content: space-between;
position: relative;
background: #ffffff;
padding: 0 9rem;
border-bottom: 0.1rem solid #c4c4c4;
2026-04-20 11:28:05 +08:00
user-select: none;
2026-04-20 11:21:21 +08:00
> .left {
> .logo {
width: auto;
height: 4rem;
}
}
> .right {
2026-04-20 11:28:05 +08:00
> * {
cursor: pointer;
}
2026-04-20 11:21:21 +08:00
> .icon {
width: 2.4rem;
height: 2.4rem;
2026-04-20 11:28:05 +08:00
}
> .login {
font-size: 1.6rem;
2026-04-20 11:21:21 +08:00
}
> .profile {
width: 4rem;
height: 4rem;
border-radius: 50%;
background: #f5f5f5;
}
2026-05-11 13:56:10 +08:00
> .language {
font-family: KaiseiOpti-Regular;
font-size: 1.6rem;
color: #c2c2c2;
> .active {
color: #232323;
font-family: KaiseiOpti-Medium;
}
}
2026-04-20 11:21:21 +08:00
}
> .center,
> .right {
display: flex;
align-items: center;
justify-content: center;
gap: 2.6rem;
}
> .center {
position: absolute;
height: 80%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
> .nav-item {
height: 100%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
> span {
padding: 0 1rem;
line-height: 2.4rem;
font-size: 1.6rem;
color: #232323;
border-bottom: 0.1rem solid transparent;
}
&.active {
> span {
border-bottom-color: #232323;
font-weight: 700;
}
}
}
}
}
2026-04-21 15:57:59 +08:00
.profile-content {
width: 100%;
> .info {
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 2rem;
> img {
width: 100%;
height: auto;
}
> .content {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1rem;
> .profile {
width: 5rem;
height: 5rem;
border-radius: 50%;
background: #cfcfcf;
}
> .name {
font-size: 1.4rem;
color: #232323;
}
}
}
> .hr {
margin: 1.2rem 1rem;
border-top: 0.1rem solid #c4c4c4;
}
> .nav-item {
margin-left: 2rem;
margin-bottom: 1.2rem;
display: flex;
align-items: center;
height: 2rem;
user-select: none;
cursor: pointer;
> .icon {
width: 2rem;
height: 2rem;
margin-right: 1rem;
}
> .label {
font-family: KaiseiOpti-Regular;
font-size: 1.2rem;
color: #585858;
}
}
> .logout {
> .label {
font-family: KaiseiOpti-Medium;
font-size: 1.4rem;
color: #232323;
}
}
}
2026-04-20 11:21:21 +08:00
</style>