s-goods-item.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 class="price-text ss-flex ss-col-center" :style="[{ color: priceColor }]" v-if="price && Number(price) > 0">¥{{ fen2yuan(price) }}</view>
  25. <view v-if="point && Number(price) > 0">+</view>
  26. <view class="price-text ss-flex ss-col-center" v-if="point">
  27. <image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="point-img"></image>
  28. <view>{{ point }}</view>
  29. </view>
  30. <view v-if="num" class="total-text ss-flex ss-col-center">x {{ num }}</view>
  31. <slot name="priceSuffix"></slot>
  32. </view>
  33. </view>
  34. <view v-if="lottery && lottery?.length" @tap.stop="handleToMyPrize">
  35. <span style="color: #2aae67; text-decoration: underline;">奖品:{{ lottery.map(e => e.prize.name).join('、') }}</span>
  36. <span style="color: #999;">(10天内未领取的,则视为主动放弃当前奖品)</span>
  37. </view>
  38. <view class="tool-box">
  39. <slot name="tool"></slot>
  40. </view>
  41. <view>
  42. <slot name="rightBottom"></slot>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script setup>
  49. import sheep from '@/sheep';
  50. import { computed } from 'vue';
  51. import { fen2yuan } from '@/sheep/hooks/useGoods';
  52. /**
  53. * 订单卡片
  54. *
  55. * @property {String} img - 图片
  56. * @property {String} title - 标题
  57. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx
  58. * @property {String} skuText - 规格
  59. * @property {String | Number} price - 价格
  60. * @property {String} priceColor - 价格颜色
  61. * @property {Number | String} num - 数量
  62. *
  63. */
  64. const props = defineProps({
  65. img: {
  66. type: String,
  67. default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
  68. },
  69. title: {
  70. type: String,
  71. default: '',
  72. },
  73. titleWidth: {
  74. type: Number,
  75. default: 0,
  76. },
  77. skuText: {
  78. type: [String, Array],
  79. default: '',
  80. },
  81. price: {
  82. type: [String, Number],
  83. default: '',
  84. },
  85. priceColor: {
  86. type: [String],
  87. default: '',
  88. },
  89. num: {
  90. type: [String, Number],
  91. default: 0,
  92. },
  93. point: {
  94. type: [String, Number],
  95. default: '',
  96. },
  97. radius: {
  98. type: [String],
  99. default: '',
  100. },
  101. marginBottom: {
  102. type: [String],
  103. default: '',
  104. },
  105. lottery: {
  106. type: Array,
  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. // 我的奖品
  120. const handleToMyPrize = () =>{
  121. sheep.$router.go('/pages/user/prize/index');
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .point-img {
  126. width: 36rpx;
  127. height: 36rpx;
  128. margin: 0 4rpx;
  129. }
  130. .ss-order-card-warp {
  131. padding: 20rpx;
  132. .img-box {
  133. width: 164rpx;
  134. height: 164rpx;
  135. border-radius: 10rpx;
  136. overflow: hidden;
  137. .order-img {
  138. width: 164rpx;
  139. height: 164rpx;
  140. }
  141. }
  142. .box-right {
  143. flex: 1;
  144. // width: 500rpx;
  145. // height: 164rpx;
  146. position: relative;
  147. .tool-box {
  148. // position: absolute;
  149. // right: 0rpx;
  150. // bottom: -10rpx;
  151. display: flex;
  152. justify-content: flex-end;
  153. margin-top: 10px;
  154. }
  155. }
  156. .title-text {
  157. font-size: 28rpx;
  158. font-weight: 500;
  159. line-height: 40rpx;
  160. }
  161. .spec-text {
  162. font-size: 24rpx;
  163. font-weight: 400;
  164. color: $dark-9;
  165. min-width: 0;
  166. overflow: hidden;
  167. text-overflow: ellipsis;
  168. display: -webkit-box;
  169. -webkit-line-clamp: 1;
  170. -webkit-box-orient: vertical;
  171. }
  172. .price-text {
  173. font-size: 24rpx;
  174. font-weight: 500;
  175. font-family: OPPOSANS;
  176. }
  177. .total-text {
  178. font-size: 24rpx;
  179. font-weight: 400;
  180. line-height: 24rpx;
  181. color: $dark-9;
  182. margin-left: 8rpx;
  183. }
  184. }
  185. </style>