goosList.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="list">
  3. <uni-list class="uni-list--waterfall">
  4. <!-- to 属性携带参数跳转详情页面,当前只为参考 -->
  5. <uni-list-item
  6. direction="column"
  7. :border="false"
  8. class="uni-list-item--waterfall"
  9. title="自定义商品列表"
  10. v-for="item in data"
  11. :key="item._id"
  12. :to="'/pages/detail/detail?id=' + item._id + '&title=' + item.name"
  13. >
  14. <!-- 通过header插槽定义列表左侧图片 -->
  15. <template v-slot:header>
  16. <view class="uni-thumb shop-picture shop-picture-column">
  17. <image :src="baseurl + item.thumbnail" mode="aspectFill"></image>
  18. </view>
  19. </template>
  20. <!-- 通过body插槽定义商品布局 -->
  21. <template v-slot:body>
  22. <view class="shop">
  23. <view>
  24. <view class="uni-title">
  25. <text class="uni-ellipsis-2">{{ item.name }}</text>
  26. </view>
  27. <view>
  28. <text class="uni-tag hot-tag">{{ item.type }}</text>
  29. <!-- <text v-for="tag in item.tag" :key="tag" class="uni-tag">{{
  30. tag
  31. }}</text> -->
  32. </view>
  33. </view>
  34. <view>
  35. <view class="shop-price">
  36. <text>¥</text>
  37. <text class="shop-price-text">{{ item.money }}</text>
  38. <text>.00</text>
  39. </view>
  40. <!-- <view class="uni-note">{{ item.integral }}</view> -->
  41. <view class="uni-note ellipsis">
  42. <text class="uni-ellipsis-1">积分: {{ item.integral }}</text>
  43. <text class="uni-link">详情 ></text>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. </uni-list-item>
  49. </uni-list>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. props: {
  55. // 数据内容
  56. data: { type: Array, default: () => [] },
  57. name: { type: String, default: "默认title" },
  58. },
  59. computed: {},
  60. data() {
  61. return {
  62. waterfall: false,
  63. baseurl: "http://192.168.0.45:9002",
  64. };
  65. },
  66. async mounted() {},
  67. methods: {
  68. async onClick(e) {
  69. console.log(e);
  70. },
  71. },
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. @import "@/static/uni-ui.scss";
  76. .uni-list-item--waterfall {
  77. width: 50%;
  78. box-sizing: border-box;
  79. }
  80. .shop {
  81. flex: 1;
  82. display: flex;
  83. flex-direction: column;
  84. justify-content: space-between;
  85. }
  86. .shop-picture {
  87. width: 110px;
  88. height: 110px;
  89. }
  90. .shop-picture-column {
  91. width: 100%;
  92. height: 170px;
  93. margin-bottom: 10px;
  94. }
  95. .shop-price {
  96. margin-top: 5px;
  97. font-size: 12px;
  98. color: #ff5a5f;
  99. }
  100. .shop-price-text {
  101. font-size: 16px;
  102. }
  103. .hot-tag {
  104. background: #ff5a5f;
  105. border: none;
  106. color: #fff;
  107. }
  108. .button-box {
  109. height: 30px;
  110. line-height: 30px;
  111. font-size: 12px;
  112. background: #007aff;
  113. color: #fff;
  114. }
  115. .uni-link {
  116. flex-shrink: 0;
  117. }
  118. .ellipsis {
  119. display: flex;
  120. overflow: hidden;
  121. }
  122. .uni-ellipsis-1 {
  123. overflow: hidden;
  124. white-space: nowrap;
  125. text-overflow: ellipsis;
  126. }
  127. .uni-ellipsis-2 {
  128. overflow: hidden;
  129. text-overflow: ellipsis;
  130. display: -webkit-box;
  131. -webkit-line-clamp: 2;
  132. -webkit-box-orient: vertical;
  133. }
  134. </style>