index.vue 2.4 KB

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