敢为人鲜小程序前端代码仓库
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.

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