CourseCard.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <el-card class="course-card" @click.native="checkCourseDetail" shadow="hover" :body-style="bodyStyle">
  3. <img :src="picture" class="course-card__picture"/>
  4. <div class="course-card__header">
  5. <div class="course-card__info">
  6. <div class="course-card__title">{{ title }}</div>
  7. </div>
  8. <p class="course-card__origin">{{ origin }}</p>
  9. </div>
  10. <div class="contentCenter">
  11. <div class="course-card__description">{{ description }}</div>
  12. </div>
  13. </el-card>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'CourseCard',
  18. props: {
  19. title: {
  20. type: String,
  21. require: true,
  22. default: '课程xxxxxxx'
  23. },
  24. origin: {
  25. type: String,
  26. require: true,
  27. default: '课程提供者xxx'
  28. },
  29. picture: {
  30. type: String,
  31. require: true,
  32. default: '/image/seec_logo.png'
  33. },
  34. url: {
  35. type: String,
  36. require: true,
  37. default: '/'
  38. },
  39. description: {
  40. type: String,
  41. default: ''
  42. }
  43. },
  44. data () {
  45. return {
  46. bodyStyle: {
  47. padding: '0',
  48. backgroundColor: '#F8F9FB'
  49. }
  50. }
  51. },
  52. methods: {
  53. checkCourseDetail () {
  54. const token = this.$store.state.token
  55. if (token === null) {
  56. this.$message({
  57. showClose: true,
  58. message: '请先登录',
  59. type: 'error'
  60. })
  61. } else {
  62. window.location.href = this.url
  63. }
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. @import '~/assets/css/course-card.scss';
  70. .contentCenter{
  71. display: flex;
  72. align-items: center;
  73. flex-direction: column;
  74. margin-top: 8px;
  75. }
  76. </style>