普兆健康管家前端代码仓库
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.

139 lines
3.1 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view class="card product-card__view" :style="cardStyle" @click="jumpToProductDetail">
  3. <view class="card-img flex" :style="imgStyle">
  4. <!-- todo: check url key -->
  5. <image class="img" :src="data.url" mode="scaleToFill"></image>
  6. </view>
  7. <view class="card-detail">
  8. <view class="product-name">{{ data.name }}</view>
  9. <view class="product-sales" v-if="data.sold">{{ `已售出${data.sold}` }}</view>
  10. <view class="flex product-price">
  11. <view>
  12. <view class="product-price-val">
  13. <text>¥</text>
  14. <text class="highlight">{{ data.currentPrice }}</text>
  15. <text>{{ `/${data.unit}` }}</text>
  16. </view>
  17. <view class="product-price-bef" v-if="data.originalPrice">
  18. {{ `¥${data.originalPrice}/${data.unit}` }}
  19. </view>
  20. </view>
  21. <button class="btn flex" @click.stop="onAddCart(data.id)">
  22. <image class="btn-img" src="@/pages_order/static/report/plus.png" mode="widthFix"></image>
  23. </button>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. data: {
  32. type: Object,
  33. default() {
  34. return {}
  35. },
  36. },
  37. cardStyle: {
  38. type: String,
  39. default: '',
  40. },
  41. imgStyle: {
  42. type: String,
  43. default: '',
  44. }
  45. },
  46. methods: {
  47. onAddCart(id) {
  48. this.$store.commit('addCart', this.data)
  49. },
  50. jumpToProductDetail() {
  51. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${this.data.id}`)
  52. },
  53. },
  54. }
  55. </script>
  56. <style scoped lang="scss">
  57. .card {
  58. font-size: 0;
  59. height: 420rpx;
  60. background-image: linear-gradient(#FAFAFF, #F3F3F3);
  61. border: 2rpx solid #FFFFFF;
  62. border-radius: 32rpx;
  63. overflow: hidden;
  64. &-img {
  65. width: 100%;
  66. height: 220rpx;
  67. .img {
  68. width: 100%;
  69. height: 100%;
  70. }
  71. }
  72. &-detail {
  73. padding: 16rpx 24rpx 0 24rpx;
  74. .product {
  75. &-name {
  76. font-family: PingFang SC;
  77. font-weight: 600;
  78. font-size: 28rpx;
  79. line-height: 1.4;
  80. color: #000000;
  81. }
  82. &-sales {
  83. margin-top: 8rpx;
  84. font-family: PingFang SC;
  85. font-weight: 400;
  86. font-size: 24rpx;
  87. line-height: 1;
  88. color: #8B8B8B;
  89. }
  90. &-price {
  91. margin-top: 16rpx;
  92. justify-content: space-between;
  93. &-val {
  94. font-family: PingFang SC;
  95. font-weight: 600;
  96. font-size: 24rpx;
  97. line-height: 1.4;
  98. color: $uni-color;
  99. .highlight {
  100. font-size: 32rpx;
  101. margin: 0 8rpx;
  102. }
  103. }
  104. &-bef {
  105. margin-top: 4rpx;
  106. text-decoration: line-through;
  107. font-family: PingFang SC;
  108. font-weight: 400;
  109. font-size: 24rpx;
  110. line-height: 1;
  111. color: #8B8B8B;
  112. }
  113. .btn {
  114. width: 56rpx;
  115. height: 56rpx;
  116. border-radius: 50%;
  117. background: $uni-color;
  118. &-img {
  119. width: 20rpx;
  120. height: 20rpx;
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. </style>