CourseCard.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="course-card" title="点击修改课程详情" @click="handleClick">
  3. <div class="course-card-title">
  4. <c-icon theme="orange" :left="-2" :right="6" :size="18">book</c-icon>
  5. {{course.name || '暂无课程名称'}}
  6. </div>
  7. <show-transition-small>
  8. <div v-if="!hideBio" class="course-card-bio">{{course.bio || '暂无课程简介'}}</div>
  9. </show-transition-small>
  10. <show-transition-small>
  11. <div v-if="!hideTeacher" class="course-card-teacher">教师:{{course.teacherName}}</div>
  12. </show-transition-small>
  13. <show-transition-small>
  14. <div v-if="!hideTime" class="course-card-time">创建时间:{{createAt}}</div>
  15. </show-transition-small>
  16. </div>
  17. </template>
  18. <script>
  19. import CIcon from '@/components/Basic/CIcon'
  20. import ShowTransitionSmall from '@/animations/ShowTransitionSmall'
  21. import momentFromNow from '@/utils/moment-from-now'
  22. export default {
  23. components: { CIcon, ShowTransitionSmall },
  24. props: {
  25. clickHandler: {
  26. type: Function,
  27. default: () => {}
  28. },
  29. course: {
  30. type: Object
  31. },
  32. hideTeacher: {
  33. type: Boolean,
  34. default: false
  35. },
  36. hideBio: {
  37. type: Boolean,
  38. default: false
  39. },
  40. hideTime: {
  41. type: Boolean,
  42. default: false
  43. }
  44. },
  45. methods: {
  46. handleClick () {
  47. this.clickHandler(this.course)
  48. }
  49. },
  50. computed: {
  51. createAt () {
  52. return momentFromNow(this.course.createAt)
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. @import '~@/style/theme.scss';
  59. .course-card {
  60. margin: 8px 0;
  61. padding: 8px 8px 8px 12px;
  62. // border-left: 4px solid $input-background-color;
  63. transition: .2s;
  64. cursor: pointer;
  65. border-radius: 12px;
  66. &:hover {
  67. background: $card-background;
  68. // border-left: 4px solid $theme-blue;
  69. }
  70. }
  71. .course-card-title {
  72. font-size: 16px;
  73. display: flex;
  74. align-items: center;
  75. position: relative;
  76. line-height: 1.8;
  77. }
  78. .course-card-bio {
  79. font-size: 14px;
  80. color: #6a7a8a;
  81. }
  82. .course-card-teacher {
  83. font-size: 14px;
  84. color: #8a9aaa;
  85. line-height: 1.8;
  86. }
  87. .course-card-time {
  88. font-size: 12px;
  89. color: #aabaca;
  90. line-height: 1.8;
  91. }
  92. .c-icon {
  93. transform: scale(1.3);
  94. }
  95. </style>