index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div class="mine-index">
  3. <div class="mine-header">
  4. <el-avatar
  5. class="avatar"
  6. :size="54"
  7. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  8. />
  9. <div class="user-info">
  10. <span class="user-name">听妈妈的话</span>
  11. <div class="user-day">这是您使用飞鸟有味的第15天</div>
  12. </div>
  13. </div>
  14. <div class="mine-content">
  15. <div class="grid-group">
  16. <div
  17. class="grid-item"
  18. v-for="(item, index) in gridItems"
  19. :key="index"
  20. @click="handleGridClick(item)"
  21. >
  22. <div class="grid-title">
  23. <span>{{ item.title }}</span>
  24. <el-icon><ArrowRight /></el-icon>
  25. </div>
  26. <span class="grid-desc">{{ item.desc }}</span>
  27. </div>
  28. </div>
  29. <div class="cell-group">
  30. <div
  31. class="cell-item"
  32. v-for="(item, index) in cellItems"
  33. :key="index"
  34. @click="handleCellClick(item)"
  35. >
  36. <span class="item-title">{{ item.title }}</span>
  37. <el-icon class="item-arrow"><ArrowRight /></el-icon>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup>
  44. import { Cell, CellGroup } from "vant";
  45. import { ref } from 'vue';
  46. import { useRouter } from 'vue-router';
  47. const router = useRouter();
  48. // 网格项数据
  49. const gridItems = ref([
  50. {
  51. title: '我的农场',
  52. desc: '查看农场列表',
  53. path: '/my_farm'
  54. },
  55. {
  56. title: '我的消息',
  57. desc: '查看未读信息',
  58. path: '/message'
  59. },
  60. {
  61. title: '农事记录',
  62. desc: '查看历史农事',
  63. path: '/order/list'
  64. }
  65. ]);
  66. // 单元格项数据
  67. const cellItems = ref([
  68. {
  69. title: '联系客服',
  70. path: '/customer-service'
  71. },
  72. {
  73. title: '帮助中心',
  74. path: '/help'
  75. },
  76. {
  77. title: '退出登录',
  78. path: '/logout'
  79. }
  80. ]);
  81. // 处理网格项点击
  82. const handleGridClick = (item) => {
  83. if (item.path) {
  84. router.push(item.path);
  85. }
  86. };
  87. // 处理单元格项点击
  88. const handleCellClick = (item) => {
  89. if (item.path) {
  90. if (item.path === '/logout') {
  91. // 退出登录逻辑
  92. console.log('退出登录');
  93. // 这里可以添加退出登录的具体逻辑
  94. } else {
  95. router.push(item.path);
  96. }
  97. }
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. .mine-index {
  102. width: 100%;
  103. height: 100vh;
  104. box-sizing: border-box;
  105. padding: 20px 16px;
  106. background: url("@/assets/img/mine/mine-bg.png") no-repeat center center / 100% 100%;
  107. .mine-header {
  108. width: 100%;
  109. display: flex;
  110. align-items: center;
  111. .avatar {
  112. border: 1px solid #fff;
  113. margin-right: 12px;
  114. }
  115. .user-info {
  116. font-size: 20px;
  117. .user-name {
  118. font-weight: 500;
  119. }
  120. .user-day {
  121. font-size: 12px;
  122. color: rgba(0, 0, 0, 0.5);
  123. }
  124. }
  125. }
  126. .mine-content {
  127. margin-top: 20px;
  128. .grid-group {
  129. display: flex;
  130. align-items: center;
  131. .grid-item {
  132. background-color: #fff;
  133. border-radius: 14px;
  134. padding: 10px 0 10px 10px;
  135. color: #000;
  136. font-size: 16px;
  137. flex: 1;
  138. .grid-title {
  139. display: flex;
  140. align-items: center;
  141. font-weight: 500;
  142. margin-bottom: 6px;
  143. span{
  144. margin-right: 10px;
  145. }
  146. }
  147. .grid-desc {
  148. font-size: 12px;
  149. color: rgba(0, 0, 0, 0.2);
  150. }
  151. }
  152. .grid-item + .grid-item {
  153. margin-left: 10px;
  154. }
  155. }
  156. .cell-group {
  157. .cell-item {
  158. margin-top: 10px;
  159. background-color: #fff;
  160. border-radius: 14px;
  161. padding: 13px 10px;
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. color: #000;
  166. font-size: 16px;
  167. }
  168. }
  169. }
  170. }
  171. </style>