course.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="center">
  3. <view class="english">various courses for children</view>
  4. <scroll-view scroll-y="true" class="list">
  5. <view v-for="(item,index) in courseList" :key="index" class="listBox" @click="nav(index)">
  6. <view class="bg"></view>
  7. <view class="title">暑假培训阅读精品课</view>
  8. <view class="teacher">授课科目:{{ item.subject}} {{ item.teacher}}</view>
  9. <view class="bzr">{{ item.bzr }}</view>
  10. <view class="button">上传作业</view>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. </template>
  15. <script>
  16. import { getCourse } from '@/api/course.js'
  17. export default {
  18. data() {
  19. return {
  20. page: 1,
  21. limit: 10,
  22. loadingType: 'more',
  23. courseList: [
  24. ],
  25. }
  26. },
  27. onLoad() {
  28. this.loadData();
  29. },
  30. //下拉刷新
  31. onPullDownRefresh() {
  32. this.loadData('refresh');
  33. },
  34. //监听页面是否滚动到底部加载更多
  35. onReachBottom() {
  36. this.loadData();
  37. },
  38. methods: {
  39. async loadData(type = 'add', loading) {
  40. let obj = this;
  41. if (type === 'add') {
  42. if (obj.loadingType === 'nomore') {
  43. return;
  44. }
  45. obj.loadingType = 'loading';
  46. } else {
  47. obj.loadingType = 'more';
  48. }
  49. if (type === 'refresh') {
  50. // 清空数组
  51. obj.courseList = [];
  52. obj.page = 1
  53. }
  54. //获取课程
  55. getCourse({
  56. page: obj.page,
  57. limit: obj.limit
  58. }).then(e => {
  59. obj.courseList = obj.courseList.concat(e.data.data);
  60. console.log(obj.courseList);
  61. //判断是否还有下一页,有是more 没有是nomore
  62. if (obj.limit==e.data.length) {
  63. obj.page++
  64. obj.loadingType='more'
  65. } else{
  66. obj.loadingType='nomore'
  67. }
  68. if (type === 'refresh') {
  69. if (loading == 1) {
  70. uni.hideLoading();
  71. } else {
  72. uni.stopPullDownRefresh();
  73. }
  74. }
  75. })
  76. },
  77. nav(index){
  78. uni.navigateTo({
  79. url: '/pages/homework/setHomework?id=' + this.courseList[index].id
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. page,
  87. .center {
  88. width: 100%;
  89. height: 100%;
  90. background-color: #f8f8f8;
  91. }
  92. .english {
  93. padding-left: 41rpx;
  94. font-size: 25rpx;
  95. font-family: Source Han Sans CN;
  96. font-weight: 400;
  97. color: #C2C2C2;
  98. }
  99. .list {
  100. height: 1100rpx;
  101. }
  102. .listBox {
  103. position: relative;
  104. width: 90%;
  105. height: 250rpx;
  106. margin: 0 auto;
  107. margin-top: 34rpx;
  108. box-shadow: 0rpx 5rpx 16rpx 0rpx rgba(253, 90, 84, 0.48);
  109. border-radius: 28rpx;
  110. .bg {
  111. width: 100%;
  112. height: 100%;
  113. position: absolute;
  114. left: 0;
  115. top: 0;
  116. background-color: #4EADFA;;
  117. border-radius: 28rpx;
  118. }
  119. .title {
  120. position: relative;
  121. padding-top: 36rpx;
  122. padding-left: 36rpx;
  123. font-size: 36rpx;
  124. font-weight: bold;
  125. color: #FFFFFF;
  126. z-index: 1;
  127. }
  128. .teacher {
  129. position: relative;
  130. margin-top: 56rpx;
  131. margin-left: 36rpx;
  132. font-size: 24rpx;
  133. font-weight: 500;
  134. color: #FFFFFF;
  135. z-index: 1;
  136. }
  137. .bzr {
  138. position: relative;
  139. margin-left: 36rpx;
  140. font-size: 24rpx;
  141. font-weight: 500;
  142. color: #FFFFFF;
  143. z-index: 1;
  144. }
  145. .button {
  146. position: absolute;
  147. right: 26rpx;
  148. bottom: 35rpx;
  149. width: 160rpx;
  150. height: 57rpx;
  151. background: #FFFFFF;
  152. border-radius: 28rpx;
  153. text-align: center;
  154. line-height: 57rpx;
  155. font-size: 27rpx;
  156. font-weight: bold;
  157. color: #FD5954;
  158. }
  159. }
  160. </style>