index.vue 6.8 KB

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