index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="box">
  3. <div class="d-flex">
  4. <div style="width: 80px; height: 80px;" class="mr-3">
  5. <v-img :src="img" :aspect-ratio="1" style="border-radius: 8px;"></v-img>
  6. </div>
  7. <div
  8. class="d-flex justify-space-between align-center"
  9. style="flex: 1; font-size: 16px;"
  10. >
  11. <div v-if="title" class="title">{{ title }}</div>
  12. <div v-if="skuString" class="skuString" style="color: var(--v-primary-base);">{{ skuString }}</div>
  13. <div v-if="price && Number(price) > 0" class="price" :style="[{ color: priceColor }]"> ¥{{ fen2yuan(price) }} </div>
  14. <div v-if="num" class="buyNum ml-2"> x {{ num }}</div>
  15. <div v-if="price && Number(price) > 0" class="subtotal">¥{{ fen2yuan(num*price) }}</div>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup>
  21. import { computed } from 'vue';
  22. import { fen2yuan } from '@/hooks/web/useGoods'
  23. /**
  24. * 订单卡片
  25. *
  26. * @property {String} img - 图片
  27. * @property {String} title - 标题
  28. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位
  29. * @property {String} skuText - 规格
  30. * @property {String | Number} price - 价格
  31. * @property {String} priceColor - 价格颜色
  32. * @property {Number | String} num - 数量
  33. *
  34. */
  35. const props = defineProps({
  36. img: {
  37. type: String,
  38. default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
  39. },
  40. title: {
  41. type: String,
  42. default: '',
  43. },
  44. titleWidth: {
  45. type: Number,
  46. default: 0,
  47. },
  48. skuText: {
  49. type: [String, Array],
  50. default: '',
  51. },
  52. price: {
  53. type: [String, Number],
  54. default: '',
  55. },
  56. priceColor: {
  57. type: [String],
  58. default: '',
  59. },
  60. num: {
  61. type: [String, Number],
  62. default: 0,
  63. },
  64. point: {
  65. type: [String, Number],
  66. default: '',
  67. },
  68. radius: {
  69. type: [String],
  70. default: '',
  71. },
  72. marginTop: {
  73. type: [String],
  74. default: '',
  75. },
  76. });
  77. const skuString = computed(() => {
  78. if (!props.skuText) {
  79. return '';
  80. }
  81. if (typeof props.skuText === 'object') {
  82. return props.skuText.join(',');
  83. }
  84. return props.skuText;
  85. });
  86. </script>
  87. <style lang="scss" scoped>
  88. .box {
  89. // background-color: var(--default-bgc);
  90. background-color: #e9e9e9;
  91. border-radius: 8px;
  92. padding: 12px;
  93. // border: 1px dashed #000000;
  94. }
  95. .title {
  96. font-size: 17px;
  97. font-family: 'MiSans-Bold';
  98. width: 30%;
  99. }
  100. .skuString {
  101. width: 25%;
  102. }
  103. .price {
  104. width: 15%;
  105. }
  106. .buyNum {
  107. width: 10%;
  108. color: #777;
  109. }
  110. .subtotal {
  111. width: 15%;
  112. }
  113. </style>