CourseList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <ul class="courseList">
  3. <li v-for="(item,index) in data" :key="index" :class="[index===data.length-1?'noborder':'',isBuy||index<1?'buy':'']" @click="handleLink(item,isBuy||index<1,index)">
  4. <span class="number">{{index+1 + '.'}}</span>
  5. <b class="title">{{item.name}}</b>
  6. <span class="teacher">{{item.teacher_name?'主讲教师 '+item.teacher_name:''}}</span>
  7. <span class="time-length">{{item.timeCn}}</span>
  8. <i class="el-icon-lock" v-if="!(isBuy||index<1)"></i>
  9. <i class="el-icon-arrow-right" v-else></i>
  10. </li>
  11. </ul>
  12. </template>
  13. <script>
  14. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  15. //例如:import 《组件名称》from ‘《组件路径》';
  16. export default {
  17. //import引入的组件需要注入到对象中才能使用
  18. components: { },
  19. props: ["data", "isBuy","LoginNavIndex","userBg","headerBorder","headerBg","cardType"],
  20. data() {
  21. //这里存放数据
  22. return {
  23. }
  24. },
  25. //计算属性 类似于data概念
  26. computed: {},
  27. //监控data中数据变化
  28. watch: {
  29. },
  30. //方法集合
  31. methods: {
  32. // 跳转
  33. handleLink(item,flag,index){
  34. if(flag){
  35. let url = this.LoginNavIndex +'&&&'+ this.userBg +'&&&'+ this.headerBorder +'&&&'+ this.headerBg
  36. this.$router.push({
  37. path: this.cardType===1?"/courseDetail":"/videoDetail",
  38. query: {
  39. headerConfig: encodeURIComponent(url),
  40. index: index,
  41. id: this.$route.query.id?this.$route.query.id:''
  42. },
  43. });
  44. }
  45. }
  46. },
  47. //生命周期 - 创建完成(可以访问当前this实例)
  48. created() {
  49. },
  50. //生命周期 - 挂载完成(可以访问DOM元素)
  51. mounted() {
  52. },
  53. //生命周期-创建之前
  54. beforeCreated() { },
  55. //生命周期-挂载之前
  56. beforeMount() { },
  57. //生命周期-更新之前
  58. beforUpdate() { },
  59. //生命周期-更新之后
  60. updated() { },
  61. //生命周期-销毁之前
  62. beforeDestory() { },
  63. //生命周期-销毁完成
  64. destoryed() { },
  65. //如果页面有keep-alive缓存功能,这个函数会触发
  66. activated() { }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. /* @import url(); 引入css类 */
  71. ul{
  72. list-style: none;
  73. padding: 0;
  74. margin: 0;
  75. }
  76. .courseList{
  77. li{
  78. padding: 16px;
  79. border-bottom: 1px solid #E5E6EB;
  80. font-size: 16px;
  81. line-height: 24px;
  82. color: #2F3742;
  83. display: flex;
  84. align-items: center;
  85. &.noborder{
  86. border: none;
  87. }
  88. &.buy{
  89. cursor: pointer;
  90. }
  91. .number{
  92. width: 27px;
  93. }
  94. .title{
  95. font-weight: 400;
  96. margin-right: 16px;
  97. }
  98. .teacher,.time-length{
  99. flex: 1;
  100. color: #929CA8;
  101. margin-right: 16px;
  102. }
  103. .time-length{
  104. flex: initial;
  105. }
  106. }
  107. }
  108. </style>