index.vue 2.6 KB

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