index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="main-content ">
  3. <view class="home-banner">
  4. <view class="home-banner-left">
  5. <img src="/static/serverImg/home/address.png" alt=""
  6. style="width: 41.67rpx;height: 41.67rpx;margin-right: 8rpx;">
  7. <text>{{ data.address }}</text>
  8. </view>
  9. <view>
  10. <up-icon name="bell" :size="25" color="rgba(46, 46, 46, 1)"></up-icon>
  11. <!-- <img src="/static/serverImg/home/message.png" alt="" style="width: 50rpx;height: 50rpx;"> -->
  12. </view>
  13. </view>
  14. <view class="home-main">
  15. <view class="custom-swiper">
  16. <up-swiper :list="list3" indicator indicatorMode="line" circular></up-swiper>
  17. </view>
  18. </view>
  19. <view class="home-grid">
  20. <Client />
  21. </view>
  22. <view class="home-grid hot-box">
  23. <view v-for="(item, index) in hotList" :key="index + 'hot'" class="hot-item">
  24. <img :src="item" alt=""
  25. style="width: 100%;height: 160rpx;">
  26. </view>
  27. </view>
  28. <view class="home-grid">
  29. <view class="serve-title hot-box-title">超值专区</view>
  30. <view class="hot-swiper">
  31. <up-swiper :list="ValueZone" indicator indicatorMode="line" circular></up-swiper>
  32. </view>
  33. </view>
  34. <view class="home-ranking">
  35. <ServIces :leftList="leftList" :rightList="rightList" v-if="userType == 1"></ServIces>
  36. <RankingList v-if="userType === 2" />
  37. </view>
  38. <up-loadmore
  39. style="margin-top: 40rpx;"
  40. :status="loadmoreInfo.status"
  41. :loadmoreText="loadmoreInfo.loadingText"
  42. :loadingText="loadmoreInfo.loadmoreText"
  43. :nomoreText="loadmoreInfo.nomoreText"
  44. @loadmore="handleLoadmore"
  45. />
  46. </view>
  47. </template>
  48. <script setup>
  49. import {
  50. ref,
  51. reactive,
  52. onMounted
  53. } from 'vue';
  54. import {
  55. onLoad,
  56. onShow
  57. } from "@dcloudio/uni-app";
  58. import RankingList from '@/pages/common/rankingList/index.vue';
  59. import ServIces from "@/components/Services/services.vue"
  60. import {
  61. Client
  62. } from "@/components/Client/new_file.vue"
  63. import {
  64. volunteerinfolist,
  65. } from "@/api/volunteerDetailsApi/details.js"
  66. import { slideshow } from '@/api/home.js'
  67. const total = ref(0)
  68. const listData = ref([])
  69. const rightList = ref([])
  70. const leftList = ref([])
  71. const userType = uni.getStorageSync('userType') //读取本地存储
  72. const data = reactive({
  73. address: '重庆市永川区',
  74. queryValue: ''
  75. })
  76. const list3 = ref([]);
  77. const ValueZone = ref([]);
  78. const hotList = ref([])
  79. // 分页
  80. const pages = ref({
  81. current: 1,
  82. pageSize: 10,
  83. total: 0
  84. })
  85. const loadmoreInfo = ref({
  86. status: 'loadmore',
  87. loadingText: '努力加载中...',
  88. loadmoreText: '点击加载更多~',
  89. nomoreText: '已经到底啦~'
  90. })
  91. const getList = async () => {
  92. try {
  93. loadmoreInfo.value.status = 'loading'
  94. const res = await volunteerinfolist();
  95. if (!res || !res.rows) {
  96. return;
  97. }
  98. // 判断是否已经到了最后一页
  99. if (pages.value.current >= Math.ceil(res.total/pages.value.pageSize)) {
  100. loadmoreInfo.value.status = 'nomore'
  101. } else {
  102. loadmoreInfo.value.status = 'loadmore'
  103. }
  104. listData.value.push(...res.rows)
  105. let leftArr = [];
  106. let rightArr = [];
  107. listData.value.forEach((item, index) => {
  108. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  109. });
  110. leftList.value = leftArr;
  111. rightList.value = rightArr;
  112. pages.value.total = res.total;
  113. } catch (error) {
  114. listData.value = []
  115. pages.value.total = 0
  116. console.error('Error fetching data:', error);
  117. } finally {
  118. loadmoreInfo.value.status = 'loadmore'
  119. }
  120. }
  121. const getBanners = async () => {
  122. try {
  123. const res = await slideshow(7);
  124. if (res.code === 200 && res.data.picture) {
  125. list3.value = res.data.picture.split(',');
  126. }
  127. const value_res = await slideshow(8);
  128. if (value_res.code === 200 && value_res.data.picture) {
  129. ValueZone.value = value_res.data.picture.split(',');
  130. }
  131. const hot_res = await slideshow(11);
  132. if (hot_res.code === 200 && hot_res.data.picture) {
  133. hotList.value = hot_res.data.picture.split(',');
  134. }
  135. } catch (error) {
  136. console.log('error', error);
  137. }
  138. }
  139. onShow(() => {
  140. getList()
  141. getBanners();
  142. })
  143. </script>
  144. <style scoped lang="scss">
  145. .main-content {
  146. .home-banner {
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. background: rgba(255, 255, 255, 1);
  151. box-shadow: 0rpx 0rpx 0rpx rgba(0, 0, 0, 0), 0rpx 0rpx 0rpx rgba(0, 0, 0, 0), 0rpx 2.08rpx 4.17rpx rgba(0, 0, 0, 0.05);
  152. padding: 20rpx 16rpx;
  153. }
  154. .home-banner-left {
  155. display: flex;
  156. align-items: center;
  157. }
  158. .home-main {
  159. padding: 12px 16px;
  160. .custom-swiper {}
  161. .home-grid {
  162. margin-bottom: 32px;
  163. }
  164. }
  165. .home-ranking {
  166. padding: 24rpx 16px;
  167. }
  168. }
  169. .hot-box-title {
  170. padding: 0 32rpx;
  171. }
  172. .hot-swiper {
  173. padding: 24rpx 32rpx 0;
  174. }
  175. .hot-box {
  176. padding: 24rpx 32rpx;
  177. display: grid;
  178. grid-template-columns: repeat(2, 1fr);
  179. gap: 8rpx;
  180. .hot-item {
  181. // padding: 32rpx 16rpx;
  182. // border-radius: 10rpx;
  183. }
  184. }
  185. </style>