myuser.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <route lang="json5">
  2. {
  3. layout: 'tabbar',
  4. style: {
  5. navigationStyle: 'custom',
  6. navigationBarTitleText: '%tabbar.myuser%',
  7. },
  8. }
  9. </route>
  10. <template>
  11. <view class="container">
  12. <!-- 头像 -->
  13. <view class="profile-section">
  14. <view class="avatar-container" @click="modifyBtn">
  15. <image :src="userInfo.avatar" class="avatar" mode="aspectFill" />
  16. <view class="avatar-badge">
  17. <image style="width: 26px; height: 26px" src="/src/static/icon/modify.svg"></image>
  18. </view>
  19. </view>
  20. <text class="user-id">{{ userInfo.id }}</text>
  21. </view>
  22. <!-- 菜单列表 -->
  23. <view class="menu-list">
  24. <view
  25. v-for="(item, index) in menuItems"
  26. :key="index"
  27. class="menu-item"
  28. @click="handleMenuClick(item.key, index)"
  29. >
  30. <image style="width: 24px; height: 24px" :src="item.icon"></image>
  31. <view class="menu-label">{{ item.label }}</view>
  32. <image style="width: 24px; height: 24px; margin-right: 15px" :src="item.right"></image>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { ref } from 'vue'
  39. const userInfo = ref({
  40. id: '199****3465',
  41. avatar: 'https://ai-public.mastergo.com/ai/img_res/522a9d6767d9f1ad533cf624f7dd95ea.jpg',
  42. })
  43. const menuItems = ref([
  44. {
  45. key: 'baby',
  46. label: '我的宝宝',
  47. icon: '/src/static/icon/fi-rr-child-head.svg',
  48. right: '/src/static/icon/chevron-right.svg',
  49. },
  50. {
  51. key: 'notification',
  52. label: '消息通知',
  53. icon: '/src/static/icon/fi-rr-bell.svg',
  54. right: '/src/static/icon/chevron-right.svg',
  55. },
  56. {
  57. key: 'settings',
  58. label: '设置中心',
  59. icon: '/src/static/icon/setup.svg',
  60. right: '/src/static/icon/chevron-right.svg',
  61. },
  62. ])
  63. // 页面跳转
  64. const handleMenuClick = (item, index) => {
  65. console.log('Clicked menu item:', item, index)
  66. if (item === 'baby') {
  67. uni.navigateTo({
  68. url: '/pages/myUser/component/babyInformation',
  69. })
  70. } else if (item === 'notification') {
  71. uni.navigateTo({
  72. url: '/pages/myUser/component/messageCenter',
  73. })
  74. } else if (item === 'settings') {
  75. uni.navigateTo({
  76. url: '/pages/myUser/component/setFocus',
  77. })
  78. }
  79. }
  80. const modifyBtn = () => {
  81. console.log('修改头像')
  82. }
  83. </script>
  84. <style scoped>
  85. .container {
  86. min-height: 100vh;
  87. font-size: 16px;
  88. background-color: #f9fafb;
  89. }
  90. .profile-section {
  91. display: flex;
  92. flex-direction: column;
  93. align-items: center;
  94. justify-content: center;
  95. height: 175px;
  96. padding: 36px 16px 0px 16px;
  97. }
  98. .avatar-container {
  99. position: relative;
  100. }
  101. .avatar {
  102. width: 88px;
  103. height: 88px;
  104. border-radius: 50%;
  105. }
  106. .avatar-badge {
  107. position: absolute;
  108. right: 0;
  109. bottom: 0;
  110. background: #f88842;
  111. border-radius: 24px;
  112. }
  113. .user-id {
  114. margin-top: 0.75rem;
  115. color: #4b5563;
  116. }
  117. .menu-list {
  118. padding: 16px;
  119. }
  120. .menu-item {
  121. display: flex;
  122. align-items: center;
  123. justify-content: space-between;
  124. padding-top: 1rem;
  125. padding-bottom: 1rem;
  126. cursor: pointer;
  127. border-bottom: 1px solid #e5e7eb;
  128. }
  129. .menu-label {
  130. flex: 1;
  131. margin-left: 0.75rem;
  132. color: #374151;
  133. }
  134. </style>