myCourses.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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>
  49. </view>
  50. </view>
  51. </view>
  52. <u-divider v-if="courseList.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px">没有更多了</u-divider>
  53. </view>
  54. </template>
  55. <script>
  56. import * as mineApi from '@/apis/youth/mine.js'
  57. export default {
  58. data() {
  59. return {
  60. pageNum: 1,
  61. pageSize: 5,
  62. recordsTotal: 0,
  63. courseList: [],
  64. studentId: ''
  65. }
  66. },
  67. onReady() {
  68. if (this.carhelp.getStudentId()) {
  69. this.studentId = this.carhelp.getStudentId().studentId;
  70. this.getLoadMyCourses();
  71. }
  72. },
  73. onReachBottom() {
  74. if (this.courseList.length < this.recordsTotal) {
  75. this.myLoadmore();
  76. }
  77. },
  78. methods: {
  79. myLoadmore() {
  80. this.pageNum += 1;
  81. this.getLoadMyCourses();
  82. },
  83. getLoadMyCourses(bl) {
  84. uni.showLoading({
  85. title: "加载中",
  86. mask: true,
  87. })
  88. if (bl) {
  89. this.courseList = [];
  90. this.pageNum = 1;
  91. }
  92. mineApi.loadMyCourses({
  93. studentId: this.studentId,
  94. pageNum: this.pageNum,
  95. pageSize: this.pageSize
  96. }).then((res) => {
  97. uni.hideLoading();
  98. this.courseList = [
  99. ...this.courseList,
  100. ...res.data.data
  101. ];
  102. this.recordsTotal = res.data.recordsTotal;
  103. }).catch(error => {
  104. uni.showToast({
  105. title: error,
  106. icon: "none"
  107. })
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .courses-box {
  115. display: flex;
  116. padding: 24rpx;
  117. background-color: #fff;
  118. margin: 24rpx 32rpx 0 32rpx;
  119. border-radius: 24rpx;
  120. .photo {
  121. width: 100px;
  122. height: 100px;
  123. border-radius: 4px;
  124. overflow: hidden;
  125. img {
  126. width: 100%;
  127. height: 100%;
  128. }
  129. }
  130. .infos {
  131. margin-left: 24rpx;
  132. .title {
  133. display: flex;
  134. justify-content: space-between;
  135. .text {
  136. width: 70%;
  137. color: rgba(51, 51, 51, 1);
  138. font-size: 16px;
  139. font-weight: bold;
  140. text-overflow: ellipsis;
  141. white-space: nowrap;
  142. overflow: hidden;
  143. }
  144. .state {
  145. width: 96rpx;
  146. line-height: 40rpx;
  147. border-radius: 8rpx;
  148. background-color: rgba(13, 186, 199, 1);
  149. color: rgba(255, 255, 255, 1);
  150. font-size: 22rpx;
  151. text-align: center;
  152. margin-left: 24rpx;
  153. }
  154. .stateClose {
  155. width: 96rpx;
  156. line-height: 40rpx;
  157. border-radius: 8rpx;
  158. background-color: rgba(165, 168, 184, 1);
  159. color: rgba(255, 255, 255, 1);
  160. font-size: 22rpx;
  161. text-align: center;
  162. margin-left: 24rpx;
  163. }
  164. }
  165. .tags {
  166. display: flex;
  167. margin-top: 12rpx;
  168. .item {
  169. line-height: 40rpx;
  170. border-radius: 4px;
  171. background-color: rgba(241, 243, 244, 1);
  172. color: rgba(136, 133, 133, 1);
  173. font-size: 24rpx;
  174. text-align: center;
  175. padding: 0 8rpx;
  176. margin-right: 16rpx;
  177. }
  178. }
  179. .teacher {
  180. margin-top: 48rpx;
  181. display: flex;
  182. align-items: center;
  183. .teacher-photo {
  184. width: 64rpx;
  185. height: 64rpx;
  186. border-radius: 50px;
  187. overflow: hidden;
  188. img {
  189. width: 100%;
  190. height: 100%;
  191. }
  192. }
  193. .teacher-name {
  194. color: rgba(16, 16, 16, 1);
  195. margin-left: 24rpx;
  196. font-size: 28rpx;
  197. font-weight: bold;
  198. }
  199. }
  200. .progress {
  201. display: flex;
  202. align-items: center;
  203. margin-left: 16rpx;
  204. /deep/.u-progress {
  205. width: 128rpx;
  206. height: 4px !important;
  207. }
  208. .percent {
  209. margin-left: 8rpx;
  210. color: rgba(119, 119, 119, 1);
  211. font-size: 24rpx;
  212. }
  213. }
  214. }
  215. @media screen and(max-width:320px) {
  216. .infos {
  217. margin-left: 8rpx;
  218. .teacher {
  219. margin-top: 24rpx;
  220. }
  221. .tags {
  222. .item {
  223. padding: 0;
  224. margin-right: 8rpx;
  225. }
  226. }
  227. }
  228. }
  229. }
  230. @media screen and(max-width:320px) {
  231. .courses-box {
  232. padding-right: 8rpx;
  233. }
  234. }
  235. </style>