course.vue 4.5 KB

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