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

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