index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div>
  3. <!-- HERO -->
  4. <hero
  5. :title="courseHero.title"
  6. :subtitle="courseHero.subtitle"
  7. :image="courseHero.image"
  8. :promoLink="courseHero.product && courseHero.product.productLink"
  9. />
  10. <!-- HERO -->
  11. <section class="section">
  12. <div class="container">
  13. <h1 class="title">Featured Courses</h1>
  14. <div class="columns is-multiline">
  15. <div
  16. v-for="course in courses"
  17. :key="course._id"
  18. class="column is-one-quarter">
  19. <!-- CARD-ITEM -->
  20. <CourseCard :course="course"/>
  21. <!-- CARD-ITEM-END -->
  22. </div>
  23. </div>
  24. </div>
  25. </section>
  26. <section class="section">
  27. <div class="container">
  28. <h1 class="title">Featured Articles</h1>
  29. <div class="columns is-multiline">
  30. <div v-for="blog in featuredBlogs" :key="blog._id" class="column is-one-quarter">
  31. <blog-card
  32. :key="blog._id"
  33. :blog="blog"
  34. />
  35. <!-- CARD-ITEM-END -->
  36. </div>
  37. </div>
  38. </div>
  39. </section>
  40. </div>
  41. </template>
  42. <script>
  43. import Hero from "~/components/shared/Hero";
  44. import CourseCard from "~/components/CourseCard";
  45. import BlogCard from "~/components/BlogCard";
  46. import {mapState} from "vuex"
  47. export default {
  48. components: {
  49. Hero, CourseCard, BlogCard
  50. },
  51. computed : {
  52. ...mapState({
  53. // courses: state => {
  54. // console.log('index.vue mapState')
  55. // return state.course.items
  56. // }
  57. courses : state => state.course.items,
  58. featuredBlogs: state => state.blog.items.featured,
  59. courseHero: state => state.hero.item
  60. })
  61. },
  62. async fetch({store}) {
  63. const result = await store.dispatch('course/fetchCourses')
  64. console.log('index.vue fetch')
  65. await store.dispatch('blog/fetchFeaturedBlogs', {'filter[featured]': true})
  66. }
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. // card item
  71. .card-image:hover {
  72. cursor: pointer;
  73. opacity: 0.9;
  74. }
  75. .price-box {
  76. text-align: right;
  77. .price {
  78. color: gray;
  79. font-size: 16px;
  80. text-decoration: line-through;
  81. }
  82. .disc-price {
  83. font-size: 21px;
  84. font-weight: bold;
  85. }
  86. }
  87. // card item end
  88. // hero
  89. .hero-body {
  90. position: relative;
  91. }
  92. .hero-img {
  93. opacity: 0.8;
  94. position: absolute;
  95. height: 100%;
  96. width: 100%;
  97. top: 0;
  98. left: 0;
  99. -webkit-background-size: cover;
  100. -moz-background-size: cover;
  101. -o-background-size: cover;
  102. background-size: cover;
  103. }
  104. .user-avatar {
  105. display: inline-block;
  106. }
  107. .is-black {
  108. background-color: black;
  109. }
  110. .title {
  111. font-weight: bold;
  112. font-size: 45px;
  113. }
  114. .subtitle {
  115. /*font-weight: bold;*/
  116. font-size: 25px;
  117. }
  118. .author-name {
  119. font-size: 20px;
  120. font-weight: bold;
  121. }
  122. // hero
  123. // Home page
  124. .links {
  125. padding-top: 15px;
  126. }
  127. </style>