Side_index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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"
  7. :index="index"></up-lazy-load>
  8. <view class="demo-title">
  9. {{item.businessTierName}}
  10. </view>
  11. <view class="demo-skillDescribe">
  12. {{item.skillDescribe}}
  13. </view>
  14. <view class="demo-PriceDome">
  15. <view class="demo-price">
  16. <image :src="item.volunteerPicture" class="name-image"></image>
  17. {{item.name}}
  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"
  25. :index="index"></up-lazy-load>
  26. <view class="demo-title">
  27. {{item.businessTierName}}
  28. </view>
  29. <view class="demo-skillDescribe">
  30. {{item.skillDescribe}}
  31. </view>
  32. <view class="demo-PriceDome">
  33. <view class="demo-price">
  34. <image :src="item.volunteerPicture" class="name-image"></image>
  35. {{item.name}}
  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 total = ref(0)
  58. const loadStatus = ref('loadmore');
  59. const userType = uni.getStorageSync('userType') //读取本地存储
  60. // 用户/志愿者 识别标识
  61. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  62. const listData = ref([])
  63. const rightList = ref([])
  64. const getList = async () => {
  65. try {
  66. const res = await volunteerinfolist();
  67. if (!res || !res.rows) {
  68. console.error('No data returned from API');
  69. return;
  70. }
  71. let leftArr = [];
  72. let rightArr = [];
  73. (res.rows || []).forEach((item, index) => {
  74. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  75. });
  76. listData.value = leftArr;
  77. rightList.value = rightArr;
  78. total.value = res.rows;
  79. } catch (error) {
  80. console.error('Error fetching data:', error);
  81. }
  82. };
  83. const goToDetail = async (item) => {
  84. const params = {
  85. volunteerId: item.volunteerId, // 获取 volunteerId
  86. serviceCategory: item.serviceCategory, // 获取 serviceCategory
  87. businessManagementId: item.businessManagementId, //获取 businessManagementId
  88. };
  89. // 使用 JSON.stringify 将对象传递给 URL 参数
  90. uni.navigateTo({
  91. url: `/pages/goodsDetails/goodsDetails?params=${JSON.stringify(params)}`
  92. });
  93. }
  94. onShow(() => {
  95. getList()
  96. })
  97. </script>
  98. <style scoped>
  99. .demo-warter {
  100. border-radius: 8px;
  101. margin: 5px;
  102. background-color: #ffffff;
  103. padding: 5px;
  104. }
  105. .u-close {
  106. position: absolute;
  107. top: 32rpx;
  108. right: 32rpx;
  109. }
  110. .demo-image {
  111. width: 100%;
  112. border-radius: 4px;
  113. }
  114. .demo-title {
  115. font-size: 25rpx;
  116. margin-top: 5px;
  117. color: #ccc;
  118. /* margin-left: 15rpx; */
  119. display: -webkit-box;
  120. -webkit-box-orient: vertical;
  121. -webkit-line-clamp: 3;
  122. overflow: hidden;
  123. text-overflow: ellipsis;
  124. word-break: break-all;
  125. }
  126. .demo-skillDescribe{
  127. font-size: 30rpx;
  128. margin-top: 5px;
  129. color: black;
  130. /* margin-left: 15rpx; */
  131. display: -webkit-box;
  132. -webkit-box-orient: vertical;
  133. -webkit-line-clamp: 3;
  134. overflow: hidden;
  135. text-overflow: ellipsis;
  136. word-break: break-all;
  137. }
  138. .demo-img {
  139. width: 40rpx;
  140. height: 40rpx;
  141. border-radius: 50%;
  142. }
  143. .demo-PriceDome {
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. width: 100%;
  148. margin-top: 15rpx;
  149. }
  150. .demo-price {
  151. display: flex;
  152. align-items: center;
  153. flex: 1;
  154. overflow: hidden;
  155. /* 防止内容溢出 */
  156. }
  157. .name-image {
  158. width: 40rpx;
  159. height: 40rpx;
  160. margin-right: 10rpx;
  161. border-radius: 50%;
  162. }
  163. .name-text {
  164. white-space: nowrap;
  165. /* 禁止换行 */
  166. overflow: hidden;
  167. /* 超出部分隐藏 */
  168. text-overflow: ellipsis;
  169. /* 显示省略号 */
  170. max-width: 120rpx;
  171. /* 6个中文字符大约占120rpx */
  172. }
  173. </style>