ProductItem.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div>
  3. <div>
  4. <slot name="top"></slot>
  5. </div>
  6. <div
  7. :style="[{ borderRadius: radius + 'px', marginBottom: marginBottom + 'px' }]"
  8. class="ss-order-card-warp flex items-stretch justify-between bg-white"
  9. >
  10. <div class="img-box mr-24px">
  11. <el-image
  12. :initial-index="0"
  13. :preview-src-list="[picUrl]"
  14. :src="picUrl"
  15. class="order-img"
  16. fit="contain"
  17. preview-teleported
  18. />
  19. </div>
  20. <div
  21. :style="[{ width: titleWidth ? titleWidth + 'px' : '' }]"
  22. class="box-right flex flex-col justify-between"
  23. >
  24. <div v-if="title" class="title-text ss-line-2">{{ title }}</div>
  25. <div v-if="skuString" class="spec-text mt-8px mb-12px">{{ skuString }}</div>
  26. <div class="groupon-box">
  27. <slot name="groupon"></slot>
  28. </div>
  29. <div class="flex">
  30. <div class="flex items-center">
  31. <div
  32. v-if="price && Number(price) > 0"
  33. :style="[{ color: priceColor }]"
  34. class="price-text flex items-center"
  35. >
  36. ¥{{ fenToYuan(price) }}
  37. </div>
  38. <div v-if="num" class="total-text flex items-center">x {{ num }}</div>
  39. <slot name="priceSuffix"></slot>
  40. </div>
  41. </div>
  42. <div class="tool-box">
  43. <slot name="tool"></slot>
  44. </div>
  45. <div>
  46. <slot name="rightBottom"></slot>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </template>
  52. <script lang="ts" setup>
  53. import { fenToYuan } from '@/utils'
  54. defineOptions({ name: 'ProductItem' })
  55. const props = defineProps({
  56. picUrl: {
  57. type: String,
  58. default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto'
  59. },
  60. title: {
  61. type: String,
  62. default: ''
  63. },
  64. titleWidth: {
  65. type: Number,
  66. default: 0
  67. },
  68. skuText: {
  69. type: [String, Array],
  70. default: ''
  71. },
  72. price: {
  73. type: [String, Number],
  74. default: ''
  75. },
  76. priceColor: {
  77. type: [String],
  78. default: ''
  79. },
  80. num: {
  81. type: [String, Number],
  82. default: 0
  83. },
  84. score: {
  85. type: [String, Number],
  86. default: ''
  87. },
  88. radius: {
  89. type: [String],
  90. default: ''
  91. },
  92. marginBottom: {
  93. type: [String],
  94. default: ''
  95. }
  96. })
  97. /** SKU 展示字符串 */
  98. const skuString = computed(() => {
  99. if (!props.skuText) {
  100. return ''
  101. }
  102. if (typeof props.skuText === 'object') {
  103. return props.skuText.join(',')
  104. }
  105. return props.skuText
  106. })
  107. </script>
  108. <style lang="scss" scoped>
  109. .ss-order-card-warp {
  110. padding: 20px;
  111. border-radius: 10px;
  112. border: 1px #6a6a6a solid;
  113. background-color: var(--app-content-bg-color);
  114. .img-box {
  115. width: 80px;
  116. height: 80px;
  117. border-radius: 10px;
  118. overflow: hidden;
  119. .order-img {
  120. width: 80px;
  121. height: 80px;
  122. }
  123. }
  124. .box-right {
  125. flex: 1;
  126. position: relative;
  127. .tool-box {
  128. position: absolute;
  129. right: 0px;
  130. bottom: -10px;
  131. }
  132. }
  133. .title-text {
  134. font-size: 13px;
  135. font-weight: 500;
  136. line-height: 20px;
  137. }
  138. .spec-text {
  139. font-size: 10px;
  140. font-weight: 400;
  141. color: #999999;
  142. min-width: 0;
  143. overflow: hidden;
  144. text-overflow: ellipsis;
  145. display: -webkit-box;
  146. -webkit-line-clamp: 1;
  147. -webkit-box-orient: vertical;
  148. }
  149. .price-text {
  150. font-size: 11px;
  151. font-weight: 500;
  152. font-family: OPPOSANS;
  153. }
  154. .total-text {
  155. font-size: 10px;
  156. font-weight: 400;
  157. line-height: 16px;
  158. color: #999999;
  159. margin-left: 8px;
  160. }
  161. }
  162. .ss-line {
  163. min-width: 0;
  164. overflow: hidden;
  165. text-overflow: ellipsis;
  166. display: -webkit-box;
  167. -webkit-box-orient: vertical;
  168. &-1 {
  169. -webkit-line-clamp: 1;
  170. }
  171. &-2 {
  172. -webkit-line-clamp: 2;
  173. }
  174. }
  175. </style>