goodsList.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="product-list">
  3. <view class="product" v-for="(i, s) in productList" :key="s" @click="NavToGoodsDetail(i.goodsId,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.goodsName }}</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">{{ i.fanIntegral }}</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. },
  33. data() {
  34. return {
  35. productList: [], //商品数据
  36. };
  37. },
  38. created() {
  39. this.loadData();
  40. },
  41. methods: {
  42. loadData() {
  43. post(this.url).then((res) => {
  44. if (res.status == 200) {
  45. this.productList = res.goods;
  46. }
  47. });
  48. },
  49. // 跳转到商品详情页
  50. NavToGoodsDetail(id,type){
  51. uni.navigateTo({
  52. url:'/pages/product/p_details?id=' + id + '&type=' + type
  53. })
  54. },
  55. },
  56. };
  57. </script>
  58. <style lang="scss" scoped>
  59. .product-list {
  60. padding: 0 20rpx;
  61. display: flex;
  62. width: 100%;
  63. flex-wrap: wrap;
  64. flex-direction: row;
  65. }
  66. .product {
  67. width: 50%;
  68. padding: 20rpx 10rpx;
  69. display: flex;
  70. flex-direction: column;
  71. }
  72. .product-image {
  73. border-radius: 10rpx 10rpx 0 0;
  74. width: 100%;
  75. height: 260rpx;
  76. object-fit: cover;
  77. }
  78. .product-title {
  79. width: 100%;
  80. overflow: hidden;
  81. line-height: 1.5;
  82. }
  83. .product-price {
  84. color: #121212;
  85. font-size: 28rpx;
  86. position: relative;
  87. }
  88. .product-price-original {
  89. color: #18bb88;
  90. }
  91. .product-price-favour {
  92. color: #888888;
  93. text-decoration: line-through;
  94. margin-left: 10upx;
  95. }
  96. .product-tip {
  97. position: absolute;
  98. right: 10upx;
  99. background-color: #ff3333;
  100. color: #ffffff;
  101. padding: 0 10upx;
  102. border-radius: 5upx;
  103. }
  104. .product-unit {
  105. font-size: 24rpx;
  106. }
  107. .product-txt {
  108. font-size: 22rpx;
  109. color: #787878;
  110. }
  111. </style>