index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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-ranking">
  23. <ServIces :listData="listData" :rightList="rightList" v-if="userType == 1"></ServIces>
  24. <RankingList v-if="userType === 2" />
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import {
  30. ref,
  31. reactive,
  32. onMounted
  33. } from 'vue';
  34. import {
  35. onLoad,
  36. onShow
  37. } from "@dcloudio/uni-app";
  38. import RankingList from '@/pages/common/rankingList/index.vue';
  39. import ServIces from "@/components/Services/services.vue"
  40. import {
  41. Client
  42. } from "@/components/Client/new_file.vue"
  43. import {
  44. volunteerinfolist,
  45. } from "@/api/volunteerDetailsApi/details.js"
  46. import { slideshow } from '@/api/home.js'
  47. const total = ref(0)
  48. const listData = ref([])
  49. const rightList = ref([])
  50. const userType = uni.getStorageSync('userType') //读取本地存储
  51. const data = reactive({
  52. address: '重庆市永川区',
  53. queryValue: ''
  54. })
  55. const list3 = ref([]);
  56. const getList = async () => {
  57. try {
  58. const res = await volunteerinfolist();
  59. if (!res || !res.rows) {
  60. return;
  61. }
  62. let leftArr = [];
  63. let rightArr = [];
  64. (res.rows || []).forEach((item, index) => {
  65. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  66. });
  67. listData.value = leftArr;
  68. rightList.value = rightArr;
  69. total.value = res.rows;
  70. } catch (error) {
  71. console.error('Error fetching data:', error);
  72. }
  73. };
  74. const getBanners = async() => {
  75. try {
  76. const res =await slideshow(7);
  77. if(res.code === 200 && res.data.picture){
  78. list3.value = res.data.picture.split(',');
  79. }
  80. } catch (error) {
  81. console.log('error',error);
  82. }
  83. }
  84. onShow(() => {
  85. getList()
  86. getBanners();
  87. })
  88. </script>
  89. <style scoped lang="scss">
  90. .main-content {
  91. .home-banner {
  92. display: flex;
  93. align-items: center;
  94. justify-content: space-between;
  95. background: rgba(255, 255, 255, 1);
  96. 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);
  97. padding: 20rpx 16rpx;
  98. }
  99. .home-banner-left {
  100. display: flex;
  101. align-items: center;
  102. }
  103. .home-main {
  104. padding: 12px 16px;
  105. .custom-swiper {}
  106. .home-grid {
  107. margin-bottom: 32px;
  108. }
  109. }
  110. .home-ranking {
  111. padding: 12px 16px;
  112. }
  113. }
  114. </style>