goodsList.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="product-list">
  3. <view class="product" v-for="(product, index) in productList" :key="index">
  4. <view class="image-view">
  5. <image class="product-image" :src="product.goodsThumbnailUrl"></image>
  6. </view>
  7. <view :class="['product-title','ellipsis' + long]">{{ product.goodsName }}</view>
  8. <view class="product-price">
  9. <text class="product-price-original"
  10. ><text class="product-unit">¥</text>{{ product.price }}</text
  11. >
  12. <!-- <text class="product-price-favour">¥{{product.originalPrice}}</text> -->
  13. <!-- <text class="product-tip">{{product.tip}}</text> -->
  14. </view>
  15. <view class="product-txt">{{ product.fanIntegral }}</view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { get, post } from "@/request/api.js";
  21. export default {
  22. name: "goodslist",
  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(action = "add") {
  43. post(this.url).then((res) => {
  44. if (res.status == 200) {
  45. this.productList = res.goods;
  46. }
  47. });
  48. if (action === "refresh") {
  49. this.productList = [];
  50. }
  51. },
  52. },
  53. };
  54. </script>
  55. <style lang="scss" scoped>
  56. .product-list {
  57. padding: 0 20rpx;
  58. display: flex;
  59. width: 100%;
  60. flex-wrap: wrap;
  61. flex-direction: row;
  62. }
  63. .product {
  64. width: 50%;
  65. padding: 20rpx 10rpx;
  66. display: flex;
  67. flex-direction: column;
  68. }
  69. .product-image {
  70. border-radius: 10rpx 10rpx 0 0;
  71. width: 100%;
  72. height: 260rpx;
  73. object-fit: cover;
  74. }
  75. .product-title {
  76. width: 100%;
  77. overflow: hidden;
  78. line-height: 1.5;
  79. }
  80. .product-price {
  81. color: #121212;
  82. font-size: 28rpx;
  83. position: relative;
  84. }
  85. .product-price-original {
  86. color: #18bb88;
  87. }
  88. .product-price-favour {
  89. color: #888888;
  90. text-decoration: line-through;
  91. margin-left: 10upx;
  92. }
  93. .product-tip {
  94. position: absolute;
  95. right: 10upx;
  96. background-color: #ff3333;
  97. color: #ffffff;
  98. padding: 0 10upx;
  99. border-radius: 5upx;
  100. }
  101. .product-unit {
  102. font-size: 24rpx;
  103. }
  104. .product-txt {
  105. font-size: 22rpx;
  106. color: #787878;
  107. }
  108. </style>