洛阳学员端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

  1. <template>
  2. <view class="main">
  3. <comments :list="list" @changeNav="changeNav"></comments>
  4. <view style="padding-bottom: 20rpx;" v-if="list.length">
  5. <u-loadmore :status="status" />
  6. </view>
  7. <nodata v-if="!list.length&&status=='nomore'"></nodata>
  8. </view>
  9. </template>
  10. <script>
  11. import comments from '../comments/comments.vue'
  12. import { getSchoolListComment } from '@/config/api.js'
  13. export default {
  14. components: { comments },
  15. data() {
  16. return {
  17. params: {
  18. pageNo: 1,
  19. pageSize: 20,
  20. schoolId: '',
  21. condition: 0
  22. },
  23. total: 20,
  24. list: [],
  25. status: 'loading'
  26. }
  27. },
  28. onLoad(options) {
  29. this.params.schoolId = options.id
  30. this.getSchoolListCommentFn()
  31. },
  32. onPullDownRefresh() {
  33. this.getSchoolListCommentFn().then(()=>{
  34. uni.stopPullDownRefresh()
  35. })
  36. },
  37. onReachBottom() {
  38. if(this.list.length<this.total) this.getSchoolListCommentFn()
  39. },
  40. methods: {
  41. changeNav(val) {
  42. this.params.condition = val
  43. this.initList()
  44. },
  45. initList() {
  46. this.params.pageNo = 1
  47. this.status = 'loading'
  48. this.list = []
  49. this.getSchoolListCommentFn()
  50. },
  51. async getSchoolListCommentFn() {
  52. const {data: res} = await getSchoolListComment(this.params)
  53. this.params.pageNo ++
  54. let arr = res.list.map(item=>{
  55. if(item.images) {
  56. item.images = item.images.split(',')
  57. }
  58. return item
  59. })
  60. this.list.push(...arr)
  61. this.total = res.total
  62. if(this.list.length>=this.total) this.status = 'nomore'
  63. }
  64. }
  65. }
  66. </script>
  67. <style>
  68. </style>