course.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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">授课科目:<text style=" display: inline-block;padding-left: 20rpx;">{{item.subject}}</text></view>
  16. <view class="font">班主任:<text style=" display: inline-block;padding-left: 20rpx;">{{ bzr }}</text></view>
  17. </view>
  18. <view class="right">
  19. <view class="font">授课老师:<text style=" display: inline-block;padding-left: 20rpx;">{{item.teacher}}</text></view>
  20. <view class="font">电话:<text style=" display: inline-block;padding-left: 20rpx;">{{ phone }}</text></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. type: 1,
  105. }).then(e => {
  106. obj.courseList = obj.courseList.concat(e.data.data);
  107. console.log(obj.courseList);
  108. //判断是否还有下一页,有是more 没有是nomore
  109. if (obj.limit==e.data.data.length) {
  110. obj.page++
  111. obj.loadingType='more'
  112. } else{
  113. obj.loadingType='nomore'
  114. }
  115. if (type === 'refresh') {
  116. if (loading == 1) {
  117. uni.hideLoading();
  118. } else {
  119. uni.stopPullDownRefresh();
  120. }
  121. }
  122. })
  123. },
  124. data(){
  125. my({}).then(({data}) => {
  126. this.bzr = data.manage.real_name;
  127. this.phone = data.manage.phone;
  128. })
  129. },
  130. nav(index){
  131. console.log(index)
  132. uni.navigateTo({
  133. url: '/pages/leave/leave?id=' + this.courseList[index].id+'&ifyid='+this.courseList[index].ifyid + '&grade_id=' + this.courseList[index].grade_id + '&subject_id=' + this.courseList[index].subject_id
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. page,
  141. .center {
  142. width: 100%;
  143. height: 100%;
  144. background-color: #f8f8f8;
  145. }
  146. .listBox {
  147. position: relative;
  148. padding: 42rpx 32rpx 20rpx 30rpx;
  149. margin: 0 auto;
  150. margin: 20rpx;
  151. background: #FFFFFF;
  152. box-shadow: 0px 5rpx 24rpx 0px rgba(4, 0, 0, 0.06);
  153. border-radius: 15rpx;
  154. .type {
  155. position: absolute;
  156. top: 38rpx;
  157. right: 32rpx;
  158. width: 97rpx;
  159. height: 38rpx;
  160. text-align: center;
  161. background: #FFDEDF;
  162. border-radius: 5rpx;
  163. font-size: 22rpx;
  164. font-weight: 500;
  165. color: #FF5850;
  166. line-height: 38rpx;
  167. }
  168. .top {
  169. justify-content: start;
  170. margin-bottom: 34rpx;
  171. image {
  172. width: 76rpx;
  173. height: 60rpx;
  174. }
  175. .font {
  176. margin-left: 10rpx;
  177. .title {
  178. font-size: 32rpx;
  179. font-weight: bold;
  180. color: #333333;
  181. }
  182. .time {
  183. margin-top: 14rpx;
  184. font-size: 24rpx;
  185. font-weight: 400;
  186. color: #808080;
  187. }
  188. }
  189. }
  190. .main {
  191. display: flex;
  192. justify-content: start;
  193. .left {
  194. width: 50%;
  195. padding-left: 10rpx;
  196. .font{
  197. margin-top: 20rpx;
  198. font-size: 28rpx;
  199. font-weight: 500;
  200. color: #808080;
  201. }
  202. }
  203. .right {
  204. padding-left: 10rpx;
  205. .font{
  206. margin-top: 20rpx;
  207. font-size: 28rpx;
  208. font-weight: 500;
  209. color: #808080;
  210. }
  211. }
  212. }
  213. .button {
  214. margin-top: 40rpx;
  215. margin-left: 500rpx;
  216. width: 145rpx;
  217. height: 48rpx;
  218. border: 1rpx solid #FF8219;
  219. border-radius: 24rpx;
  220. font-size: 26rpx;
  221. font-weight: 500;
  222. color: #FF8219;
  223. text-align: center;
  224. line-height: 48rpx;
  225. }
  226. }
  227. </style>