index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view class="container">
  3. <!-- 用户信息卡片 -->
  4. <view class="user-card">
  5. <view class="user-header">
  6. <image class="avatar" src="/static/images/default-avatar.png"></image>
  7. <view class="user-detail">
  8. <text class="nickname">测试用户</text>
  9. <text class="user-id">ID: 888888</text>
  10. </view>
  11. </view>
  12. </view>
  13. <!-- 地块信息 -->
  14. <view class="info-card">
  15. <view class="card-title">
  16. <text>我的地块</text>
  17. <text class="more" @click="navigateToPlots">查看更多 ></text>
  18. </view>
  19. <view class="plot-info">
  20. <view class="plot-item">
  21. <text class="number">{{ plotInfo.total }}</text>
  22. <text class="label">总地块数</text>
  23. </view>
  24. <view class="plot-item">
  25. <text class="number">{{ plotInfo.active }}</text>
  26. <text class="label">种植中</text>
  27. </view>
  28. <view class="plot-item">
  29. <text class="number">{{ plotInfo.idle }}</text>
  30. <text class="label">空闲</text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 农业服务 -->
  35. <view class="info-card">
  36. <view class="card-title">
  37. <text>农业服务</text>
  38. </view>
  39. <view class="service-grid">
  40. <view
  41. class="service-item"
  42. v-for="(item, index) in serviceList"
  43. :key="index"
  44. @click="navigateToService(item)"
  45. >
  46. <view class="service-icon">
  47. <image v-if="item.iconSvg" class="icon-svg" :src="item.iconSvg"></image>
  48. <text v-else>{{ item.iconText }}</text>
  49. </view>
  50. <text class="service-name">{{ item.name }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 常用功能 -->
  55. <view class="info-card">
  56. <view class="function-list">
  57. <view class="function-item" @click="handleContact">
  58. <view class="left">
  59. <text>联系客服</text>
  60. </view>
  61. <text class="arrow">></text>
  62. </view>
  63. <view class="function-item" @click="navigateToSettings">
  64. <view class="left">
  65. <text>系统设置</text>
  66. </view>
  67. <text class="arrow">></text>
  68. </view>
  69. <view class="function-item" @click="handleLogout">
  70. <view class="left">
  71. <text>退出登录</text>
  72. </view>
  73. <text class="arrow">></text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. plotInfo: {
  84. total: 3,
  85. active: 2,
  86. idle: 1
  87. },
  88. serviceList: [
  89. {
  90. name: '农资商城',
  91. iconText: '商',
  92. iconSvg: '/static/icons/mall.png',
  93. path: '/pages/service/mall'
  94. },
  95. {
  96. name: '农品交易',
  97. iconText: '售',
  98. iconSvg: '/static/icons/sales.png',
  99. path: '/pages/service/sales'
  100. },
  101. {
  102. name: '专家咨询',
  103. iconText: '诊',
  104. iconSvg: '/static/icons/expert.png',
  105. path: '/pages/service/expert'
  106. },
  107. {
  108. name: '绿色认证',
  109. iconText: '证',
  110. iconSvg: '/static/icons/certification.png',
  111. path: '/pages/service/certification'
  112. },
  113. {
  114. name: '保险接入',
  115. iconText: '保',
  116. iconSvg: '/static/icons/insurance.png',
  117. path: '/pages/service/insurance'
  118. }
  119. ]
  120. }
  121. },
  122. methods: {
  123. navigateToPlots() {
  124. uni.navigateTo({ url: '/pages/plots/list' })
  125. },
  126. navigateToService(item) {
  127. uni.navigateTo({ url: item.path })
  128. },
  129. handleContact() {
  130. uni.makePhoneCall({
  131. phoneNumber: '400-xxx-xxxx' // 替换为实际的客服电话
  132. })
  133. },
  134. navigateToSettings() {
  135. uni.navigateTo({ url: '/pages/settings/index' })
  136. },
  137. handleLogout() {
  138. uni.showModal({
  139. title: '提示',
  140. content: '确认退出登录?',
  141. success: (res) => {
  142. if (res.confirm) {
  143. // 清除登录信息
  144. uni.removeStorageSync('token')
  145. uni.removeStorageSync('userInfo')
  146. // 返回登录页
  147. uni.reLaunch({
  148. url: '/pages/login/index'
  149. })
  150. }
  151. }
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style>
  158. .container {
  159. min-height: 100vh;
  160. background-color: #f5f5f5;
  161. padding: 20rpx;
  162. }
  163. .user-card {
  164. background-color: #4CAF50;
  165. border-radius: 16rpx;
  166. padding: 30rpx;
  167. margin-bottom: 20rpx;
  168. }
  169. .user-header {
  170. display: flex;
  171. align-items: center;
  172. }
  173. .avatar {
  174. width: 120rpx;
  175. height: 120rpx;
  176. border-radius: 60rpx;
  177. border: 4rpx solid #fff;
  178. }
  179. .user-detail {
  180. margin-left: 20rpx;
  181. color: #fff;
  182. }
  183. .nickname {
  184. font-size: 32rpx;
  185. font-weight: bold;
  186. margin-bottom: 10rpx;
  187. display: block;
  188. }
  189. .user-id {
  190. font-size: 24rpx;
  191. opacity: 0.8;
  192. }
  193. .info-card {
  194. background-color: #fff;
  195. border-radius: 16rpx;
  196. padding: 30rpx;
  197. margin-bottom: 20rpx;
  198. }
  199. .card-title {
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. margin-bottom: 30rpx;
  204. font-size: 32rpx;
  205. font-weight: bold;
  206. }
  207. .more {
  208. color: #666;
  209. font-size: 24rpx;
  210. font-weight: normal;
  211. }
  212. .plot-info {
  213. display: flex;
  214. justify-content: space-around;
  215. }
  216. .plot-item {
  217. text-align: center;
  218. }
  219. .number {
  220. font-size: 36rpx;
  221. font-weight: bold;
  222. color: #4CAF50;
  223. display: block;
  224. }
  225. .label {
  226. font-size: 24rpx;
  227. color: #666;
  228. margin-top: 10rpx;
  229. display: block;
  230. }
  231. .service-grid {
  232. display: grid;
  233. grid-template-columns: repeat(4, 1fr);
  234. gap: 30rpx;
  235. padding: 10rpx 0;
  236. }
  237. .service-item {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. }
  242. .service-icon {
  243. width: 88rpx;
  244. height: 88rpx;
  245. background-color: #E8F5E9;
  246. border-radius: 16rpx;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. margin-bottom: 16rpx;
  251. }
  252. .service-icon text {
  253. font-size: 32rpx;
  254. color: #4CAF50;
  255. font-weight: bold;
  256. }
  257. .icon-svg {
  258. width: 48rpx;
  259. height: 48rpx;
  260. display: block;
  261. }
  262. .service-name {
  263. font-size: 28rpx;
  264. color: #666;
  265. text-align: center;
  266. }
  267. .function-list {
  268. width: 100%;
  269. }
  270. .function-item {
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. padding: 30rpx 0;
  275. border-bottom: 1rpx solid #f5f5f5;
  276. }
  277. .function-item:last-child {
  278. border-bottom: none;
  279. }
  280. .function-item .left {
  281. display: flex;
  282. align-items: center;
  283. }
  284. .function-item text {
  285. font-size: 28rpx;
  286. color: #333;
  287. }
  288. .arrow {
  289. color: #999;
  290. font-size: 24rpx;
  291. }
  292. </style>