敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.1 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="list">
  3. <view class="item" v-for="(item, index) in list"
  4. @click="$utils.navigateTo('/pages_order/product/productDetail?id=' + item.id)" :key="index">
  5. <image class="image" :src="item.image &&
  6. item.image.split(',')[0]" mode="aspectFill"></image>
  7. <view class="product-info">
  8. <view class="product-title">
  9. {{ item.title }}
  10. </view>
  11. <view class="product-main">
  12. <view class="sale-information">
  13. <view style="display: flex;align-items: flex-end;">
  14. <view class="price">
  15. <text>{{ item.price }}</text>/
  16. </view>
  17. <view class="oldPrice">
  18. <text>{{ item.oldPrice }}</text>
  19. </view>
  20. </view>
  21. <view class="num">
  22. 已售卖{{ item.payNum }}+
  23. </view>
  24. </view>
  25. <view @click.stop="purchase(item.id)" class="btn">
  26. 购买
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. name: "productList",
  37. props: {
  38. list: {
  39. default: []
  40. },
  41. },
  42. data() {
  43. return {
  44. };
  45. },
  46. methods: {
  47. // 购买商品(创建订单)
  48. purchase(id) {
  49. this.$api('getRiceProductDetail', {
  50. id
  51. }, res => {
  52. if (res.code == 200) {
  53. res.result.num = 1
  54. this.$store.commit('setPayOrderProduct', [
  55. res.result
  56. ])
  57. this.$utils.navigateTo('/pages_order/order/createOrder')
  58. }
  59. })
  60. },
  61. },
  62. }
  63. </script>
  64. <style scoped lang="scss">
  65. .list {
  66. display: flex;
  67. flex-wrap: wrap;
  68. .item {
  69. position: relative;
  70. width: 345rpx;
  71. padding: 20rpx;
  72. box-sizing: border-box;
  73. background-color: #fff;
  74. border-radius: 20rpx;
  75. margin-left: 20rpx;
  76. margin-bottom: 20rpx;
  77. .image {
  78. width: 300rpx;
  79. height: 250rpx;
  80. border-radius: 20rpx;
  81. }
  82. .product-info {
  83. font-size: 24rpx;
  84. .product-title {
  85. font-weight: bold;
  86. display: -webkit-box;
  87. /* 兼容WebKit内核浏览器 */
  88. -webkit-line-clamp: 2;
  89. /* 显示最大3行 */
  90. -webkit-box-orient: vertical;
  91. /* 设置垂直方向上的排列方式 */
  92. overflow: hidden;
  93. /* 隐藏溢出内容 */
  94. text-overflow: ellipsis;
  95. /* 当文本溢出时显示省略号 */
  96. }
  97. .product-main {
  98. display: flex;
  99. align-items: flex-end;
  100. .sale-information {
  101. width: 75%;
  102. .title {
  103. font-size: 28rpx;
  104. overflow: hidden; //超出的文本隐藏
  105. text-overflow: ellipsis; //溢出用省略号显示
  106. white-space: nowrap; //溢出不换行
  107. }
  108. .price {
  109. color: $uni-color;
  110. margin-top: 6rpx;
  111. text {
  112. font-size: 30rpx;
  113. font-weight: 900;
  114. }
  115. }
  116. .oldPrice {
  117. color: #888;
  118. text-decoration: line-through;
  119. }
  120. .num {
  121. margin-top: 6rpx;
  122. font-size: 22rpx;
  123. color: #888;
  124. }
  125. }
  126. .btn {
  127. display: flex;
  128. align-items: center;
  129. justify-content: center;
  130. border-radius: 10rpx;
  131. font-size: 24rpx;
  132. height: 60rpx;
  133. width: 25%;
  134. color: #fff;
  135. background-color: $uni-color;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. </style>