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

138 lines
3.0 KiB

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