s-goods-item.vue 4.1 KB

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