Side_index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view v-if="userType == 1">
  3. <up-waterfall v-model="flowList">
  4. <template v-slot:left="{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.name}}
  10. </view>
  11. <view class="demo-PriceDome">
  12. <image :src="item.image" mode="aspectFill" class="demo-img" />
  13. <view class="demo-price">
  14. {{item.price}}
  15. </view>
  16. <view class="dome-Like">
  17. <image src="/static/爱心.png" class="Wrapper-img"
  18. style="width: 40rpx; height: 40rpx;" />
  19. <text>1.4w</text>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <template v-slot:right="{rightList}">
  25. <view class="demo-warter" v-for="(item, index) in rightList" :key="index">
  26. <up-lazy-load threshold="-450" border-radius="10" :image="item.image"
  27. :index="index"></up-lazy-load>
  28. <view class="demo-title">
  29. {{item.title}}
  30. </view>
  31. <view class="demo-PriceDome">
  32. <image :src="item.image" mode="aspectFill" class="demo-img" />
  33. <view class="demo-price">
  34. {{item.price}}
  35. </view>
  36. <view class="dome-Like">
  37. <image src="/static/爱心.png" class="Wrapper-img"
  38. style="width: 40rpx; height: 40rpx;" />
  39. <text>1.4w</text>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. </up-waterfall>
  45. <!-- <up-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></up-loadmore> -->
  46. </view>
  47. <view class="container" v-else-if="userType == 2">
  48. <view v-for="(item, index) in list" :key="index" class="item">
  49. <!-- 左侧:图片 -->
  50. <view class="Wrap-img">
  51. <image :src="item.image" mode="aspectFit" class="image"></image>
  52. </view>
  53. <!-- 中间:姓名、分类、技能介绍 -->
  54. <view class="middle">
  55. <view class="name">姓名:{{ item.name }}</view>
  56. <view class="category">类别:{{ item.category }}</view>
  57. <view class="title">技能介绍:{{ item.title }}</view>
  58. </view>
  59. <!-- 右侧:评分 + 按钮 -->
  60. <view class="right">
  61. <view class="score">评分:{{ item.score }}</view>
  62. <up-button type="error" text="购买" size="mini" custom-style="
  63. width: 120rpx;
  64. height: 50rpx;
  65. font-size: 24rpx;
  66. border-radius: 25rpx;
  67. margin-left: 40rpx;
  68. "></up-button>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script setup>
  74. import {
  75. ref,
  76. onMounted
  77. } from 'vue';
  78. import {volunteerinfolist} from "@/api/volunteerDetailsApi/details.js"
  79. const flowList = ref([]); //list数据
  80. const loadStatus = ref('loadmore');
  81. const userType = uni.getStorageSync('userType') //读取本地存储
  82. const listData = ref([])
  83. const getList = async() =>{
  84. const res = await volunteerinfolist()
  85. console.log(res,'>>>>>')
  86. listData.value = res.data
  87. }
  88. const list = ref([{
  89. price: '王老板',
  90. title: '北国风光,千里冰封,万里雪飘北国风光,千里冰封,万里雪飘北国风光,千里冰封,万里雪飘',
  91. // shop: '李白杜甫白居易旗舰店',
  92. image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg',
  93. img: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg'
  94. },
  95. {
  96. price: '李老板',
  97. title: '望长城内外,惟余莽莽北国风光,千里冰封,万里雪飘、望长城内外,惟余莽莽北国风光,千里冰封,万里雪飘',
  98. // shop: '李白杜甫白居易旗舰店',
  99. image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23325_s.jpg',
  100. img: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg'
  101. },
  102. ]);
  103. // const addRandomData = () => {
  104. // const newItems = []
  105. // for (let i = 0; i < 10; i++) {
  106. // const index = Math.floor(Math.random() * list.value.length)
  107. // newItems.push({
  108. // ...list.value[index],
  109. // id: generateId()
  110. // })
  111. // }
  112. // flowList.value = [...flowList.value, ...newItems] // 替换为新数组
  113. // }
  114. // const remove = (id) => {
  115. // const index = flowList.value.findIndex(item => item.id === id);
  116. // if (index !== -1) {
  117. // flowList.value.splice(index, 1);
  118. // }
  119. // };
  120. // const generateId = () => {
  121. // return Math.random().toString(36).substr(2, 9); // 生成一个随机ID
  122. // };
  123. const goToDetail = (item) => {
  124. console.log(item, '>>>>>>>>>详情事件');
  125. const itemInfo = encodeURIComponent(JSON.stringify(item))
  126. uni.navigateTo({
  127. url: `/pages/goodsDetails/goodsDetails?itemInfo=${itemInfo}`
  128. });
  129. }
  130. onMounted(() => {
  131. // addRandomData();
  132. getList()
  133. });
  134. </script>
  135. <style scoped>
  136. .demo-warter {
  137. border-radius: 8px;
  138. margin: 5px;
  139. background-color: #ffffff;
  140. padding: 5px;
  141. /* position: relative; */
  142. }
  143. .u-close {
  144. position: absolute;
  145. top: 32rpx;
  146. right: 32rpx;
  147. }
  148. .demo-image {
  149. width: 100%;
  150. border-radius: 4px;
  151. }
  152. .demo-title {
  153. font-size: 30rpx;
  154. margin-top: 5px;
  155. color: $up-main-color;
  156. margin-left: 15rpx;
  157. /* 添加以下样式 */
  158. display: -webkit-box;
  159. -webkit-box-orient: vertical;
  160. -webkit-line-clamp: 2;
  161. /* 限制显示两行 */
  162. overflow: hidden;
  163. text-overflow: ellipsis;
  164. /* 超出部分显示省略号 */
  165. word-break: break-all;
  166. }
  167. .demo-img {
  168. width: 40rpx;
  169. height: 40rpx;
  170. border-radius: 50%;
  171. }
  172. .demo-PriceDome {
  173. display: flex;
  174. font-size: 30rpx;
  175. color: $up-type-error;
  176. margin-top: 5px;
  177. margin-top: 20rpx;
  178. }
  179. .dome-Like {
  180. margin-left: 80rpx;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. }
  185. /* 志愿者列表 */
  186. /* 容器样式 */
  187. .container {
  188. padding: 20rpx;
  189. }
  190. /* 每个 item 使用 Flex 布局 */
  191. .item {
  192. display: flex;
  193. align-items: flex-start;
  194. margin-bottom: 30rpx;
  195. padding: 20rpx;
  196. border: 1rpx solid #eee;
  197. border-radius: 16rpx;
  198. }
  199. /* 图片固定宽度 */
  200. .image {
  201. width: 230rpx;
  202. height: 180rpx;
  203. border-radius: 8rpx;
  204. margin-right: 20rpx;
  205. }
  206. /* 中间部分:自动填充剩余空间 */
  207. .middle {
  208. flex: 1;
  209. margin-right: 20rpx;
  210. }
  211. /* 姓名样式 */
  212. .name {
  213. font-weight: bold;
  214. font-size: 32rpx;
  215. margin-bottom: 8rpx;
  216. }
  217. /* 分类样式 */
  218. .category {
  219. color: #666;
  220. font-size: 28rpx;
  221. margin-bottom: 8rpx;
  222. }
  223. .title {
  224. font-size: 28rpx;
  225. color: #888;
  226. line-height: 1.4;
  227. display: -webkit-box;
  228. -webkit-box-orient: vertical;
  229. -webkit-line-clamp: 2;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. word-break: break-all;
  233. /* 可选:长单词强制换行 */
  234. }
  235. /* 右侧:评分和按钮 */
  236. .right {
  237. display: flex;
  238. flex-direction: column;
  239. align-items: flex-end;
  240. min-width: 160rpx;
  241. }
  242. /* 评分样式 */
  243. .score {
  244. color: orange;
  245. font-size: 28rpx;
  246. margin-bottom: 10rpx;
  247. height: 120rpx;
  248. }
  249. </style>