myEvaluate.vue 1.4 KB

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