courseWan.vue 5.5 KB

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