index.vue 2.6 KB

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