index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="support-wrap">
  3. <div class="list">
  4. <div
  5. v-for="(item, index) in list"
  6. :key="index"
  7. class="item"
  8. @click="handleClick"
  9. >
  10. <div
  11. class="left"
  12. :style="{ backgroundImage: `url(${item.cover})` }"
  13. >
  14. <div
  15. v-if="item.badge"
  16. class="badge"
  17. :style="{ backgroundColor: item.badge_bg }"
  18. >
  19. <div class="txt">{{ item.badge }}</div>
  20. </div>
  21. </div>
  22. <div class="right">
  23. <div class="title">{{ item.name }}</div>
  24. <div class="info">100%好评</div>
  25. <div class="desc">{{ item.desc }}</div>
  26. <div class="price-wrap">
  27. <span class="price">¥{{ item.price }}</span>
  28. <del
  29. v-if="item.price !== item.original_price"
  30. class="original-price"
  31. >
  32. {{ item.original_price }}
  33. </del>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import { onMounted, ref } from 'vue';
  42. import { fetchGoodsList } from '@/api/goods';
  43. import { GoodsTypeEnum, IGoods } from '@/interface';
  44. const list = ref<IGoods[]>([]);
  45. async function getGoodsList() {
  46. const res = await fetchGoodsList({
  47. type: GoodsTypeEnum.support,
  48. orderName: 'created_at',
  49. orderBy: 'desc',
  50. });
  51. if (res.code === 200) {
  52. console.log(res.data);
  53. list.value = res.data.rows;
  54. }
  55. }
  56. onMounted(() => {
  57. getGoodsList();
  58. });
  59. function handleClick() {
  60. window.$message.info('即将推出,敬请期待~');
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .support-wrap {
  65. margin-top: 30px;
  66. padding: 0 20px;
  67. .list {
  68. display: flex;
  69. .item {
  70. display: flex;
  71. margin-right: 20px;
  72. padding: 10px;
  73. border-radius: 10px;
  74. box-shadow: 0 4px 30px 0 rgba(238, 242, 245, 0.8);
  75. cursor: pointer;
  76. transition: box-shadow 0.2s linear;
  77. &:hover {
  78. box-shadow: 4px 4px 20px 0 rgba(205, 216, 228, 0.6);
  79. }
  80. .left {
  81. position: relative;
  82. margin-right: 10px;
  83. width: 100px;
  84. height: 100px;
  85. background-position: center center;
  86. background-size: cover;
  87. background-repeat: no-repeat;
  88. .badge {
  89. position: absolute;
  90. top: -10px;
  91. right: -10px;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. border-radius: 2px;
  96. padding: 2px;
  97. color: white;
  98. .txt {
  99. display: inline-block;
  100. transform-origin: center !important;
  101. line-height: 1;
  102. @include minFont(10);
  103. }
  104. }
  105. }
  106. .right {
  107. .title {
  108. font-size: 22px;
  109. }
  110. .info {
  111. }
  112. .price-wrap {
  113. display: flex;
  114. align-items: center;
  115. .price {
  116. color: gold;
  117. font-size: 22px;
  118. }
  119. .original-price {
  120. margin-left: 5px;
  121. color: #666;
  122. font-size: 14px;
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. </style>