headerBanner.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <script lang='ts' setup>
  2. import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
  3. import { useUserStore } from '@/stores/modules/user'
  4. import { getBannerDataApi } from '~/api/model/common'
  5. const props = defineProps({
  6. slug: {
  7. type: String,
  8. default: '',
  9. },
  10. })
  11. const userStore = useUserStore()
  12. const { isLogin } = storeToRefs(userStore)
  13. const dynamicImg = ref('')
  14. const bannerTitle = ref('')
  15. const subTitle = ref('')
  16. watch(() => props.slug, async (val: any) => {
  17. const data: any = await getBannerDataApi({ slug: val })
  18. dynamicImg.value = data.bannerImg
  19. bannerTitle.value = data.contentTitle
  20. subTitle.value = data.subhead
  21. }, {
  22. immediate: true,
  23. })
  24. </script>
  25. <template>
  26. <div class="">
  27. <el-skeleton :loading="!dynamicImg" class="w-full h-[400px]" animated>
  28. <template #template>
  29. <el-skeleton-item variant="h3" class="w-full !h-[400px]" />
  30. </template>
  31. <template #default>
  32. <img :src="dynamicImg" class="w-full h-[400px] object-cover" alt="" srcset="">
  33. </template>
  34. </el-skeleton>
  35. <div class="pos-absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] w-1400px mx-auto">
  36. <h1 class="!mb-20px text-#333333 text-40px fw-700 custom-title-font">
  37. {{ bannerTitle }}
  38. </h1>
  39. <div class="mb-20px text-#999999 w-800px">
  40. {{ subTitle }}
  41. </div>
  42. <el-button v-if="!isLogin" type="primary" plain class="w-160px !bg-#C58C64 !text-#fff !h-40px !text-16px !fw-500 !b-rd-150px">
  43. <nuxt-link to="/register">
  44. Shop on EJET
  45. </nuxt-link>
  46. </el-button>
  47. </div>
  48. </div>
  49. </template>
  50. <style lang='less' scoped>
  51. </style>