s-goods-item.vue 4.2 KB

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