index.vue 2.7 KB

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