s-goods-item.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. <!-- v-if="price && Number(price) > 0" -->
  25. <view
  26. class="price-text ss-flex ss-col-center"
  27. :style="[{ color: priceColor }]"
  28. >
  29. <template v-if="virtualPirce"><image src="@/static/icon/points.png" style="width:30rpx;height:30rpx"></image> {{fen2yuan6(price)}}</template>
  30. <template v-else>¥{{ fen2yuan(price) }}</template>
  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>
  40. <slot name="rightBottom"></slot>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup>
  47. import sheep from '@/sheep';
  48. import { computed } from 'vue';
  49. import { fen2yuan,fen2yuan6 } from '@/sheep/hooks/useGoods';
  50. /**
  51. * 订单卡片
  52. *
  53. * @property {String} img - 图片
  54. * @property {String} title - 标题
  55. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx
  56. * @property {String} skuText - 规格
  57. * @property {String | Number} price - 价格
  58. * @property {String} priceColor - 价格颜色
  59. * @property {Number | String} num - 数量
  60. *
  61. */
  62. const props = defineProps({
  63. img: {
  64. type: String,
  65. default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
  66. },
  67. title: {
  68. type: String,
  69. default: '',
  70. },
  71. titleWidth: {
  72. type: Number,
  73. default: 0,
  74. },
  75. skuText: {
  76. type: [String, Array],
  77. default: '',
  78. },
  79. price: {
  80. type: [String, Number],
  81. default: '',
  82. },
  83. priceColor: {
  84. type: [String],
  85. default: '',
  86. },
  87. num: {
  88. type: [String, Number],
  89. default: 0,
  90. },
  91. score: {
  92. type: [String, Number],
  93. default: '',
  94. },
  95. radius: {
  96. type: [String],
  97. default: '',
  98. },
  99. marginBottom: {
  100. type: [String],
  101. default: '',
  102. },
  103. virtualPirce:{
  104. type:[Boolean],
  105. default:false
  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: 500;
  171. line-height: 24rpx;
  172. color: #ff3000;
  173. margin-left: 8rpx;
  174. font-family: OPPOSANS;
  175. }
  176. }
  177. </style>