index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <script lang='ts' setup>
  2. import { submitSubscribeApi } from '~/api/model/common'
  3. import { PageSizeEnum } from '~/enums/sizeEnum'
  4. import {
  5. getBlogsListApi,
  6. } from '~/api/model/blogs'
  7. const list = ref<any>([])
  8. const currentPage = ref(PageSizeEnum.PAGE)
  9. const total = ref()
  10. const page_size = ref(9)
  11. const categories = ref(
  12. [
  13. {
  14. key: '',
  15. title: 'All',
  16. slug: 'all',
  17. },
  18. {
  19. key: 'instructions',
  20. title: 'Security settings instructions',
  21. slug: 'instructions',
  22. },
  23. {
  24. key: 'settings',
  25. title: 'Multiple account settings',
  26. slug: 'settings',
  27. },
  28. ],
  29. )
  30. const category = ref('')
  31. const form = ref<any>({
  32. mail: '',
  33. })
  34. async function getVideoOrBlogsList(pageNo = currentPage.value, pageSize = page_size.value) {
  35. const params = {
  36. pageNo,
  37. pageSize,
  38. categoryId: category.value,
  39. orderBy: 'createTime',
  40. orderType: 'desc',
  41. }
  42. const res: any = await getBlogsListApi(params)
  43. total.value = res.total
  44. currentPage.value = res.current
  45. list.value = res.records
  46. }
  47. getVideoOrBlogsList()
  48. async function submitSubscribe() {
  49. try {
  50. await submitSubscribeApi(form.value)
  51. ElMessage.success(`You've subscribed successfully.`)
  52. form.value.mail = ''
  53. }
  54. catch (error) {
  55. console.log(error)
  56. }
  57. }
  58. function onSelectCategory(item: any) {
  59. category.value = item.key
  60. currentPage.value = PageSizeEnum.PAGE
  61. getVideoOrBlogsList(currentPage.value, page_size.value)
  62. }
  63. function changePage(current: number, size: number) {
  64. getVideoOrBlogsList(current, size)
  65. }
  66. const validateEmail = computed(() => {
  67. const emailReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/
  68. if (!form.value.mail)
  69. return true
  70. return emailReg.test(form.value.mail)
  71. })
  72. </script>
  73. <template>
  74. <div>
  75. <div class="pt-184px pb-50px bg-#F3F4FB text-center">
  76. <h2 class="text-60px fw-800 ls-2 text-#333 inline-block pos-relative custom-title-font">
  77. EJET Spark <span class="custom-title-bg03">Blog</span>
  78. <img src="@/assets/images/blog_icon05.png" class="w-90px h-90px pos-absolute top--10px left--120px" alt="" srcset="">
  79. <img src="@/assets/images/blog_icon06.png" class="w-70px h-70px pos-absolute top--20px right--100px" alt="" srcset="">
  80. </h2>
  81. <div class="pos-relative w-500px mx-auto mb-60px mt-40px">
  82. <el-input v-model.trim="form.mail" class="custom-input h-46px !b-rd-200px overflow-hidden" placeholder="Please enter your email address" />
  83. <el-button :disabled="!validateEmail || !form.mail" type="primary" class="!bg-#9B6CFF text-#fff pos-absolute !b-0px top-50% transform-translate-y--50% right-10px w-120px !text-16px !b-rd-150px" @click="submitSubscribe">
  84. Subscribe
  85. </el-button>
  86. </div>
  87. <div class="flex gap-30px justify-center">
  88. <div
  89. v-for="(item, index) in categories"
  90. :key="index"
  91. class="h-60px lh-60px px-30px b-rd-200px text-16px cursor-pointer hover:bg-#EAE5FA hover:text-#9B6CFF transition-all duration-300"
  92. :class="
  93. category === item.key
  94. ? '!bg-#EAE5FA !text-#9B6CFF'
  95. : 'bg-#fff text-#333'
  96. "
  97. @click="onSelectCategory(item)"
  98. >
  99. {{ item.title }}
  100. </div>
  101. </div>
  102. </div>
  103. <div class="pt-120px w-1200-auto">
  104. <div class="grid grid-cols-3 gap-col-40px gap-row-60px ">
  105. <div v-for="item, index in list" :key="index">
  106. <common-blog-item :item="item" />
  107. </div>
  108. </div>
  109. <div class="mt-60px flex justify-center">
  110. <el-pagination
  111. v-model:current-page="currentPage" :page-size="page_size" :pager-count="10"
  112. layout="prev, pager, next" :total="total" @change="changePage"
  113. />
  114. </div>
  115. </div>
  116. <AppFooter />
  117. </div>
  118. </template>
  119. <style lang='less' scoped>
  120. ::v-deep(.custom-input){
  121. .el-input__wrapper{
  122. border-radius:4px!important;
  123. padding: 7px 10px!important;
  124. color: #999;
  125. font-size: 16px;
  126. box-shadow: unset!important;
  127. }
  128. }
  129. </style>