myCourses.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <u-navbar title="我的课程">
  4. </u-navbar>
  5. <view class="courses-box" v-for="(item,index) in courseList" :key="index">
  6. <!-- @click="gotoUrl('pages/youth/mine/classRecord?id='+item.buyId)"> -->
  7. <view class="photo" v-if="item.posterUrl != null">
  8. <img :src="item.posterUrl" alt="">
  9. </view>
  10. <view class="photo" v-else>
  11. <img src="../../../assets/img/classschedule.png" alt="">
  12. </view>
  13. <view class="infos">
  14. <view class="title">
  15. <view class="text">
  16. {{item.className}}
  17. </view>
  18. <view class="state" v-if="item.status=='1' || item.status=='5'">
  19. 进行中
  20. </view>
  21. <view class="stateClose" v-if="item.status=='2'">
  22. 已结课
  23. </view>
  24. </view>
  25. <view class="tags">
  26. <view class="item">
  27. {{item.classroomName}}
  28. </view>
  29. <view class="item" v-if="item.courseEnd != null">
  30. {{item.courseEnd.replaceAll('-','/')}}截止
  31. </view>
  32. </view>
  33. <view class="teacher">
  34. <view class="teacher-photo">
  35. <u-avatar class="avatar"
  36. :src="item.teacherPhoto != null ? item.teacherPhoto : '../../assets/img/head.png'" size="64">
  37. </u-avatar>
  38. </view>
  39. <view class="teacher-name">
  40. {{item.teacherName}}
  41. </view>
  42. <view class="progress">
  43. <!-- <u-line-progress :percent="item.rollcallCount/(item.courseAmount+item.freeAmount)*100" :show-percent="false" active-color="#43C9D3">
  44. </u-line-progress>
  45. <view class="percent">
  46. {{item.rollcallCount!= null ? item.rollcallCount : '0'}}/{{item.courseAmount+item.freeAmount}}
  47. </view> -->
  48. <view class="percent">
  49. 总课时:{{item.courseAmount+item.freeAmount}}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <u-divider v-if="courseList.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px">没有更多了</u-divider>
  56. </view>
  57. </template>
  58. <script>
  59. import * as mineApi from '@/apis/youth/mine.js'
  60. export default {
  61. data() {
  62. return {
  63. pageNum: 1,
  64. pageSize: 5,
  65. recordsTotal: 0,
  66. courseList: [],
  67. studentId: ''
  68. }
  69. },
  70. onReady() {
  71. if (this.carhelp.getNsStudentId()) {
  72. this.studentId = this.carhelp.getNsStudentId().studentId;
  73. this.getLoadMyCourses();
  74. }
  75. },
  76. onReachBottom() {
  77. if (this.courseList.length < this.recordsTotal) {
  78. this.myLoadmore();
  79. }
  80. },
  81. methods: {
  82. myLoadmore() {
  83. this.pageNum += 1;
  84. this.getLoadMyCourses();
  85. },
  86. getLoadMyCourses(bl) {
  87. uni.showLoading({
  88. title: "加载中",
  89. mask: true,
  90. })
  91. if (bl) {
  92. this.courseList = [];
  93. this.pageNum = 1;
  94. }
  95. mineApi.loadMyCourses({
  96. studentId: this.studentId,
  97. pageNum: this.pageNum,
  98. pageSize: this.pageSize
  99. }).then((res) => {
  100. uni.hideLoading();
  101. this.courseList = [
  102. ...this.courseList,
  103. ...res.data.data
  104. ];
  105. this.recordsTotal = res.data.recordsTotal;
  106. }).catch(error => {
  107. uni.showToast({
  108. title: error,
  109. icon: "none"
  110. })
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .courses-box {
  118. display: flex;
  119. padding: 24rpx;
  120. background-color: #fff;
  121. margin: 24rpx 32rpx 0 32rpx;
  122. border-radius: 24rpx;
  123. .photo {
  124. width: 100px;
  125. height: 100px;
  126. border-radius: 4px;
  127. overflow: hidden;
  128. img {
  129. width: 100%;
  130. height: 100%;
  131. }
  132. }
  133. .infos {
  134. margin-left: 24rpx;
  135. .title {
  136. display: flex;
  137. justify-content: space-between;
  138. .text {
  139. width: 70%;
  140. color: rgba(51, 51, 51, 1);
  141. font-size: 16px;
  142. font-weight: bold;
  143. text-overflow: ellipsis;
  144. white-space: nowrap;
  145. overflow: hidden;
  146. }
  147. .state {
  148. width: 96rpx;
  149. line-height: 40rpx;
  150. border-radius: 8rpx;
  151. background-color: rgba(13, 186, 199, 1);
  152. color: rgba(255, 255, 255, 1);
  153. font-size: 22rpx;
  154. text-align: center;
  155. margin-left: 24rpx;
  156. }
  157. .stateClose {
  158. width: 96rpx;
  159. line-height: 40rpx;
  160. border-radius: 8rpx;
  161. background-color: rgba(165, 168, 184, 1);
  162. color: rgba(255, 255, 255, 1);
  163. font-size: 22rpx;
  164. text-align: center;
  165. margin-left: 24rpx;
  166. }
  167. }
  168. .tags {
  169. display: flex;
  170. margin-top: 12rpx;
  171. .item {
  172. line-height: 40rpx;
  173. border-radius: 4px;
  174. background-color: rgba(241, 243, 244, 1);
  175. color: rgba(136, 133, 133, 1);
  176. font-size: 24rpx;
  177. text-align: center;
  178. padding: 0 8rpx;
  179. margin-right: 16rpx;
  180. }
  181. }
  182. .teacher {
  183. margin-top: 48rpx;
  184. display: flex;
  185. align-items: center;
  186. .teacher-photo {
  187. width: 64rpx;
  188. height: 64rpx;
  189. border-radius: 50px;
  190. overflow: hidden;
  191. img {
  192. width: 100%;
  193. height: 100%;
  194. }
  195. }
  196. .teacher-name {
  197. color: rgba(16, 16, 16, 1);
  198. margin-left: 24rpx;
  199. font-size: 28rpx;
  200. font-weight: bold;
  201. }
  202. }
  203. .progress {
  204. display: flex;
  205. align-items: center;
  206. margin-left: 16rpx;
  207. ::v-deep.u-progress {
  208. width: 128rpx;
  209. height: 4px !important;
  210. }
  211. .percent {
  212. margin-left: 8rpx;
  213. color: rgba(119, 119, 119, 1);
  214. font-size: 24rpx;
  215. }
  216. }
  217. }
  218. @media screen and(max-width:320px) {
  219. .infos {
  220. margin-left: 8rpx;
  221. .teacher {
  222. margin-top: 24rpx;
  223. }
  224. .tags {
  225. .item {
  226. padding: 0;
  227. margin-right: 8rpx;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. @media screen and(max-width:320px) {
  234. .courses-box {
  235. padding-right: 8rpx;
  236. }
  237. }
  238. </style>