CourseList.vue 3.8 KB

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