goodsList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="product-list">
  3. <view class="product" v-for="(i, s) in productList" :key="s" @click="NavToGoodsDetail(i.id,i.type)">
  4. <view class="image-view">
  5. <image class="product-image" :src="i.goodsThumbnailUrl"></image>
  6. </view>
  7. <view :class="['product-title', 'ellipsis' + long]">{{ i.goods.goods_name }}</view>
  8. <view class="product-price">
  9. <text class="product-price-original"><text class="product-unit">¥</text>{{ type == 2 ? i.trade_price : i.cost_price }}</text>
  10. <!-- <text class="product-price-favour">¥{{i.originalPrice}}</text> -->
  11. <!-- <text class="product-tip">{{i.tip}}</text> -->
  12. </view>
  13. <view class="product-txt">{{ i.trade_give_num }}</view>
  14. </view>
  15. <view class='fz_w_text mar_t20 mar_b20'>茶,让生活更美好!</view>
  16. </view>
  17. </template>
  18. <script>
  19. import { get, post, u_post } from "@/request/api.js";
  20. export default {
  21. name: "goodslist",
  22. components: {},
  23. props: {
  24. long: {
  25. type: Number,
  26. default: 2,
  27. },
  28. url: {
  29. type: String,
  30. default: "",
  31. },
  32. type: {
  33. type: String,
  34. default: "3",
  35. },
  36. },
  37. data() {
  38. return {
  39. productList: [], //商品数据
  40. };
  41. },
  42. created() {
  43. this.loadData();
  44. },
  45. methods: {
  46. loadData(page) {
  47. post("goods/goodsList",{
  48. type: this.type,
  49. page: page ? page : 1
  50. }).then((res) => {
  51. if(page == 1) this.productList = []
  52. if (res.code === 0) {
  53. console.log(res);
  54. this.productList = [...this.productList,...res.data.data]
  55. }
  56. });
  57. },
  58. // 跳转到商品详情页
  59. NavToGoodsDetail(id,type){
  60. uni.navigateTo({
  61. url:'/pages/product/p_details?id=' + id + '&type=' + this.type
  62. })
  63. },
  64. },
  65. };
  66. </script>
  67. <style lang="scss" scoped>
  68. .product-list {
  69. padding: 0 20rpx;
  70. display: flex;
  71. width: 100%;
  72. flex-wrap: wrap;
  73. flex-direction: row;
  74. }
  75. .product {
  76. width: 50%;
  77. padding: 20rpx 10rpx;
  78. display: flex;
  79. flex-direction: column;
  80. }
  81. .product-image {
  82. border-radius: 10rpx 10rpx 0 0;
  83. width: 100%;
  84. height: 260rpx;
  85. object-fit: cover;
  86. }
  87. .product-title {
  88. width: 100%;
  89. overflow: hidden;
  90. line-height: 1.5;
  91. }
  92. .product-price {
  93. color: #121212;
  94. font-size: 28rpx;
  95. position: relative;
  96. }
  97. .product-price-original {
  98. color: #18bb88;
  99. }
  100. .product-price-favour {
  101. color: #888888;
  102. text-decoration: line-through;
  103. margin-left: 10upx;
  104. }
  105. .product-tip {
  106. position: absolute;
  107. right: 10upx;
  108. background-color: #ff3333;
  109. color: #ffffff;
  110. padding: 0 10upx;
  111. border-radius: 5upx;
  112. }
  113. .product-unit {
  114. font-size: 24rpx;
  115. }
  116. .product-txt {
  117. font-size: 22rpx;
  118. color: #787878;
  119. }
  120. </style>