|
|
@@ -1,45 +1,53 @@
|
|
|
<template>
|
|
|
- <uni-popup ref="popupRef" type="right" background-color="#f5f5f5">
|
|
|
- <view class="right-drawer">
|
|
|
- <view class="drawer-header">
|
|
|
- <image class="avatar" src="/static/logo.png" mode="aspectFill" />
|
|
|
- <view class="user-info">
|
|
|
- <text class="name">{{ displayName }}</text>
|
|
|
- <text class="cid">CID: {{ displayCid }}</text>
|
|
|
- </view>
|
|
|
+ <view class="notice-container">
|
|
|
+ <cwg-dropdown ref="dropdownRef" :menu-list="[]">
|
|
|
+ <view class="pc-header-btn">
|
|
|
+ <cwg-icon name="icon_my" color="#141d22" @click="openNotice" />
|
|
|
</view>
|
|
|
-
|
|
|
- <view class="menu-list">
|
|
|
- <view v-for="item in menuList" :key="item.key" class="menu-item"
|
|
|
- :class="{ active: activePath === item.path }" @click="handleNavigate(item.path)">
|
|
|
- <cwg-icon :name="item.icon" :size="16" :color="activePath === item.path ? '#fff' : '#0f172b'" />
|
|
|
- <text>{{ item.name }}</text>
|
|
|
+ <template #btn>
|
|
|
+ <view class="right-drawer">
|
|
|
+ <view class="drawer-header">
|
|
|
+ <image class="avatar" src="/static/images/avatars.png" mode="aspectFill" />
|
|
|
+ <view class="user-info">
|
|
|
+ <text class="name">{{ displayName }}</text>
|
|
|
+ <text class="cid">CID: {{ displayCid }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="menu-list">
|
|
|
+ <view v-for="item in menuList" :key="item.key" class="menu-item"
|
|
|
+ :class="{ active: activePath === item.path }" @click="handleNavigate(item.path)">
|
|
|
+ <cwg-icon :name="item.icon" :size="16"
|
|
|
+ :color="activePath === item.path ? '#0f172b' : '#0f172b'" />
|
|
|
+ <text>{{ item.name }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="logout-wrap">
|
|
|
+ <view class="logout-btn" @click="handleLogout">
|
|
|
+ <cwg-icon name="logout" :size="16" color="#ff9800" />
|
|
|
+ <text>Logout</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
- <view class="logout-wrap">
|
|
|
- <view class="logout-btn" @click="handleLogout">
|
|
|
- <cwg-icon name="logout" :size="16" color="#ff9800" />
|
|
|
- <text>Logout</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </uni-popup>
|
|
|
+ </template>
|
|
|
+ </cwg-dropdown>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { computed, ref } from 'vue'
|
|
|
import useRoute from '@/hooks/useRoute'
|
|
|
import useUserStore from '@/stores/use-user-store'
|
|
|
+import { userApi } from '@/api/user'
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
const { t } = useI18n();
|
|
|
-const emit = defineEmits<{
|
|
|
- (e: 'navigate', path: string): void
|
|
|
- (e: 'logout'): void
|
|
|
-}>()
|
|
|
-
|
|
|
-const popupRef = ref<any>(null)
|
|
|
+import useRouter from "@/hooks/useRouter";
|
|
|
+const router = useRouter();
|
|
|
+const dropdownRef = ref(null)
|
|
|
const userStore = useUserStore()
|
|
|
-const userInfo = computed<any>(() => userStore.userInfo || {})
|
|
|
+const userInfo = computed<any>(() => userStore.userInfo?.customInfo || {})
|
|
|
+
|
|
|
+
|
|
|
const route = useRoute()
|
|
|
const menuList = computed(() => [
|
|
|
{
|
|
|
@@ -64,21 +72,28 @@ const displayName = computed(() => {
|
|
|
const displayCid = computed(() => userInfo.value?.cId || userInfo.value?.id || '--')
|
|
|
const activePath = computed(() => route.path + (route.query?.type ? `?type=${route.query.type}` : '') || '')
|
|
|
|
|
|
-function open() {
|
|
|
- popupRef.value?.open()
|
|
|
-}
|
|
|
|
|
|
function close() {
|
|
|
- popupRef.value?.close()
|
|
|
+ dropdownRef.value?.close()
|
|
|
+ console.log(userInfo, 1212);
|
|
|
}
|
|
|
|
|
|
function handleNavigate(path: string) {
|
|
|
- emit('navigate', path)
|
|
|
+ router.push({ path })
|
|
|
close()
|
|
|
}
|
|
|
|
|
|
-function handleLogout() {
|
|
|
- emit('logout')
|
|
|
+async function handleLogout() {
|
|
|
+ try {
|
|
|
+ const res = await userApi.logout()
|
|
|
+ if (res.code === 200) {
|
|
|
+ userStore.clearUserInfo()
|
|
|
+ router.push('/pages/login/index')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ userStore.clearUserInfo()
|
|
|
+ router.push('/pages/login/index')
|
|
|
+ }
|
|
|
close()
|
|
|
}
|
|
|
|
|
|
@@ -91,81 +106,103 @@ defineExpose({
|
|
|
<style scoped lang="scss">
|
|
|
@import "@/uni.scss";
|
|
|
|
|
|
-.right-drawer {
|
|
|
- width: 300px;
|
|
|
- height: 100vh;
|
|
|
- background: #f5f5f5;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- padding: 20px 16px;
|
|
|
-}
|
|
|
+.notice-container {
|
|
|
+ :deep(.cwg-dropdown-menu-container) {
|
|
|
+ left: px2rpx(-280) !important;
|
|
|
+ right: px2rpx(0) !important;
|
|
|
+ }
|
|
|
|
|
|
-.drawer-header {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- gap: 12px;
|
|
|
- padding: 20px 16px;
|
|
|
- border-bottom: 1px solid #d9dde5;
|
|
|
-}
|
|
|
+ @media screen and (max-width: 991px) {
|
|
|
+ :deep(.cwg-dropdown-menu-container) {
|
|
|
+ left: px2rpx(-270) !important;
|
|
|
+ max-width: px2rpx(400);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-.avatar {
|
|
|
- width: 76px;
|
|
|
- height: 76px;
|
|
|
- border-radius: 12px;
|
|
|
- background: #fff;
|
|
|
-}
|
|
|
+ .pc-header-btn {
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
|
|
|
-.user-info {
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- gap: 6px;
|
|
|
-}
|
|
|
+ .right-drawer {
|
|
|
+ width: px2rpx(300);
|
|
|
+ background-color: var(--color-white);
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ padding: 20px 16px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
|
|
|
-.name {
|
|
|
- font-size: 20px;
|
|
|
- font-weight: 600;
|
|
|
- color: #334155;
|
|
|
-}
|
|
|
+ .drawer-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 12px;
|
|
|
+ padding: 20px 16px;
|
|
|
+ border-bottom: 1px solid #d9dde5;
|
|
|
+ }
|
|
|
|
|
|
-.cid {
|
|
|
- font-size: 14px;
|
|
|
- color: #ef4444;
|
|
|
-}
|
|
|
+ .avatar {
|
|
|
+ width: 76px;
|
|
|
+ height: 76px;
|
|
|
+ border-radius: 12px;
|
|
|
+ background: #fff;
|
|
|
+ }
|
|
|
|
|
|
-.menu-list {
|
|
|
- padding: 12px 0;
|
|
|
-}
|
|
|
+ .user-info {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 6px;
|
|
|
+ }
|
|
|
|
|
|
-.menu-item {
|
|
|
- height: 48px;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- gap: 10px;
|
|
|
- padding: 0 16px;
|
|
|
- color: #0f172b;
|
|
|
- font-size: 16px;
|
|
|
- font-weight: 600;
|
|
|
-}
|
|
|
+ .name {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #334155;
|
|
|
+ }
|
|
|
|
|
|
-.menu-item.active {
|
|
|
- background: #ea2027;
|
|
|
- color: #fff;
|
|
|
-}
|
|
|
+ .cid {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #ef4444;
|
|
|
+ }
|
|
|
|
|
|
-.logout-wrap {
|
|
|
- margin-top: auto;
|
|
|
- padding: 20px 16px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
+ .menu-list {
|
|
|
+ padding: 12px 0;
|
|
|
+ }
|
|
|
|
|
|
-.logout-btn {
|
|
|
- height: 44px;
|
|
|
- background: #f4eadf;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- gap: 8px;
|
|
|
- color: #ff9800;
|
|
|
- font-weight: 600;
|
|
|
+ .menu-item {
|
|
|
+ height: 48px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+ padding: 0 16px;
|
|
|
+ color: #0f172b;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 600;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background-color: rgba(0, 0, 0, 0.05);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .menu-item.active {
|
|
|
+ background: rgba(108, 133, 149, 0.12) !important;
|
|
|
+ border-radius: 0.125rem;
|
|
|
+ }
|
|
|
+
|
|
|
+ .logout-wrap {
|
|
|
+ margin-top: auto;
|
|
|
+ padding: 20px 16px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .logout-btn {
|
|
|
+ height: 44px;
|
|
|
+ background: #f4eadf;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ gap: 8px;
|
|
|
+ color: #ff9800;
|
|
|
+ font-weight: 600;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|