<route lang="json5">
{
  layout: 'tabbar',
  style: {
    navigationStyle: 'custom',
    navigationBarTitleText: '%tabbar.myuser%',
  },
}
</route>

<template>
  <view class="container">
    <!-- 头像 -->
    <view class="profile-section">
      <view class="avatar-container" @click="modifyBtn">
        <image :src="userInfo.avatar" class="avatar" mode="aspectFill" />
        <view class="avatar-badge">
          <image style="width: 52rpx; height: 52rpx" src="/src/static/icon/modify.svg"></image>
        </view>
      </view>
      <text class="user-id">{{ userInfo.id }}</text>
    </view>

    <!-- 菜单列表 -->
    <view class="menu-list">
      <view
        v-for="(item, index) in menuItems"
        :key="index"
        class="menu-item"
        @click="handleMenuClick(item.key, index)"
      >
        <image style="width: 48rpx; height: 48rpx" :src="item.icon"></image>
        <view class="menu-label">{{ item.label }}</view>
        <image style="width: 48rpx; height: 48rpx; margin-right: 30rpx" :src="item.right"></image>
      </view>
    </view>
  </view>
</template>

<script setup>
  import { ref } from 'vue'

  const userInfo = ref({
    id: '199****3465',
    avatar: 'https://ai-public.mastergo.com/ai/img_res/522a9d6767d9f1ad533cf624f7dd95ea.jpg',
  })
  const menuItems = ref([
    {
      key: 'baby',
      label: '我的宝宝',
      icon: '/src/static/icon/fi-rr-child-head.svg',
      right: '/src/static/icon/chevron-right.svg',
    },
    {
      key: 'notification',
      label: '消息通知',
      icon: '/src/static/icon/fi-rr-bell.svg',
      right: '/src/static/icon/chevron-right.svg',
    },
    {
      key: 'settings',
      label: '设置中心',
      icon: '/src/static/icon/setup.svg',
      right: '/src/static/icon/chevron-right.svg',
    },
  ])
  //  页面跳转
  const handleMenuClick = (item, index) => {
    console.log('Clicked menu item:', item, index)
    if (item === 'baby') {
      uni.navigateTo({
        url: '/pages/myUser/component/myBaby',
      })
    } else if (item === 'notification') {
      uni.navigateTo({
        url: '/pages/myUser/component/messageCenter',
      })
    } else if (item === 'settings') {
      uni.navigateTo({
        url: '/pages/myUser/component/setFocus',
      })
    }
  }
  const modifyBtn = () => {
    uni.navigateTo({
      url: '/pages/myUser/component/userInformation',
    })
  }
</script>

<style scoped>
  .container {
    min-height: 100vh;
    font-size: 32rpx;
    background-color: #f9fafb;
  }

  .profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 350rpx;
    padding: 72rpx 32rpx 0px 32rpx;
  }

  .avatar-container {
    position: relative;
  }

  .avatar {
    width: 176rpx;
    height: 176rpx;
    border-radius: 50%;
  }

  .avatar-badge {
    position: absolute;
    right: 0;
    bottom: 0;
    background: #f88842;
    border-radius: 24rpx;
  }

  .user-id {
    margin-top: 0.75rem;
    color: #333;
  }

  .menu-list {
    padding: 16px;
  }

  .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    padding-bottom: 1rem;
    cursor: pointer;
    border-bottom: 1px solid #e5e7eb;
  }
  .menu-label {
    flex: 1;
    margin-left: 0.75rem;
    color: #333;
  }
</style>
