courseWan.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. <uni-load-more :status="loadingType"></uni-load-more>
  26. </scroll-view>
  27. </view>
  28. </template>
  29. <script>
  30. import { getCourse } from '@/api/course.js';
  31. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  32. import { mapState, mapMutations } from 'vuex';
  33. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  34. export default {
  35. computed: {
  36. ...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
  37. },
  38. components: {
  39. uniLoadMore
  40. },
  41. data() {
  42. return {
  43. page: 1,
  44. limit: 10,
  45. loadingType: 'more',
  46. courseList: [
  47. ],
  48. }
  49. },
  50. onLoad() {
  51. if (this.hasLogin) {
  52. console.log(this.userInfo)
  53. this.loadData();
  54. }else{
  55. uni.showModal({
  56. title: '登录',
  57. content: '您未登录,是否马上登陆?',
  58. success: e => {
  59. console.log(e)
  60. if (e.confirm) {
  61. console.log("1111")
  62. interceptor();
  63. }
  64. },
  65. fail: e => {
  66. console.log(e);
  67. }
  68. });
  69. return;
  70. }
  71. },
  72. //下拉刷新
  73. onPullDownRefresh() {
  74. this.loadData('refresh');
  75. },
  76. //监听页面是否滚动到底部加载更多
  77. onReachBottom() {
  78. this.loadData();
  79. },
  80. methods: {
  81. async loadData(type = 'add', loading) {
  82. let obj = this;
  83. if (type === 'add') {
  84. if (obj.loadingType === 'nomore') {
  85. return;
  86. }
  87. obj.loadingType = 'loading';
  88. } else {
  89. obj.loadingType = 'more';
  90. }
  91. if (type === 'refresh') {
  92. // 清空数组
  93. obj.courseList = [];
  94. obj.page = 1
  95. }
  96. //获取课程
  97. getCourse({
  98. page: obj.page,
  99. limit: obj.limit
  100. }).then(e => {
  101. obj.courseList = obj.courseList.concat(e.data.data);
  102. console.log(obj.courseList);
  103. obj.page++
  104. //判断是否还有下一页,有是more 没有是nomore
  105. if (obj.limit==e.data.data.length) {
  106. obj.loadingType='more'
  107. } else{
  108. obj.loadingType='nomore'
  109. }
  110. if (type === 'refresh') {
  111. if (loading == 1) {
  112. uni.hideLoading();
  113. } else {
  114. uni.stopPullDownRefresh();
  115. }
  116. }
  117. })
  118. },
  119. nav(index){
  120. index = + index;
  121. let id = '';
  122. console.log(this.courseList[index]);
  123. if(this.courseList[+index]){
  124. id = this.courseList[index].id;
  125. }
  126. uni.navigateTo({
  127. url: '/pages/course/evaluate?id=' + id
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. page,
  135. .center {
  136. width: 100%;
  137. height: 100%;
  138. background-color: #f8f8f8;
  139. }
  140. .listBox {
  141. position: relative;
  142. padding-left: 28rpx;
  143. padding-top: 42rpx;
  144. margin: 0 auto;
  145. margin: 20rpx;
  146. padding-bottom: 20rpx;
  147. background: #FFFFFF;
  148. box-shadow: 0px 5rpx 24rpx 0px rgba(4, 0, 0, 0.06);
  149. border-radius: 15rpx;
  150. .type {
  151. position: absolute;
  152. top: 38rpx;
  153. right: 32rpx;
  154. width: 97rpx;
  155. height: 38rpx;
  156. text-align: center;
  157. background: #DFFFFA;
  158. border-radius: 5rpx;
  159. font-size: 22rpx;
  160. font-weight: 500;
  161. color: #1CC7C6;
  162. line-height: 38rpx;
  163. }
  164. .top {
  165. justify-content: start;
  166. margin-bottom: 34rpx;
  167. image {
  168. width: 76rpx;
  169. height: 60rpx;
  170. }
  171. .font {
  172. margin-left: 10rpx;
  173. .title {
  174. font-size: 32rpx;
  175. font-weight: bold;
  176. color: #333333;
  177. }
  178. .time {
  179. font-size: 24rpx;
  180. font-weight: 400;
  181. color: #808080;
  182. }
  183. }
  184. }
  185. .main {
  186. display: flex;
  187. justify-content: start;
  188. .left {
  189. width: 50%;
  190. .font{
  191. font-size: 28rpx;
  192. font-weight: 500;
  193. color: #808080;
  194. }
  195. }
  196. .right {
  197. padding-left: 10rpx;
  198. .font{
  199. font-size: 28rpx;
  200. font-weight: 500;
  201. color: #808080;
  202. }
  203. }
  204. }
  205. .button {
  206. margin-top: 40rpx;
  207. margin-left: 500rpx;
  208. width: 145rpx;
  209. height: 48rpx;
  210. border: 1rpx solid #FF5850;
  211. border-radius: 24rpx;
  212. font-size: 26rpx;
  213. font-weight: 500;
  214. color: #FF5850;
  215. text-align: center;
  216. line-height: 48rpx;
  217. }
  218. }
  219. </style>