| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <template>
- <view class="container">
- <view class="header">
- <!-- 语言切换按钮 -->
- <view class="language-switcher" @click="switchLanguage">
- <text class="language-icon">🌐</text>
- <text class="language-text">{{ currentLanguageName }}</text>
- </view>
-
- <view class="avatar">
- <image class="avatar-img" src="/static/default-avatar.png" mode="aspectFill"></image>
- </view>
- <text class="username">{{ userStore.nickname }}</text>
- </view>
-
- <view class="content">
- <view class="menu-list">
- <view class="menu-item" @click="handleMenuClick('profile')">
- <text class="menu-icon">👤</text>
- <text class="menu-text">{{ $t('mine.profile') }}</text>
- <text class="menu-arrow">›</text>
- </view>
-
- <view class="menu-item" @click="handleMenuClick('settings')">
- <text class="menu-icon">⚙️</text>
- <text class="menu-text">{{ $t('mine.settings') }}</text>
- <text class="menu-arrow">›</text>
- </view>
-
- <view class="menu-item" @click="handleMenuClick('about')">
- <text class="menu-icon">ℹ️</text>
- <text class="menu-text">{{ $t('mine.about') }}</text>
- <text class="menu-arrow">›</text>
- </view>
- </view>
-
- <view class="logout-section">
- <button class="logout-btn" @click="handleLogout">
- {{ $t('mine.logout') }}
- </button>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import { computed, watch } from 'vue'
- import { onShow } from '@dcloudio/uni-app'
- import { useI18n } from 'vue-i18n'
- import { useUserStore } from '@/store/index'
- import { useLocaleStore } from '@/store/locale'
- const { t, locale } = useI18n()
- const userStore = useUserStore()
- const localeStore = useLocaleStore()
- // 当前语言名称
- const currentLanguageName = computed(() => {
- return localeStore.getCurrentLocaleName()
- })
- // 设置页面标题
- const setPageTitle = () => {
- uni.setNavigationBarTitle({
- title: t('mine.title')
- })
- }
- // 页面显示时设置标题
- onShow(() => {
- setPageTitle()
- })
- // 监听语言变化,更新标题
- watch(locale, () => {
- setPageTitle()
- })
- // 切换语言
- const switchLanguage = () => {
- localeStore.toggleLocale()
- uni.showToast({
- title: t('common.language.switchSuccess'),
- icon: 'success',
- duration: 1500
- })
- }
- // 菜单点击
- const handleMenuClick = (type) => {
- uni.showToast({
- title: `${t('mine.' + type)}`,
- icon: 'none'
- })
- }
- // 退出登录
- const handleLogout = () => {
- uni.showModal({
- title: t('mine.confirmLogout'),
- content: t('mine.logoutMessage'),
- success: (res) => {
- if (res.confirm) {
- // 清除用户信息
- userStore.logout()
-
- uni.showToast({
- title: t('mine.logoutSuccess'),
- icon: 'success',
- duration: 1500
- })
-
- // 跳转到登录页
- setTimeout(() => {
- uni.reLaunch({
- url: '/pages/login/login'
- })
- }, 1500)
- }
- }
- })
- }
- </script>
- <style lang="scss" scoped>
- .container {
- min-height: 100vh;
- background-color: #f8f8f8;
- }
- .header {
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- padding: 60rpx 40rpx 80rpx;
- text-align: center;
- position: relative;
-
- .language-switcher {
- position: absolute;
- top: 60rpx;
- right: 32rpx;
- display: flex;
- align-items: center;
- background: rgba(255, 255, 255, 0.25);
- backdrop-filter: blur(10rpx);
- border-radius: 40rpx;
- padding: 16rpx 28rpx;
- transition: all 0.3s;
- z-index: 10;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
-
- &:active {
- transform: scale(0.95);
- background: rgba(255, 255, 255, 0.35);
- }
-
- .language-icon {
- font-size: 36rpx;
- margin-right: 8rpx;
- }
-
- .language-text {
- font-size: 28rpx;
- color: #ffffff;
- font-weight: 500;
- }
- }
-
- .avatar {
- width: 140rpx;
- height: 140rpx;
- margin: 0 auto 20rpx;
- border-radius: 50%;
- background-color: #ffffff;
- overflow: hidden;
-
- .avatar-img {
- width: 100%;
- height: 100%;
- }
- }
-
- .username {
- display: block;
- font-size: 32rpx;
- font-weight: bold;
- color: #ffffff;
- }
- }
- .content {
- margin-top: -40rpx;
- padding: 0 40rpx;
-
- .menu-list {
- background-color: #ffffff;
- border-radius: 20rpx;
- overflow: hidden;
- box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
-
- .menu-item {
- display: flex;
- align-items: center;
- padding: 30rpx 40rpx;
- border-bottom: 1rpx solid #f0f0f0;
- transition: background-color 0.3s;
-
- &:last-child {
- border-bottom: none;
- }
-
- &:active {
- background-color: #f5f5f5;
- }
-
- .menu-icon {
- font-size: 40rpx;
- margin-right: 24rpx;
- }
-
- .menu-text {
- flex: 1;
- font-size: 28rpx;
- color: #333333;
- }
-
- .menu-arrow {
- font-size: 48rpx;
- color: #cccccc;
- font-weight: 300;
- }
- }
- }
-
- .logout-section {
- margin-top: 40rpx;
- padding: 0 40rpx;
-
- .logout-btn {
- width: 100%;
- height: 88rpx;
- line-height: 88rpx;
- background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
- color: #ffffff;
- font-size: 32rpx;
- font-weight: bold;
- border-radius: 44rpx;
- border: none;
- box-shadow: 0 4rpx 20rpx rgba(238, 90, 111, 0.3);
- transition: all 0.3s;
-
- &:active {
- opacity: 0.8;
- transform: scale(0.98);
- }
- }
- }
- }
- </style>
|