s-goods-item.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view>
  3. <view>
  4. <slot name="top"></slot>
  5. </view>
  6. <view class="ss-order-card-warp ss-flex ss-col-stretch ss-row-between bg-white"
  7. :style="[{ borderRadius: radius + 'rpx', marginBottom: marginBottom + 'rpx' }]">
  8. <view class="img-box ss-m-r-24">
  9. <image class="order-img" :src="sheep.$url.cdn(img)" mode="aspectFill"></image>
  10. </view>
  11. <view class="box-right ss-flex-col ss-row-between" :style="[{ width: titleWidth ? titleWidth + 'rpx' : '' }]">
  12. <view class="title-text ss-line-2" v-if="title">{{ title }}</view>
  13. <view v-if="skuString" class="spec-text ss-m-t-8 ss-m-b-12">{{ skuString }}</view>
  14. <view class="groupon-box">
  15. <slot name="groupon"></slot>
  16. </view>
  17. <view class="ss-flex">
  18. <view class="ss-flex ss-col-center">
  19. <!-- <view class="price-text ss-flex ss-col-center" :style="[{ color: priceColor }]"
  20. v-if="price && Number(price) > 0">
  21. ¥{{ fen2yuan(price) }}
  22. </view> -->
  23. <view v-if="point && Number(price) > 0">+</view>
  24. <view class="price-text ss-flex ss-col-center" v-if="point">
  25. <image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="point-img"></image>
  26. <view>{{ point }}</view>
  27. </view>
  28. <view v-if="num" class="total-text ss-flex ss-col-center">x {{ num }}</view>
  29. <slot name="priceSuffix"></slot>
  30. </view>
  31. </view>
  32. <view class="tool-box">
  33. <slot name="tool"></slot>
  34. </view>
  35. <view>
  36. <slot name="rightBottom"></slot>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup>
  43. import sheep from '@/sheep';
  44. import { computed } from 'vue';
  45. import { fen2yuan } from '@/sheep/hooks/useGoods';
  46. /**
  47. * 订单卡片
  48. *
  49. * @property {String} img - 图片
  50. * @property {String} title - 标题
  51. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx
  52. * @property {String} skuText - 规格
  53. * @property {String | Number} price - 价格
  54. * @property {String} priceColor - 价格颜色
  55. * @property {Number | String} num - 数量
  56. *
  57. */
  58. const props = defineProps({
  59. img: {
  60. type: String,
  61. default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
  62. },
  63. title: {
  64. type: String,
  65. default: '',
  66. },
  67. titleWidth: {
  68. type: Number,
  69. default: 0,
  70. },
  71. skuText: {
  72. type: [String, Array],
  73. default: '',
  74. },
  75. price: {
  76. type: [String, Number],
  77. default: '',
  78. },
  79. priceColor: {
  80. type: [String],
  81. default: '',
  82. },
  83. num: {
  84. type: [String, Number],
  85. default: 0,
  86. },
  87. point: {
  88. type: [String, Number],
  89. default: '',
  90. },
  91. radius: {
  92. type: [String],
  93. default: '',
  94. },
  95. marginBottom: {
  96. type: [String],
  97. default: '',
  98. },
  99. });
  100. const skuString = computed(() => {
  101. if (!props.skuText) {
  102. return '';
  103. }
  104. if (typeof props.skuText === 'object') {
  105. return props.skuText.join(',');
  106. }
  107. return props.skuText;
  108. });
  109. </script>
  110. <style lang="scss" scoped>
  111. .point-img {
  112. width: 36rpx;
  113. height: 36rpx;
  114. margin: 0 4rpx;
  115. }
  116. .ss-order-card-warp {
  117. padding: 20rpx;
  118. .img-box {
  119. width: 164rpx;
  120. height: 164rpx;
  121. border-radius: 10rpx;
  122. overflow: hidden;
  123. .order-img {
  124. width: 164rpx;
  125. height: 164rpx;
  126. }
  127. }
  128. .box-right {
  129. flex: 1;
  130. // width: 500rpx;
  131. // height: 164rpx;
  132. position: relative;
  133. .tool-box {
  134. position: absolute;
  135. right: 0rpx;
  136. bottom: -10rpx;
  137. }
  138. }
  139. .title-text {
  140. font-size: 28rpx;
  141. font-weight: 500;
  142. line-height: 40rpx;
  143. }
  144. .spec-text {
  145. font-size: 24rpx;
  146. font-weight: 400;
  147. color: $dark-9;
  148. min-width: 0;
  149. overflow: hidden;
  150. text-overflow: ellipsis;
  151. display: -webkit-box;
  152. -webkit-line-clamp: 1;
  153. -webkit-box-orient: vertical;
  154. }
  155. .price-text {
  156. font-size: 24rpx;
  157. font-weight: 500;
  158. font-family: OPPOSANS;
  159. }
  160. .total-text {
  161. font-size: 24rpx;
  162. font-weight: 400;
  163. line-height: 24rpx;
  164. color: $dark-9;
  165. margin-left: 8rpx;
  166. }
  167. }
  168. </style>