index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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: "/offer_price?identity=NZ&role=2",
  126. },
  127. {
  128. title: "服务维护",
  129. path: "/service_manage?identity=NZ&role=2",
  130. },
  131. // {
  132. // title: "联系客服",
  133. // path: "/customer-service",
  134. // },
  135. {
  136. title: "退出登录",
  137. path: "/logout",
  138. },
  139. ]);
  140. // 花园信息项数据
  141. const gardenInfoItems = ref([
  142. { num: 128, label: "服务次数" },
  143. { num: 256, label: "累计客户" },
  144. { num: 512, label: "服务果园" },
  145. ]);
  146. // 处理网格项点击
  147. const handleGridClick = (item) => {
  148. if (item.path) {
  149. router.push(item.path);
  150. }
  151. };
  152. // 处理单元格项点击
  153. const handleCellClick = (item) => {
  154. if (item.path) {
  155. if (item.path === "/logout") {
  156. // 退出登录逻辑
  157. console.log("退出登录");
  158. // 这里可以添加退出登录的具体逻辑
  159. } else {
  160. router.push(item.path);
  161. }
  162. }
  163. };
  164. </script>
  165. <style lang="scss" scoped>
  166. .mine-index {
  167. width: 100%;
  168. height: 100vh;
  169. box-sizing: border-box;
  170. padding: 20px 16px;
  171. background: url("@/assets/img/mine/mine-bg.png") no-repeat center center / 100% 100%;
  172. .mine-header {
  173. width: 100%;
  174. display: flex;
  175. align-items: center;
  176. justify-content: space-between;
  177. .user-info-box {
  178. display: flex;
  179. align-items: center;
  180. .avatar {
  181. border: 1px solid #fff;
  182. margin-right: 12px;
  183. }
  184. .user-info {
  185. font-size: 20px;
  186. .user-name {
  187. font-weight: 500;
  188. display: flex;
  189. align-items: center;
  190. .score {
  191. font-size: 14px;
  192. color: #2199f8;
  193. margin-left: 6px;
  194. font-weight: 500;
  195. }
  196. }
  197. .user-day {
  198. font-size: 12px;
  199. color: rgba(0, 0, 0, 0.5);
  200. }
  201. }
  202. }
  203. .code-icon {
  204. width: 21px;
  205. height: 21px;
  206. img {
  207. width: 100%;
  208. height: 100%;
  209. }
  210. }
  211. }
  212. .mine-content {
  213. margin-top: 20px;
  214. .garden-info {
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. border-radius: 8px;
  219. padding: 6px 0;
  220. background-color: rgba(255, 255, 255, 0.5);
  221. margin-bottom: 10px;
  222. .item {
  223. display: flex;
  224. flex: 1;
  225. flex-direction: column;
  226. align-items: center;
  227. justify-content: center;
  228. color: #999999;
  229. font-size: 13px;
  230. .num {
  231. font-size: 16px;
  232. color: #000;
  233. margin-bottom: 2px;
  234. }
  235. }
  236. }
  237. .grid-group {
  238. display: flex;
  239. align-items: center;
  240. .grid-item {
  241. background-color: #fff;
  242. border-radius: 14px;
  243. padding: 10px 0 10px 10px;
  244. color: #000;
  245. font-size: 16px;
  246. flex: 1;
  247. .grid-title {
  248. display: flex;
  249. align-items: center;
  250. font-weight: 500;
  251. margin-bottom: 6px;
  252. span {
  253. margin-right: 1px;
  254. }
  255. }
  256. .grid-desc {
  257. font-size: 12px;
  258. color: rgba(0, 0, 0, 0.2);
  259. }
  260. }
  261. .grid-item + .grid-item {
  262. margin-left: 10px;
  263. }
  264. }
  265. .cell-group {
  266. .cell-item {
  267. margin-top: 10px;
  268. background-color: #fff;
  269. border-radius: 14px;
  270. padding: 13px 10px;
  271. display: flex;
  272. align-items: center;
  273. justify-content: space-between;
  274. color: #000;
  275. font-size: 16px;
  276. }
  277. }
  278. }
  279. }
  280. </style>