index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <!-- <view class="w-full h-[100rpx] bg-[#f5f5f5] flex items-center justify-center" @click="navigateToTest">进入测试页面</view>-->
  3. <view class="flex flex-col items-center justify-start bg-[#f5f5f5] p-[20rpx]">
  4. <!-- 轮播图 -->
  5. <swiper class="w-full h-[400rpx] mb-[20rpx]" :indicator-dots="true" :autoplay="true" interval="5000" duration="500"
  6. :circular="true">
  7. <swiper-item v-for="(item, index) in bannerList" :key="index">
  8. <image :src="item.imageUrl" class="w-full object-contain" mode="aspectFill" />
  9. </swiper-item>
  10. </swiper>
  11. <!-- 三个图标 -->
  12. <view class="flex justify-around w-full py-[20rpx] bg-white rounded-[12rpx] mb-[20rpx] mr-[10rpx] ml-[10rpx]">
  13. <view class="flex flex-col items-center p-[20rpx] w-[200rpx] text-center" @click="handfarmerClick()">
  14. <view class="w-[80rpx] h-[80rpx] rounded-full bg-#FFF1E0 flex items-center justify-center shadow">
  15. <image src="/static/icon/farmer.png" class="w-[48rpx] h-[48rpx]" />
  16. </view>
  17. <text class="mt-[30rpx] text-[28rpx] text-[#333]">我是农户</text>
  18. </view>
  19. <view class="flex flex-col items-center p-[20rpx] w-[200rpx] text-center" @click="handleIconClick('investigator')">
  20. <view class="w-[80rpx] h-[80rpx] rounded-full bg-#FFE4E0 flex items-center justify-center shadow">
  21. <image src="/static/icon/investigator.png" class="w-[48rpx] h-[48rpx]" />
  22. </view>
  23. <text class="mt-[30rpx] text-[28rpx] text-[#333]">我是调查员</text>
  24. </view>
  25. <view class="flex flex-col items-center p-[20rpx] w-[200rpx] text-center" @click="handleIconClick('official')">
  26. <view class="w-[80rpx] h-[80rpx] rounded-full bg-#E3E3FF flex items-center justify-center shadow">
  27. <image src="/static/icon/official.png" class="w-[48rpx] h-[48rpx]" />
  28. </view>
  29. <text class="mt-[30rpx] text-[28rpx] text-[#333]">我是村干部</text>
  30. </view>
  31. </view>
  32. <!-- 新闻 -->
  33. <view class="w-full rounded-[12rpx] py-[20rpx]">
  34. <view class="text-[32rpx] font-bold text-[#333] mb-[30rpx]">新闻政策</view>
  35. <view class="flex flex-col gap-[20rpx]">
  36. <view v-for="(news, index) in newsList" :key="index" class="flex bg-white rounded-[12rpx] overflow-hidden shadow p-[10rpx]" @click="toDetail(news)">
  37. <view class="flex-1 p-[20rpx] flex flex-col justify-between">
  38. <text class="text-[30rpx] text-[#333] leading-snug mb-[20rpx] font-bold">{{ news.title }}</text>
  39. <text class="text-[24rpx] text-[#666] mb-[20rpx]">{{ news.time }}</text>
  40. <view class="flex items-center text-[28rpx] text-[#666]">
  41. <view class="text-[#007aff] mr-[10rpx]">{{ news.source }}</view>
  42. <view class="ml-[10rpx] flex items-center">
  43. <image src="/static/icon/eye.png" class="w-[36rpx] h-[36rpx]" />
  44. <text>{{ news.views }} 次</text>
  45. </view>
  46. </view>
  47. </view>
  48. <image :src="news.image" class="w-[190rpx] h-[190rpx] p-[10rpx]" mode="aspectFill" />
  49. </view>
  50. </view>
  51. </view>
  52. <CustomTabBar :current="0" />
  53. </view>
  54. </template>
  55. <script setup lang="ts">
  56. import { ref } from 'vue'
  57. import CustomTabBar from "@/components/CustomTabBar.vue";
  58. const navigateToTest = () => {
  59. uni.navigateTo({
  60. url: '/pages/test/index'
  61. })
  62. }
  63. // 轮播图数据
  64. const bannerList = ref([
  65. {
  66. imageUrl: '/static/banner/19.png'
  67. },
  68. {
  69. imageUrl: '/static/banner/20.png'
  70. },
  71. {
  72. imageUrl: '/static/banner/21.png'
  73. }
  74. ])
  75. // 新闻列表数据
  76. const newsList = ref([
  77. {
  78. title: '湖南省第二轮土地承包到期后再延长30年政策问题解答(1)',
  79. time: '2025-08-19 18:02:55',
  80. source: '实时新闻',
  81. views: 29771,
  82. image: '/static/news/news1.png',
  83. content: '湖南省第二轮planting到期后再延长30年政策问题解答(1)'
  84. },
  85. {
  86. title: '农业农村部:稳妥推进第二轮土地承包到期后再延长30年试点',
  87. time: '2025-08-19 18:01:53',
  88. source: '实时新闻',
  89. views: 15643,
  90. image: '/static/news/news2.png',
  91. content: '农业农村部:稳妥推进第二轮土地承包到期后再延长30年试点'
  92. },
  93. {
  94. title: '关于加强农村土地流转管理的通知',
  95. time: '2025-08-18 16:30:22',
  96. source: '政策发布',
  97. views: 8921,
  98. image: '/static/news/news3.png',
  99. content: '关于加强农村土地流转管理的通知'
  100. },
  101. {
  102. title: '乡村振兴战略实施情况报告',
  103. time: '2025-08-17 14:25:11',
  104. source: '专题报道',
  105. views: 12345,
  106. image: '/static/news/news1.png',
  107. content: '<p style="color: red">乡村振兴战略实施情况报告</p>'
  108. }
  109. ])
  110. // 跳转到新闻详情页面
  111. const toDetail = (news: any) => {
  112. // 存储新闻数据到缓存中
  113. uni.setStorageSync('newsParams', news)
  114. // 跳转到新闻详情页面
  115. uni.navigateTo({
  116. url: '/pages/index/news-detail/index'
  117. })
  118. }
  119. // 图标点击处理
  120. const handleIconClick = (type: 'official'|'investigator') => {
  121. const token = uni.getStorageSync('token') || '';
  122. if(!token){
  123. uni.navigateTo({
  124. url: `/pages/login/login`
  125. })
  126. }else{
  127. uni.navigateTo({
  128. url: `/pages/${type}/index?type=` + type
  129. })
  130. }
  131. }
  132. // 图标点击处理
  133. const handfarmerClick = () => {
  134. uni.navigateTo({
  135. url: `/pages/farmer/index`
  136. })
  137. }
  138. </script>