Side_index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view v-if="userType == 1">
  3. <up-waterfall v-model="flowList">
  4. <template v-slot:left="{leftList}">
  5. <view class="demo-warter" v-for="(item, index) in leftList" :key="index">
  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.title}}
  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. const flowList = ref([]); //list数据
  79. const loadStatus = ref('loadmore');
  80. const userType = uni.getStorageSync('userType') //读取本地存储
  81. const list = ref([{
  82. price: '王老板',
  83. title: '北国风光,千里冰封,万里雪飘北国风光,千里冰封,万里雪飘北国风光,千里冰封,万里雪飘',
  84. // shop: '李白杜甫白居易旗舰店',
  85. image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg',
  86. img: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg'
  87. },
  88. {
  89. price: '李老板',
  90. title: '望长城内外,惟余莽莽北国风光,千里冰封,万里雪飘、望长城内外,惟余莽莽北国风光,千里冰封,万里雪飘',
  91. // shop: '李白杜甫白居易旗舰店',
  92. image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23325_s.jpg',
  93. img: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg'
  94. },
  95. ]);
  96. const addRandomData = () => {
  97. const newItems = []
  98. for (let i = 0; i < 10; i++) {
  99. const index = Math.floor(Math.random() * list.value.length)
  100. newItems.push({
  101. ...list.value[index],
  102. id: generateId()
  103. })
  104. }
  105. flowList.value = [...flowList.value, ...newItems] // 替换为新数组
  106. }
  107. const remove = (id) => {
  108. const index = flowList.value.findIndex(item => item.id === id);
  109. if (index !== -1) {
  110. flowList.value.splice(index, 1);
  111. }
  112. };
  113. const onReachBottom = () => {
  114. loadStatus.value = 'loading';
  115. setTimeout(() => {
  116. addRandomData();
  117. loadStatus.value = 'loadmore';
  118. }, 1000);
  119. };
  120. const generateId = () => {
  121. return Math.random().toString(36).substr(2, 9); // 生成一个随机ID
  122. };
  123. onMounted(() => {
  124. addRandomData();
  125. });
  126. </script>
  127. <style scoped>
  128. .demo-warter {
  129. border-radius: 8px;
  130. margin: 5px;
  131. background-color: #ffffff;
  132. padding: 5px;
  133. /* position: relative; */
  134. }
  135. .u-close {
  136. position: absolute;
  137. top: 32rpx;
  138. right: 32rpx;
  139. }
  140. .demo-image {
  141. width: 100%;
  142. border-radius: 4px;
  143. }
  144. .demo-title {
  145. font-size: 30rpx;
  146. margin-top: 5px;
  147. color: $up-main-color;
  148. margin-left: 15rpx;
  149. /* 添加以下样式 */
  150. display: -webkit-box;
  151. -webkit-box-orient: vertical;
  152. -webkit-line-clamp: 2;
  153. /* 限制显示两行 */
  154. overflow: hidden;
  155. text-overflow: ellipsis;
  156. /* 超出部分显示省略号 */
  157. word-break: break-all;
  158. }
  159. .demo-img {
  160. width: 40rpx;
  161. height: 40rpx;
  162. border-radius: 50%;
  163. }
  164. .demo-PriceDome {
  165. display: flex;
  166. font-size: 30rpx;
  167. color: $up-type-error;
  168. margin-top: 5px;
  169. margin-top: 20rpx;
  170. }
  171. .dome-Like {
  172. margin-left: 80rpx;
  173. display: flex;
  174. justify-content: center;
  175. align-items: center;
  176. }
  177. /* 志愿者列表 */
  178. /* 容器样式 */
  179. .container {
  180. padding: 20rpx;
  181. }
  182. /* 每个 item 使用 Flex 布局 */
  183. .item {
  184. display: flex;
  185. align-items: flex-start;
  186. margin-bottom: 30rpx;
  187. padding: 20rpx;
  188. border: 1rpx solid #eee;
  189. border-radius: 16rpx;
  190. }
  191. /* 图片固定宽度 */
  192. .image {
  193. width: 230rpx;
  194. height: 180rpx;
  195. border-radius: 8rpx;
  196. margin-right: 20rpx;
  197. }
  198. /* 中间部分:自动填充剩余空间 */
  199. .middle {
  200. flex: 1;
  201. margin-right: 20rpx;
  202. }
  203. /* 姓名样式 */
  204. .name {
  205. font-weight: bold;
  206. font-size: 32rpx;
  207. margin-bottom: 8rpx;
  208. }
  209. /* 分类样式 */
  210. .category {
  211. color: #666;
  212. font-size: 28rpx;
  213. margin-bottom: 8rpx;
  214. }
  215. .title {
  216. font-size: 28rpx;
  217. color: #888;
  218. line-height: 1.4;
  219. display: -webkit-box;
  220. -webkit-box-orient: vertical;
  221. -webkit-line-clamp: 2;
  222. overflow: hidden;
  223. text-overflow: ellipsis;
  224. word-break: break-all;
  225. /* 可选:长单词强制换行 */
  226. }
  227. /* 右侧:评分和按钮 */
  228. .right {
  229. display: flex;
  230. flex-direction: column;
  231. align-items: flex-end;
  232. min-width: 160rpx;
  233. }
  234. /* 评分样式 */
  235. .score {
  236. color: orange;
  237. font-size: 28rpx;
  238. margin-bottom: 10rpx;
  239. height: 120rpx;
  240. }
  241. </style>