week.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { PageSizeEnum } from '~/enums/sizeEnum'
  4. import {
  5. getGoodsHotSaleListApi,
  6. getGoodsListApi,
  7. getGoodsTrendingListApi,
  8. } from '~/api/model/goods'
  9. const goodsList = ref<any>([])
  10. const labelGroup = ref<any>([
  11. {
  12. label: 'New Arrivals',
  13. value: 'arrivals',
  14. },
  15. {
  16. label: 'Bestsellers',
  17. value: 'hotSale',
  18. },
  19. {
  20. label: 'Trending',
  21. value: 'trends',
  22. },
  23. ])
  24. const active = ref<string>('arrivals')
  25. async function getGoodsList(params?: any, pageNo = PageSizeEnum.PAGE, pageSize = 8) {
  26. const fetchTask: any
  27. = active.value === 'arrivals'
  28. ? getGoodsListApi
  29. : active.value === 'trends'
  30. ? getGoodsTrendingListApi
  31. : getGoodsHotSaleListApi
  32. const data = await fetchTask({
  33. ...params,
  34. pageNo,
  35. pageSize,
  36. })
  37. goodsList.value = data.records
  38. }
  39. function selectLabel(val: string) {
  40. active.value = val
  41. getGoodsList()
  42. }
  43. getGoodsList()
  44. </script>
  45. <template>
  46. <div class="pt-120px text-center">
  47. <h2 class="fw-600 text-40px text-#363C40 custom-title-font">
  48. Products of The Week
  49. </h2>
  50. <div class="mt-20px w-500px mx-auto text-#999 text-16px lh-24px">
  51. Navigate through our diverse range of categories to find the products that fit your retail needs.
  52. </div>
  53. <div class="mt-40px mb-60px">
  54. <div class="flex mb-40px gap-85px justify-center">
  55. <div
  56. v-for="item in labelGroup"
  57. :key="item.value"
  58. class="cursor-pointer hover:text-#C58C64 pos-relative after:content-empty after:left-30% after:right-30% after:bottom--10px after:h-2px after:bg-#C58C64"
  59. :class="active === item.value && 'text-#C58C64 after:pos-absolute'"
  60. @click="selectLabel(item.value)"
  61. >
  62. <h3>
  63. {{ item.label }}
  64. </h3>
  65. </div>
  66. </div>
  67. <div class="grid grid-gap-66px grid-cols-4">
  68. <div v-for="item in goodsList" :key="item.id">
  69. <common-goods-item :item @update:login="getGoodsList" />
  70. </div>
  71. </div>
  72. <!-- <div class="flex justify-center items-center cursor-pointer">
  73. <div class="underline fw-500 text-32px hover:text-#CC9879">
  74. View All
  75. </div>
  76. <svgo-arrow class="!w-12px !h-12px ml-14px" />
  77. </div> -->
  78. </div>
  79. </div>
  80. </template>