Side_index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.image"
  7. :index="index"></up-lazy-load>
  8. <view class="demo-title">
  9. {{item.skillDescribe}}
  10. </view>
  11. <view class="demo-PriceDome">
  12. <view class="demo-price">
  13. <image src="../../static/用户.png" class="name-image"></image>
  14. {{item.name}}
  15. </view>
  16. <view class="dome-Like">
  17. <text style="font-size: 25rpx; color: red;" >¥</text>
  18. <text style="font-size: 35rpx; color: red;">1.4w</text>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <template #right :rightList="rightList">
  24. <view class="demo-warter" v-for="(item, index) in rightList" :key="index" @click="goToDetail(item)">
  25. <up-lazy-load threshold="-450" border-radius="10" :image="item.image"
  26. :index="index"></up-lazy-load>
  27. <view class="demo-title">
  28. {{item.skillDescribe}}
  29. </view>
  30. <view class="demo-PriceDome">
  31. <view class="demo-price">
  32. <image src="../../static/用户.png" class="name-image"></image>
  33. {{item.name}}
  34. </view>
  35. <view class="dome-Like">
  36. <text style="font-size: 25rpx; color: red;" >¥</text>
  37. <text style="font-size: 35rpx; color: red;">1.4w</text>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. </up-waterfall>
  43. <!-- <up-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></up-loadmore> -->
  44. </view>
  45. <!-- 志愿者 -->
  46. <view class="container" v-else-if="userType == '2'">
  47. <view v-for="(item, index) in list" :key="index" class="item">
  48. <!-- 左侧:图片 -->
  49. <view class="Wrap-img">
  50. <image :src="item.image" mode="aspectFit" class="image"></image>
  51. </view>
  52. <!-- 中间:姓名、分类、技能介绍 -->
  53. <view class="middle">
  54. <view class="name">姓名:{{ item.name }}</view>
  55. <view class="category">类别:{{ item.category }}</view>
  56. <view class="title">技能介绍:{{ item.title }}</view>
  57. </view>
  58. <!-- 右侧:评分 + 按钮 -->
  59. <view class="right">
  60. <view class="score">评分:{{ item.score }}</view>
  61. <up-button type="error" text="购买" size="mini" custom-style="
  62. width: 120rpx;
  63. height: 50rpx;
  64. font-size: 24rpx;
  65. border-radius: 25rpx;
  66. margin-left: 40rpx;
  67. "></up-button>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script setup>
  73. import {
  74. ref,
  75. onMounted,
  76. nextTick
  77. } from 'vue';
  78. import {
  79. onShow
  80. } from '@dcloudio/uni-app'
  81. import {volunteerinfolist,getDetailsvolunteerId} from "@/api/volunteerDetailsApi/details.js"
  82. const flowList = ref([]); //list数据
  83. const loadStatus = ref('loadmore');
  84. const userType = uni.getStorageSync('userType') //读取本地存储
  85. // 用户/志愿者 识别标识
  86. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  87. const listData = ref([])
  88. const rightList = ref([])
  89. const getList = async() =>{
  90. const res = await volunteerinfolist()
  91. console.log(res,'>>>>>222')
  92. // 处理左右数据展示
  93. let leftArr = []
  94. let rightArr = []
  95. console.log(res.data, '>>>res.data');
  96. (res.data || []).forEach((item, index) => {
  97. index%2 != 0 ? leftArr.push(item) : rightArr.push(item)
  98. })
  99. listData.value = leftArr
  100. rightList.value = rightArr
  101. console.log(rightList.value,'>>>>>>>>>rightList.value')
  102. }
  103. const goToDetail = async(item) => {
  104. console.log("11111")
  105. const volunteerId = item.volunteerId; // 获取具体的 volunteerId
  106. uni.navigateTo({
  107. url: `/pages/goodsDetails/goodsDetails?volunteerId=${volunteerId}`
  108. });
  109. }
  110. onShow(() => {
  111. getList()
  112. })
  113. </script>
  114. <style scoped>
  115. .demo-warter {
  116. border-radius: 8px;
  117. margin: 5px;
  118. background-color: #ffffff;
  119. padding: 5px;
  120. }
  121. .u-close {
  122. position: absolute;
  123. top: 32rpx;
  124. right: 32rpx;
  125. }
  126. .demo-image {
  127. width: 100%;
  128. border-radius: 4px;
  129. }
  130. .demo-title {
  131. font-size: 30rpx;
  132. margin-top: 5px;
  133. color: $up-main-color;
  134. margin-left: 15rpx;
  135. /* 添加以下样式 */
  136. display: -webkit-box;
  137. -webkit-box-orient: vertical;
  138. -webkit-line-clamp: 2;
  139. /* 限制显示两行 */
  140. overflow: hidden;
  141. text-overflow: ellipsis;
  142. /* 超出部分显示省略号 */
  143. word-break: break-all;
  144. }
  145. .demo-img {
  146. width: 40rpx;
  147. height: 40rpx;
  148. border-radius: 50%;
  149. }
  150. .demo-PriceDome {
  151. display: flex;
  152. font-size: 30rpx;
  153. color: $up-type-error;
  154. /* margin-top: 5px; */
  155. margin-top: 20rpx;
  156. }
  157. .demo-price{
  158. display: flex;
  159. }
  160. .name-image{
  161. width: 40rpx;
  162. height: 40rpx;
  163. }
  164. .dome-Like {
  165. margin-left: 120rpx;
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. }
  170. /* 志愿者列表 */
  171. /* 容器样式 */
  172. .container {
  173. padding: 20rpx;
  174. }
  175. /* 每个 item 使用 Flex 布局 */
  176. .item {
  177. display: flex;
  178. align-items: flex-start;
  179. margin-bottom: 30rpx;
  180. padding: 20rpx;
  181. border: 1rpx solid #eee;
  182. border-radius: 16rpx;
  183. }
  184. /* 图片固定宽度 */
  185. .image {
  186. width: 230rpx;
  187. height: 180rpx;
  188. border-radius: 8rpx;
  189. margin-right: 20rpx;
  190. }
  191. /* 中间部分:自动填充剩余空间 */
  192. .middle {
  193. flex: 1;
  194. margin-right: 20rpx;
  195. }
  196. /* 姓名样式 */
  197. .name {
  198. font-weight: bold;
  199. font-size: 32rpx;
  200. margin-bottom: 8rpx;
  201. }
  202. /* 分类样式 */
  203. .category {
  204. color: #666;
  205. font-size: 28rpx;
  206. margin-bottom: 8rpx;
  207. }
  208. .title {
  209. font-size: 28rpx;
  210. color: #888;
  211. line-height: 1.4;
  212. display: -webkit-box;
  213. -webkit-box-orient: vertical;
  214. -webkit-line-clamp: 2;
  215. overflow: hidden;
  216. text-overflow: ellipsis;
  217. word-break: break-all;
  218. /* 可选:长单词强制换行 */
  219. }
  220. /* 右侧:评分和按钮 */
  221. .right {
  222. display: flex;
  223. flex-direction: column;
  224. align-items: flex-end;
  225. min-width: 160rpx;
  226. }
  227. /* 评分样式 */
  228. .score {
  229. color: orange;
  230. font-size: 28rpx;
  231. margin-bottom: 10rpx;
  232. height: 120rpx;
  233. }
  234. </style>