coursePj.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. console.log(e)
  60. obj.courseList = obj.courseList.concat(e.data.data);
  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. index = + index;
  79. let id = '';
  80. console.log(this.courseList[index]);
  81. if(this.courseList[+index]){
  82. id = this.courseList[index].id;
  83. }
  84. uni.navigateTo({
  85. url: '/pages/course/evaluate?id=' + id
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. page,
  93. .center {
  94. width: 100%;
  95. height: 100%;
  96. background-color: #f8f8f8;
  97. }
  98. .english {
  99. padding-left: 41rpx;
  100. font-size: 25rpx;
  101. font-family: Source Han Sans CN;
  102. font-weight: 400;
  103. color: #C2C2C2;
  104. }
  105. .list {
  106. height: calc(100%-400px);
  107. }
  108. .listBox {
  109. position: relative;
  110. width: 90%;
  111. height: 250rpx;
  112. margin: 0 auto;
  113. margin-top: 34rpx;
  114. box-shadow: 0rpx 5rpx 16rpx 0rpx rgba(253, 90, 84, 0.48);
  115. border-radius: 28rpx;
  116. .bg {
  117. width: 100%;
  118. height: 100%;
  119. position: absolute;
  120. left: 0;
  121. top: 0;
  122. background-color: #4EADFA;;
  123. border-radius: 28rpx;
  124. }
  125. .title {
  126. position: relative;
  127. padding-top: 36rpx;
  128. padding-left: 36rpx;
  129. font-size: 36rpx;
  130. font-weight: bold;
  131. color: #FFFFFF;
  132. z-index: 1;
  133. }
  134. .teacher {
  135. position: relative;
  136. margin-top: 56rpx;
  137. margin-left: 36rpx;
  138. font-size: 24rpx;
  139. font-weight: 500;
  140. color: #FFFFFF;
  141. z-index: 1;
  142. }
  143. .bzr {
  144. position: relative;
  145. margin-left: 36rpx;
  146. font-size: 24rpx;
  147. font-weight: 500;
  148. color: #FFFFFF;
  149. z-index: 1;
  150. }
  151. .button {
  152. position: absolute;
  153. right: 26rpx;
  154. bottom: 35rpx;
  155. width: 160rpx;
  156. height: 57rpx;
  157. background: #FFFFFF;
  158. border-radius: 28rpx;
  159. text-align: center;
  160. line-height: 57rpx;
  161. font-size: 27rpx;
  162. font-weight: bold;
  163. color: #FD5954;
  164. }
  165. }
  166. </style>