s-goods-item.vue 4.4 KB

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