goodsList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.original_img"></image>
  6. </view>
  7. <view :class="['product-title', 'ellipsis' + long]">{{ i.goods_name }}</view>
  8. <view class="product-price">
  9. <text class="product-price-original"><text class="product-unit">¥</text>{{ i.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">{{ type == 3 ? i.give_cha_bao + "茶宝" : i.give_integral + "积分" }}</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. onShow(){},
  43. created() {
  44. // this.loadData();
  45. },
  46. mounted () {},
  47. methods: {
  48. loadData(page) {
  49. post("goods/goodsList",{
  50. type: this.type,
  51. page: page ? page : 1
  52. }).then((res) => {
  53. if(page == 1) this.productList = []
  54. if (res.code === 0) {
  55. console.log(res);
  56. this.productList = [...this.productList,...res.data.data]
  57. }
  58. });
  59. },
  60. // 跳转到商品详情页
  61. NavToGoodsDetail(id,type){
  62. uni.navigateTo({
  63. url:'/pages/product/p_details?id=' + id + '&type=' + this.type
  64. })
  65. },
  66. },
  67. };
  68. </script>
  69. <style lang="scss" scoped>
  70. .product-list {
  71. padding: 0 20rpx;
  72. display: flex;
  73. width: 100%;
  74. flex-wrap: wrap;
  75. flex-direction: row;
  76. }
  77. .product {
  78. width: 50%;
  79. padding: 20rpx 10rpx;
  80. display: flex;
  81. flex-direction: column;
  82. }
  83. .product-image {
  84. border-radius: 10rpx 10rpx 0 0;
  85. width: 100%;
  86. height: 260rpx;
  87. object-fit: cover;
  88. }
  89. .product-title {
  90. width: 100%;
  91. overflow: hidden;
  92. line-height: 1.5;
  93. }
  94. .product-price {
  95. color: #121212;
  96. font-size: 28rpx;
  97. position: relative;
  98. }
  99. .product-price-original {
  100. color: #18bb88;
  101. }
  102. .product-price-favour {
  103. color: #888888;
  104. text-decoration: line-through;
  105. margin-left: 10upx;
  106. }
  107. .product-tip {
  108. position: absolute;
  109. right: 10upx;
  110. background-color: #ff3333;
  111. color: #ffffff;
  112. padding: 0 10upx;
  113. border-radius: 5upx;
  114. }
  115. .product-unit {
  116. font-size: 24rpx;
  117. }
  118. .product-txt {
  119. font-size: 22rpx;
  120. color: #787878;
  121. }
  122. </style>