s-goods-item.vue 4.5 KB

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