index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 "@/pages/Client/new_file.vue"
  42. import {
  43. Client
  44. } from "@/components/Client/new_file.vue"
  45. import {
  46. volunteerinfolist,
  47. } from "@/api/volunteerDetailsApi/details.js"
  48. const total = ref(0)
  49. const listData = ref([])
  50. const rightList = ref([])
  51. const userType = uni.getStorageSync('userType') //读取本地存储
  52. const data = reactive({
  53. address: '重庆市永川区',
  54. queryValue: ''
  55. })
  56. const list3 = ref([
  57. '/static/img/68c51cda626f732e5a6a782e245ac255.jpeg',
  58. '/static/img/78f89f319f760ba84a5b86916612a99d.jpeg',
  59. '/static/img/e88c34398a054556e59659f4b7b83e8e.jpeg',
  60. ]);
  61. const getList = async () => {
  62. try {
  63. const res = await volunteerinfolist();
  64. if (!res || !res.rows) {
  65. return;
  66. }
  67. let leftArr = [];
  68. let rightArr = [];
  69. (res.rows || []).forEach((item, index) => {
  70. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  71. });
  72. listData.value = leftArr;
  73. rightList.value = rightArr;
  74. total.value = res.rows;
  75. } catch (error) {
  76. console.error('Error fetching data:', error);
  77. }
  78. };
  79. onShow(() => {
  80. getList()
  81. })
  82. </script>
  83. <style scoped lang="scss">
  84. .main-content {
  85. .home-banner {
  86. display: flex;
  87. align-items: center;
  88. justify-content: space-between;
  89. background: rgba(255, 255, 255, 1);
  90. 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);
  91. padding: 20rpx 16rpx;
  92. }
  93. .home-banner-left {
  94. display: flex;
  95. align-items: center;
  96. }
  97. .home-main {
  98. padding: 12px 16px;
  99. .custom-swiper {}
  100. .home-grid {
  101. margin-bottom: 32px;
  102. }
  103. }
  104. .home-ranking {
  105. padding: 12px 16px;
  106. }
  107. }
  108. </style>