details.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. </template>
  3. <script>
  4. import { getLeave } from '@/api/course.js'
  5. export default {
  6. data() {
  7. return{
  8. page: 1,
  9. limit: 10,
  10. loadingType: 'more',
  11. leaveList:[]
  12. }
  13. },
  14. onLoad() {
  15. this.loadData()
  16. },
  17. //下拉刷新
  18. onPullDownRefresh() {
  19. this.loadData('refresh');
  20. },
  21. //监听页面是否滚动到底部加载更多
  22. onReachBottom() {
  23. this.loadData();
  24. },
  25. methods: {
  26. async loadData(type = 'add', loading){
  27. let obj = this;
  28. if (type === 'add') {
  29. if (obj.loadingType === 'nomore') {
  30. return;
  31. }
  32. obj.loadingType = 'loading';
  33. } else {
  34. obj.loadingType = 'more';
  35. }
  36. if (type === 'refresh') {
  37. // 清空数组
  38. obj.courseList = [];
  39. obj.page = 1
  40. }
  41. //获取反馈列表
  42. getLeave({
  43. page: obj.page,
  44. limit: obj.limit
  45. }).then(e => {
  46. obj.leaveList = obj.leaveList.concat(e.data.data);
  47. console.log(obj.leaveList)
  48. //判断是否还有下一页,有是more 没有是nomore
  49. if (obj.limit==e.data.length) {
  50. obj.page++
  51. obj.loadingType='more'
  52. } else{
  53. obj.loadingType='nomore'
  54. }
  55. if (type === 'refresh') {
  56. if (loading == 1) {
  57. uni.hideLoading();
  58. } else {
  59. uni.stopPullDownRefresh();
  60. }
  61. }
  62. })
  63. },
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. </style>