index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="mine-index">
  3. <div class="mine-header">
  4. <div class="user-info-box">
  5. <el-avatar
  6. class="avatar"
  7. :size="54"
  8. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  9. />
  10. <div class="user-info">
  11. <div class="user-name">
  12. <span>听妈妈的话</span>
  13. <span class="score" v-if="curRole !== 0">5.0分</span>
  14. </div>
  15. <div class="user-day">这是您使用飞鸟有味的第15天</div>
  16. </div>
  17. </div>
  18. <div class="code-icon" v-if="curRole === 1">
  19. <img src="@/assets/img/mine/code-icon.png" alt="" />
  20. </div>
  21. </div>
  22. <div class="mine-content">
  23. <div class="garden-info" v-if="curRole !== 0">
  24. <div class="item" v-for="(item, index) in gardenInfoItems" :key="index">
  25. <span class="num">{{ item.num }}</span>
  26. <span>{{ item.label }}</span>
  27. </div>
  28. </div>
  29. <!-- <div class="grid-group">
  30. <div class="grid-item" v-for="(item, index) in gridItems" :key="index" @click="handleGridClick(item)">
  31. <div class="grid-title">
  32. <span>{{ item.title }}</span>
  33. <el-icon><ArrowRight /></el-icon>
  34. </div>
  35. <span class="grid-desc">{{ item.desc }}</span>
  36. </div>
  37. </div> -->
  38. <div class="cell-group">
  39. <div class="cell-item" v-for="(item, index) in cellItems" :key="index" @click="handleCellClick(item)">
  40. <span class="item-title">{{ item.title }}</span>
  41. <el-icon class="item-arrow"><ArrowRight /></el-icon>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup>
  48. import { onActivated, ref } from "vue";
  49. import { useRouter } from "vue-router";
  50. const router = useRouter();
  51. // 0: 农户, 1: 专家, 2:农资农服
  52. const curRole = ref(0);
  53. // 网格项数据
  54. const gridItems = ref([]);
  55. onActivated(() => {
  56. if (curRole.value === 0) {
  57. gridItems.value = [
  58. {
  59. title: "我的农场",
  60. desc: "查看农场列表",
  61. path: "/my_farm",
  62. },
  63. {
  64. title: "我的消息",
  65. desc: "查看未读信息",
  66. path: "/message",
  67. },
  68. {
  69. title: "农事记录",
  70. desc: "查看历史农事",
  71. path: "/farm_records",
  72. },
  73. ];
  74. } else if (curRole.value === 1) {
  75. gridItems.value = [
  76. {
  77. title: "我的主页",
  78. desc: "查看农场列表",
  79. path: "/expert_detail",
  80. },
  81. {
  82. title: "我的报价",
  83. desc: "查看未读信息",
  84. path: "/message",
  85. },
  86. {
  87. title: "信息化档案",
  88. desc: "查看历史农事",
  89. path: "/archives",
  90. },
  91. ];
  92. } else if (curRole.value === 2) {
  93. gridItems.value = [
  94. {
  95. title: "我的主页",
  96. desc: "查看农场列表",
  97. path: "/my_farm",
  98. },
  99. {
  100. title: "我的消息",
  101. desc: "查看未读信息",
  102. path: "/message",
  103. },
  104. {
  105. title: "信息化档案",
  106. desc: "查看历史农事",
  107. path: "/archives",
  108. },
  109. ];
  110. }
  111. // curRole.value = localStorage.getItem('SET_USER_CUR_ROLE');
  112. });
  113. // 单元格项数据
  114. const cellItems = ref([
  115. {
  116. title: "我的农场",
  117. path: "/my_farm",
  118. },
  119. {
  120. title: "认证农资",
  121. path: "/register?identity=NZ&role=2",
  122. },
  123. // {
  124. // title: "联系客服",
  125. // path: "/customer-service",
  126. // },
  127. {
  128. title: "退出登录",
  129. path: "/logout",
  130. },
  131. ]);
  132. // 花园信息项数据
  133. const gardenInfoItems = ref([
  134. { num: 128, label: "服务次数" },
  135. { num: 256, label: "累计客户" },
  136. { num: 512, label: "服务果园" },
  137. ]);
  138. // 处理网格项点击
  139. const handleGridClick = (item) => {
  140. if (item.path) {
  141. router.push(item.path);
  142. }
  143. };
  144. // 处理单元格项点击
  145. const handleCellClick = (item) => {
  146. if (item.path) {
  147. if (item.path === "/logout") {
  148. // 退出登录逻辑
  149. console.log("退出登录");
  150. // 这里可以添加退出登录的具体逻辑
  151. } else {
  152. router.push(item.path);
  153. }
  154. }
  155. };
  156. </script>
  157. <style lang="scss" scoped>
  158. .mine-index {
  159. width: 100%;
  160. height: 100vh;
  161. box-sizing: border-box;
  162. padding: 20px 16px;
  163. background: url("@/assets/img/mine/mine-bg.png") no-repeat center center / 100% 100%;
  164. .mine-header {
  165. width: 100%;
  166. display: flex;
  167. align-items: center;
  168. justify-content: space-between;
  169. .user-info-box {
  170. display: flex;
  171. align-items: center;
  172. .avatar {
  173. border: 1px solid #fff;
  174. margin-right: 12px;
  175. }
  176. .user-info {
  177. font-size: 20px;
  178. .user-name {
  179. font-weight: 500;
  180. display: flex;
  181. align-items: center;
  182. .score {
  183. font-size: 14px;
  184. color: #2199f8;
  185. margin-left: 6px;
  186. font-weight: 500;
  187. }
  188. }
  189. .user-day {
  190. font-size: 12px;
  191. color: rgba(0, 0, 0, 0.5);
  192. }
  193. }
  194. }
  195. .code-icon {
  196. width: 21px;
  197. height: 21px;
  198. img {
  199. width: 100%;
  200. height: 100%;
  201. }
  202. }
  203. }
  204. .mine-content {
  205. margin-top: 20px;
  206. .garden-info {
  207. display: flex;
  208. align-items: center;
  209. justify-content: space-between;
  210. border-radius: 8px;
  211. padding: 6px 0;
  212. background-color: rgba(255, 255, 255, 0.5);
  213. margin-bottom: 10px;
  214. .item {
  215. display: flex;
  216. flex: 1;
  217. flex-direction: column;
  218. align-items: center;
  219. justify-content: center;
  220. color: #999999;
  221. font-size: 13px;
  222. .num {
  223. font-size: 16px;
  224. color: #000;
  225. margin-bottom: 2px;
  226. }
  227. }
  228. }
  229. .grid-group {
  230. display: flex;
  231. align-items: center;
  232. .grid-item {
  233. background-color: #fff;
  234. border-radius: 14px;
  235. padding: 10px 0 10px 10px;
  236. color: #000;
  237. font-size: 16px;
  238. flex: 1;
  239. .grid-title {
  240. display: flex;
  241. align-items: center;
  242. font-weight: 500;
  243. margin-bottom: 6px;
  244. span {
  245. margin-right: 1px;
  246. }
  247. }
  248. .grid-desc {
  249. font-size: 12px;
  250. color: rgba(0, 0, 0, 0.2);
  251. }
  252. }
  253. .grid-item + .grid-item {
  254. margin-left: 10px;
  255. }
  256. }
  257. .cell-group {
  258. .cell-item {
  259. margin-top: 10px;
  260. background-color: #fff;
  261. border-radius: 14px;
  262. padding: 13px 10px;
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. color: #000;
  267. font-size: 16px;
  268. }
  269. }
  270. }
  271. }
  272. </style>