courseWan.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="center">
  3. <scroll-view scroll-y="true" class="list">
  4. <view v-for="(item,index) in courseList" :key="index" class="listBox" @click="nav(index)">
  5. <view class="type">已完成</view>
  6. <view class="top flex">
  7. <image src="../../static/img/indexMycourse.png"></image>
  8. <view class="font">
  9. <view class="title">奥数能力提升班</view>
  10. <view class="time">{{item.start_time}}</view>
  11. </view>
  12. </view>
  13. <view class="main">
  14. <view class="left">
  15. <view class="font">授课科目: {{item.subject}}</view>
  16. <view class="font">班主任:</view>
  17. </view>
  18. <view class="right">
  19. <view class="font">授课老师: {{item.teacher}}</view>
  20. <view class="font">电话:</view>
  21. </view>
  22. </view>
  23. <view class="button">课程评价</view>
  24. </view>
  25. </scroll-view>
  26. </view>
  27. </template>
  28. <script>
  29. import { getCourse } from '@/api/course.js'
  30. export default {
  31. data() {
  32. return {
  33. page: 1,
  34. limit: 10,
  35. loadingType: 'more',
  36. courseList: [
  37. ],
  38. }
  39. },
  40. onLoad() {
  41. this.loadData();
  42. },
  43. //下拉刷新
  44. onPullDownRefresh() {
  45. this.loadData('refresh');
  46. },
  47. //监听页面是否滚动到底部加载更多
  48. onReachBottom() {
  49. this.loadData();
  50. },
  51. methods: {
  52. async loadData(type = 'add', loading) {
  53. let obj = this;
  54. if (type === 'add') {
  55. if (obj.loadingType === 'nomore') {
  56. return;
  57. }
  58. obj.loadingType = 'loading';
  59. } else {
  60. obj.loadingType = 'more';
  61. }
  62. if (type === 'refresh') {
  63. // 清空数组
  64. obj.courseList = [];
  65. obj.page = 1
  66. }
  67. //获取课程
  68. getCourse({
  69. page: obj.page,
  70. limit: obj.limit
  71. }).then(e => {
  72. obj.courseList = obj.courseList.concat(e.data.data);
  73. console.log(obj.courseList);
  74. //判断是否还有下一页,有是more 没有是nomore
  75. if (obj.limit==e.data.length) {
  76. obj.page++
  77. obj.loadingType='more'
  78. } else{
  79. obj.loadingType='nomore'
  80. }
  81. if (type === 'refresh') {
  82. if (loading == 1) {
  83. uni.hideLoading();
  84. } else {
  85. uni.stopPullDownRefresh();
  86. }
  87. }
  88. })
  89. },
  90. nav(index){
  91. index = + index;
  92. let id = '';
  93. console.log(this.courseList[index]);
  94. if(this.courseList[+index]){
  95. id = this.courseList[index].id;
  96. }
  97. uni.navigateTo({
  98. url: '/pages/course/evaluate?id=' + id
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. page,
  106. .center {
  107. width: 100%;
  108. height: 100%;
  109. background-color: #f8f8f8;
  110. }
  111. .listBox {
  112. position: relative;
  113. padding-left: 28rpx;
  114. padding-top: 42rpx;
  115. margin: 0 auto;
  116. margin: 20rpx;
  117. padding-bottom: 20rpx;
  118. background: #FFFFFF;
  119. box-shadow: 0px 5rpx 24rpx 0px rgba(4, 0, 0, 0.06);
  120. border-radius: 15rpx;
  121. .type {
  122. position: absolute;
  123. top: 38rpx;
  124. right: 32rpx;
  125. width: 97rpx;
  126. height: 38rpx;
  127. text-align: center;
  128. background: #DFFFFA;
  129. border-radius: 5rpx;
  130. font-size: 22rpx;
  131. font-weight: 500;
  132. color: #1CC7C6;
  133. line-height: 38rpx;
  134. }
  135. .top {
  136. justify-content: start;
  137. margin-bottom: 34rpx;
  138. image {
  139. width: 76rpx;
  140. height: 60rpx;
  141. }
  142. .font {
  143. margin-left: 10rpx;
  144. .title {
  145. font-size: 32rpx;
  146. font-weight: bold;
  147. color: #333333;
  148. }
  149. .time {
  150. font-size: 24rpx;
  151. font-weight: 400;
  152. color: #808080;
  153. }
  154. }
  155. }
  156. .main {
  157. display: flex;
  158. justify-content: start;
  159. .left {
  160. width: 50%;
  161. .font{
  162. font-size: 28rpx;
  163. font-weight: 500;
  164. color: #808080;
  165. }
  166. }
  167. .right {
  168. padding-left: 10rpx;
  169. .font{
  170. font-size: 28rpx;
  171. font-weight: 500;
  172. color: #808080;
  173. }
  174. }
  175. }
  176. .button {
  177. margin-top: 40rpx;
  178. margin-left: 500rpx;
  179. width: 145rpx;
  180. height: 48rpx;
  181. border: 1rpx solid #FF5850;
  182. border-radius: 24rpx;
  183. font-size: 26rpx;
  184. font-weight: 500;
  185. color: #FF5850;
  186. text-align: center;
  187. line-height: 48rpx;
  188. }
  189. }
  190. </style>