index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <script lang='ts' setup>
  2. import { getBlogCategoryListApi, getBlogsListApi } from '~/api/model/blogs'
  3. import { PageSizeEnum } from '~/enums/sizeEnum'
  4. import { ConstKeys } from '~/enums/const-enums'
  5. useHead({
  6. title: 'Insights, Trends, and Tips for Retail Success| EJET Selection Blog',
  7. meta: [
  8. {
  9. name: 'description',
  10. content:
  11. `Stay updated with EJET Selection's blog! Explore industry insights, product trends, and expert tips to grow your retail business and stay ahead in the market.`,
  12. },
  13. {
  14. property: 'og:title',
  15. content: 'Insights, Trends, and Tips for Retail Success| EJET Selection Blog',
  16. },
  17. {
  18. property: 'og:description',
  19. content:
  20. `Stay updated with EJET Selection's blog! Explore industry insights, product trends, and expert tips to grow your retail business and stay ahead in the market.`,
  21. },
  22. {
  23. property: 'og:type',
  24. content: 'website',
  25. },
  26. {
  27. property: 'twitter:title',
  28. content: 'Insights, Trends, and Tips for Retail Success| EJET Selection Blog',
  29. },
  30. {
  31. property: 'twitter:description',
  32. content:
  33. `Stay updated with EJET Selection's blog! Explore industry insights, product trends, and expert tips to grow your retail business and stay ahead in the market.`,
  34. },
  35. {
  36. property: 'twitter:card',
  37. content: 'summary_large_image',
  38. },
  39. ],
  40. link: [
  41. {
  42. rel: 'canonical',
  43. href: `${ConstKeys.DOMAINPRO}/blog`,
  44. },
  45. ],
  46. })
  47. const active = ref('all')
  48. const categoryList = ref([
  49. {
  50. title: 'All posts',
  51. key: 'all',
  52. },
  53. ])
  54. const list = ref<any>([])
  55. const page_size = ref(9)
  56. const total = ref()
  57. const currentPage = ref(PageSizeEnum.PAGE)
  58. async function getBlogCategoryList() {
  59. const res: any = await getBlogCategoryListApi()
  60. categoryList.value = categoryList.value.concat(res)
  61. }
  62. async function getBlogsList(params?: any, pageNo = PageSizeEnum.PAGE, pageSize = page_size.value) {
  63. const res: any = await getBlogsListApi({
  64. ...params,
  65. pageNo,
  66. pageSize,
  67. orderBy: 'createTime',
  68. orderType: 'desc',
  69. })
  70. list.value = res.records
  71. total.value = res.total
  72. currentPage.value = res.current
  73. }
  74. function onSelectedCategory(item: any) {
  75. active.value = item.key
  76. getBlogsList({
  77. categoryId: item.key === 'all' ? '' : item.key,
  78. }, PageSizeEnum.PAGE, page_size.value)
  79. }
  80. function changePage(current: number, size: number) {
  81. getBlogsList({ categoryId: active.value === 'all' ? '' : active.value }, current, size)
  82. }
  83. getBlogCategoryList()
  84. getBlogsList()
  85. </script>
  86. <template>
  87. <div class="">
  88. <div class="text-center py-80px">
  89. <h1 class="fw-700 text-40px !mb-20px text-#363C40 custom-title-font">
  90. Our Blog
  91. </h1>
  92. <div class="lh-24px text-16px w-500px mx-auto">
  93. Explore industry insights, product trends, and expert tips to grow your retail business and stay ahead in the market.
  94. </div>
  95. </div>
  96. <div class="w-1400px mx-auto mb-120px">
  97. <div class="flex gap-84px text-#999999 text-18px justify-center">
  98. <h2
  99. v-for="item, index in categoryList" :key="index" class="pb-10px cursor-pointer fw-500 pos-relative" :class="active === item.key && 'after:pos-absolute after:content-empty after:bottom-0 after:left-15% after:right-15% after:h-2px after:bg-#C58C64 text-#C58C64'"
  100. @click="onSelectedCategory(item)"
  101. >
  102. {{ item.title }}
  103. </h2>
  104. </div>
  105. <div class="mt-70px grid grid-cols-3 gap-x-106px gap-y-65px px-66px">
  106. <div v-for="item, index in list" :key="index">
  107. <common-blog-item :item="item" />
  108. </div>
  109. </div>
  110. <div class="mt-100px flex justify-center">
  111. <el-pagination
  112. v-model:current-page="currentPage"
  113. :page-size="page_size"
  114. :pager-count="10"
  115. layout="prev, pager, next" :total="total"
  116. @change="changePage"
  117. />
  118. </div>
  119. </div>
  120. <AppFooter />
  121. </div>
  122. </template>
  123. <style lang="less"></style>