course.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 { saveUrl, interceptor } from '@/utils/loginUtils.js';
  33. import { mapState, mapMutations } from 'vuex';
  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. //判断是否还有下一页,有是more 没有是nomore
  104. if (obj.limit==e.data.data.length) {
  105. obj.page++
  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. uni.navigateTo({
  121. url: '/pages/homework/setHomework?id=' + this.courseList[index].id
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. page,
  129. .center {
  130. width: 100%;
  131. height: 100%;
  132. background-color: #f8f8f8;
  133. }
  134. .listBox {
  135. position: relative;
  136. padding-left: 28rpx;
  137. padding-top: 42rpx;
  138. margin: 0 auto;
  139. margin: 20rpx;
  140. padding-bottom: 20rpx;
  141. background: #FFFFFF;
  142. box-shadow: 0px 5rpx 24rpx 0px rgba(4, 0, 0, 0.06);
  143. border-radius: 15rpx;
  144. .type {
  145. position: absolute;
  146. top: 38rpx;
  147. right: 32rpx;
  148. width: 97rpx;
  149. height: 38rpx;
  150. text-align: center;
  151. background: #FFDEDF;
  152. border-radius: 5rpx;
  153. font-size: 22rpx;
  154. font-weight: 500;
  155. color: #FF5850;
  156. line-height: 38rpx;
  157. }
  158. .top {
  159. justify-content: start;
  160. margin-bottom: 34rpx;
  161. image {
  162. width: 76rpx;
  163. height: 60rpx;
  164. }
  165. .font {
  166. margin-left: 10rpx;
  167. .title {
  168. font-size: 32rpx;
  169. font-weight: bold;
  170. color: #333333;
  171. }
  172. .time {
  173. font-size: 24rpx;
  174. font-weight: 400;
  175. color: #808080;
  176. }
  177. }
  178. }
  179. .main {
  180. display: flex;
  181. justify-content: start;
  182. .left {
  183. width: 50%;
  184. .font{
  185. font-size: 28rpx;
  186. font-weight: 500;
  187. color: #808080;
  188. }
  189. }
  190. .right {
  191. padding-left: 10rpx;
  192. .font{
  193. font-size: 28rpx;
  194. font-weight: 500;
  195. color: #808080;
  196. }
  197. }
  198. }
  199. .button {
  200. margin-top: 40rpx;
  201. margin-left: 500rpx;
  202. width: 145rpx;
  203. height: 48rpx;
  204. border: 1rpx solid #FF8219;
  205. border-radius: 24rpx;
  206. font-size: 26rpx;
  207. font-weight: 500;
  208. color: #FF8219;
  209. text-align: center;
  210. line-height: 48rpx;
  211. }
  212. }
  213. </style>