Side_index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view v-if="userType == '1'">
  3. <up-waterfall v-model="flowList">
  4. <template #left :listData="listData">
  5. <view class="demo-warter" v-for="(item, index) in listData" :key="index" @click="goToDetail(item)">
  6. <up-lazy-load threshold="-450" border-radius="10" :image="item.volunteerPicture" :index="index"></up-lazy-load>
  7. <view class="demo-title">
  8. {{item.skillDescribe}}
  9. </view>
  10. <view class="demo-PriceDome">
  11. <view class="demo-price">
  12. <image :src="item.volunteerPicture" class="name-image"></image>
  13. {{item.name}}
  14. </view>
  15. <view class="dome-Like">
  16. <text style="font-size: 25rpx; color: red;">¥</text>
  17. <text style="font-size: 35rpx; color: red;">1.4w</text>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <template #right :rightList="rightList">
  23. <view class="demo-warter" v-for="(item, index) in rightList" :key="index" @click="goToDetail(item)">
  24. <up-lazy-load threshold="-450" border-radius="10" :image="item.volunteerPicture" :index="index"></up-lazy-load>
  25. <view class="demo-title">
  26. {{item.skillDescribe}}
  27. </view>
  28. <view class="demo-PriceDome">
  29. <view class="demo-price">
  30. <image :src="item.volunteerPicture" class="name-image"></image>
  31. {{item.name}}
  32. </view>
  33. <view class="dome-Like">
  34. <text style="font-size: 25rpx; color: red;">¥</text>
  35. <text style="font-size: 35rpx; color: red;">1.4w</text>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. </up-waterfall>
  41. </view>
  42. </template>
  43. <script setup>
  44. import {
  45. ref,
  46. onMounted,
  47. nextTick
  48. } from 'vue';
  49. import {
  50. onShow
  51. } from '@dcloudio/uni-app'
  52. import {
  53. volunteerinfolist,
  54. getDetailsvolunteerId
  55. } from "@/api/volunteerDetailsApi/details.js"
  56. const flowList = ref([]); //list数据
  57. const loadStatus = ref('loadmore');
  58. const userType = uni.getStorageSync('userType') //读取本地存储
  59. // 用户/志愿者 识别标识
  60. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  61. const listData = ref([])
  62. const rightList = ref([])
  63. const getList = async () => {
  64. const res = await volunteerinfolist()
  65. // 处理左右数据展示
  66. let leftArr = []
  67. let rightArr = []
  68. console.log(res.data, '>>>res.data');
  69. (res.data || []).forEach((item, index) => {
  70. index % 2 != 0 ? leftArr.push(item) : rightArr.push(item)
  71. })
  72. listData.value = leftArr
  73. rightList.value = rightArr
  74. }
  75. const goToDetail = async (item) => {
  76. const params = {
  77. volunteerId: item.volunteerId, // 获取 volunteerId
  78. serviceCategory: item.serviceCategory // 获取 serviceCategory
  79. };
  80. // 使用 JSON.stringify 将对象传递给 URL 参数
  81. uni.navigateTo({
  82. url: `/pages/goodsDetails/goodsDetails?params=${JSON.stringify(params)}`
  83. });
  84. }
  85. onShow(() => {
  86. getList()
  87. })
  88. </script>
  89. <style scoped>
  90. .demo-warter {
  91. border-radius: 8px;
  92. margin: 5px;
  93. background-color: #ffffff;
  94. padding: 5px;
  95. }
  96. .u-close {
  97. position: absolute;
  98. top: 32rpx;
  99. right: 32rpx;
  100. }
  101. .demo-image {
  102. width: 100%;
  103. border-radius: 4px;
  104. }
  105. .demo-title {
  106. font-size: 30rpx;
  107. margin-top: 5px;
  108. color: $up-main-color;
  109. /* margin-left: 15rpx; */
  110. display: -webkit-box;
  111. -webkit-box-orient: vertical;
  112. -webkit-line-clamp: 3;
  113. overflow: hidden;
  114. text-overflow: ellipsis;
  115. word-break: break-all;
  116. }
  117. .demo-img {
  118. width: 40rpx;
  119. height: 40rpx;
  120. border-radius: 50%;
  121. }
  122. .demo-PriceDome {
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: center;
  126. width: 100%;
  127. margin-top: 15rpx;
  128. }
  129. .demo-price {
  130. display: flex;
  131. align-items: center;
  132. flex: 1;
  133. overflow: hidden; /* 防止内容溢出 */
  134. }
  135. .name-image {
  136. width: 40rpx;
  137. height: 40rpx;
  138. margin-right: 10rpx;
  139. }
  140. .name-text {
  141. white-space: nowrap; /* 禁止换行 */
  142. overflow: hidden; /* 超出部分隐藏 */
  143. text-overflow: ellipsis; /* 显示省略号 */
  144. max-width: 120rpx; /* 6个中文字符大约占120rpx */
  145. }
  146. .dome-Like {
  147. display: flex;
  148. align-items: baseline; /* 让¥和1.4w底部对齐 */
  149. }
  150. </style>