s-goods-item.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. ¥{{ fen2yuan(price) }}
  30. </view>
  31. <view v-if="point && Number(price) > 0">+</view>
  32. <view class="price-text ss-flex ss-col-center" v-if="point">
  33. <image
  34. :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
  35. class="point-img"
  36. ></image>
  37. <view>{{ point }}</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. import { fen2yuan } from '@/sheep/hooks/useGoods';
  57. /**
  58. * 订单卡片
  59. *
  60. * @property {String} img - 图片
  61. * @property {String} title - 标题
  62. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx
  63. * @property {String} skuText - 规格
  64. * @property {String | Number} price - 价格
  65. * @property {String} priceColor - 价格颜色
  66. * @property {Number | String} num - 数量
  67. *
  68. */
  69. const props = defineProps({
  70. img: {
  71. type: String,
  72. default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
  73. },
  74. title: {
  75. type: String,
  76. default: '',
  77. },
  78. titleWidth: {
  79. type: Number,
  80. default: 0,
  81. },
  82. skuText: {
  83. type: [String, Array],
  84. default: '',
  85. },
  86. price: {
  87. type: [String, Number],
  88. default: '',
  89. },
  90. priceColor: {
  91. type: [String],
  92. default: '',
  93. },
  94. num: {
  95. type: [String, Number],
  96. default: 0,
  97. },
  98. point: {
  99. type: [String, Number],
  100. default: '',
  101. },
  102. radius: {
  103. type: [String],
  104. default: '',
  105. },
  106. marginBottom: {
  107. type: [String],
  108. default: '',
  109. },
  110. });
  111. const skuString = computed(() => {
  112. if (!props.skuText) {
  113. return '';
  114. }
  115. if (typeof props.skuText === 'object') {
  116. return props.skuText.join(',');
  117. }
  118. return props.skuText;
  119. });
  120. </script>
  121. <style lang="scss" scoped>
  122. .point-img {
  123. width: 36rpx;
  124. height: 36rpx;
  125. margin: 0 4rpx;
  126. }
  127. .ss-order-card-warp {
  128. padding: 20rpx;
  129. .img-box {
  130. width: 164rpx;
  131. height: 164rpx;
  132. border-radius: 10rpx;
  133. overflow: hidden;
  134. .order-img {
  135. width: 164rpx;
  136. height: 164rpx;
  137. }
  138. }
  139. .box-right {
  140. flex: 1;
  141. // width: 500rpx;
  142. // height: 164rpx;
  143. position: relative;
  144. .tool-box {
  145. position: absolute;
  146. right: 0rpx;
  147. bottom: -10rpx;
  148. }
  149. }
  150. .title-text {
  151. font-size: 28rpx;
  152. font-weight: 500;
  153. line-height: 40rpx;
  154. }
  155. .spec-text {
  156. font-size: 24rpx;
  157. font-weight: 400;
  158. color: $dark-9;
  159. min-width: 0;
  160. overflow: hidden;
  161. text-overflow: ellipsis;
  162. display: -webkit-box;
  163. -webkit-line-clamp: 1;
  164. -webkit-box-orient: vertical;
  165. }
  166. .price-text {
  167. font-size: 24rpx;
  168. font-weight: 500;
  169. font-family: OPPOSANS;
  170. }
  171. .total-text {
  172. font-size: 24rpx;
  173. font-weight: 400;
  174. line-height: 24rpx;
  175. color: $dark-9;
  176. margin-left: 8rpx;
  177. }
  178. }
  179. </style>