courseView.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="open-class bgf" v-if="cardList&&cardList.length>0">
  3. <view class="title-box bgf">
  4. <text class="title">健康大讲堂</text>
  5. <view class="more" @click="goClassList()">
  6. <text>查看全部</text>
  7. <u-icon name="arrow-right" size='12'></u-icon>
  8. </view>
  9. </view>
  10. <swiper class="class-swiper" style="height: 250rpx;" :autoplay="true" circular interval="3000" duration="1000" display-multiple-items='2' next-margin="20px">
  11. <swiper-item class="class-swiper-item" v-for="(item, index) in cardList" :key="index" @click="goClass(item.courseId)">
  12. <view class="class-item">
  13. <view class="img-box">
  14. <image :src="item.imgUrl || 'https://cos.his.cdwjyyh.com/fs/20250807/1eebee6c3bff4fd68d1d3dde090bdf89.png'" mode="widthFix"></image>
  15. </view>
  16. <view class="one-t" style="max-width: 280rpx;display: block;">{{item.courseName}}</view>
  17. </view>
  18. </swiper-item>
  19. </swiper>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. getAppletCourse
  25. } from '@/api/course.js'
  26. export default {
  27. data() {
  28. return {
  29. cardList: [],
  30. }
  31. },
  32. mounted() {
  33. this.getCourseList()
  34. },
  35. methods: {
  36. goClassList() {
  37. uni.navigateTo({
  38. url: '/pages_course/teacherClassroom'
  39. })
  40. },
  41. goClass(courseId) {
  42. uni.navigateTo({
  43. url: '/pages_course/learn?courseId='+courseId
  44. })
  45. },
  46. getCourseList() {
  47. getAppletCourse().then(res => {
  48. if (res.code == 200) {
  49. this.cardList = res.data.splice(0, 6)
  50. } else {
  51. uni.hideLoading();
  52. uni.showToast({
  53. title: res.msg,
  54. icon: 'none'
  55. });
  56. }
  57. })
  58. },
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. .class-swiper {
  64. margin-top: 20rpx;
  65. }
  66. .class-swiper-item {
  67. width: 100%;
  68. height: 100%;
  69. overflow: hidden;
  70. }
  71. .open-class {
  72. .title-box {
  73. display: flex;
  74. justify-content: space-between;
  75. align-items: center;
  76. .title {
  77. font-size: 32rpx;
  78. font-weight: bold;
  79. }
  80. .more {
  81. font-size: 24rpx;
  82. padding-left: 30rpx;
  83. color: #999999;
  84. display: flex;
  85. align-items: center;
  86. image {
  87. width: 24rpx;
  88. height: 24rpx;
  89. }
  90. }
  91. }
  92. .class-item {
  93. display: inline-block;
  94. font-size: 24rpx;
  95. background-color: #fff;
  96. border-radius: 16rpx;
  97. padding: 16rpx;
  98. box-sizing: border-box;
  99. font-size: 26rpx;
  100. font-weight: 500;
  101. .img-box {
  102. border-radius: 16rpx;
  103. overflow: hidden;
  104. margin-bottom: 12rpx;
  105. width: 280rpx;
  106. height: 157.5rpx;
  107. image {
  108. width: 280rpx;
  109. height: 157.5rpx;
  110. }
  111. }
  112. &:last-child {
  113. margin-right: 0rpx;
  114. }
  115. }
  116. }
  117. </style>