index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 in hotList" :key="item.key" class="hot-item">
  24. <view>
  25. <view>{{item.name}}</view>
  26. <view>{{item.text}}</view>
  27. </view>
  28. <up-icon :name="listItem.iconName" :size="22"></up-icon>
  29. </view>
  30. </view> -->
  31. <view class="home-ranking">
  32. <ServIces :listData="listData" :rightList="rightList" v-if="userType == 1"></ServIces>
  33. <RankingList v-if="userType === 2" />
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import {
  39. ref,
  40. reactive,
  41. onMounted
  42. } from 'vue';
  43. import {
  44. onLoad,
  45. onShow
  46. } from "@dcloudio/uni-app";
  47. import RankingList from '@/pages/common/rankingList/index.vue';
  48. import ServIces from "@/components/Services/services.vue"
  49. import {
  50. Client
  51. } from "@/components/Client/new_file.vue"
  52. import {
  53. volunteerinfolist,
  54. } from "@/api/volunteerDetailsApi/details.js"
  55. import { slideshow } from '@/api/home.js'
  56. const total = ref(0)
  57. const listData = ref([])
  58. const rightList = ref([])
  59. const userType = uni.getStorageSync('userType') //读取本地存储
  60. const data = reactive({
  61. address: '重庆市永川区',
  62. queryValue: ''
  63. })
  64. const list3 = ref([]);
  65. const hotList = [
  66. {
  67. key: 1,
  68. icon: '/static/img/构建.png',
  69. name: '专业辅导',
  70. text:'与家长协同制定成长计划',
  71. },
  72. {
  73. key: 2,
  74. icon: '/static/img/构建.png',
  75. name: '暖心陪护',
  76. text:'倾听烦恼、缓解孤独感',
  77. },
  78. ]
  79. const hotList2 = [
  80. {
  81. key: 1,
  82. icon: '/static/img/构建.png',
  83. name: '专业辅导',
  84. text:'与家长协同制定成长计划',
  85. },
  86. {
  87. key: 2,
  88. icon: '/static/img/构建.png',
  89. name: '暖心陪护',
  90. text:'倾听烦恼、缓解孤独感',
  91. },
  92. {
  93. key: 3,
  94. icon: '/static/img/构建.png',
  95. name: '专业辅导',
  96. text:'与家长协同制定成长计划',
  97. },
  98. {
  99. key: 4,
  100. icon: '/static/img/构建.png',
  101. name: '暖心陪护',
  102. text:'倾听烦恼、缓解孤独感',
  103. },
  104. ]
  105. const getList = async () => {
  106. try {
  107. const res = await volunteerinfolist();
  108. if (!res || !res.rows) {
  109. return;
  110. }
  111. let leftArr = [];
  112. let rightArr = [];
  113. (res.rows || []).forEach((item, index) => {
  114. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  115. });
  116. listData.value = leftArr;
  117. rightList.value = rightArr;
  118. total.value = res.rows;
  119. } catch (error) {
  120. console.error('Error fetching data:', error);
  121. }
  122. };
  123. const getBanners = async() => {
  124. try {
  125. const res =await slideshow(7);
  126. if(res.code === 200 && res.data.picture){
  127. list3.value = res.data.picture.split(',');
  128. }
  129. } catch (error) {
  130. console.log('error',error);
  131. }
  132. }
  133. onShow(() => {
  134. getList()
  135. getBanners();
  136. })
  137. </script>
  138. <style scoped lang="scss">
  139. .main-content {
  140. .home-banner {
  141. display: flex;
  142. align-items: center;
  143. justify-content: space-between;
  144. background: rgba(255, 255, 255, 1);
  145. 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);
  146. padding: 20rpx 16rpx;
  147. }
  148. .home-banner-left {
  149. display: flex;
  150. align-items: center;
  151. }
  152. .home-main {
  153. padding: 12px 16px;
  154. .custom-swiper {}
  155. .home-grid {
  156. margin-bottom: 32px;
  157. }
  158. }
  159. .home-ranking {
  160. padding: 12px 16px;
  161. }
  162. }
  163. .hot-box {
  164. padding: 12px 16px;
  165. display: grid;
  166. grid-template-columns: repeat(2, 1fr);
  167. /* 3 列,每列等宽 */
  168. gap: 32rpx;
  169. .hot-item {
  170. .hot-item {
  171. padding: 12px 16px;
  172. }
  173. }
  174. }
  175. </style>