洛阳学员端
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.

72 lines
1.5 KiB

10 months ago
9 months ago
10 months ago
  1. <template>
  2. <view class="pageBg">
  3. <view class="pad">
  4. <view class="card" v-for="(item,index) in list" :key="index">
  5. <commentItem :item="item"/>
  6. </view>
  7. <view class="card" v-if="!list.length">
  8. <nodata>暂无评价</nodata>
  9. </view>
  10. </view>
  11. <view style="padding-bottom: 20rpx;" v-if="list.length>4">
  12. <u-loadmore :status="status" />
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { getUsersCommentById } from '@/config/api.js'
  18. import commentItem from './comp/commentItem.vue'
  19. export default {
  20. components: { commentItem },
  21. data() {
  22. return {
  23. params: {
  24. userId: '', pageNo: 1,pageSize: 20
  25. },
  26. total: 20,
  27. status: 'loading',
  28. list: []
  29. }
  30. },
  31. onLoad() {
  32. this.getUsersCommentByIdFn()
  33. this.params.userId = this.userId
  34. },
  35. onPullDownRefresh() {
  36. this.params.pageNo = 1
  37. this.list = []
  38. this.getUsersCommentByIdFn().then(()=>{
  39. uni.stopPullDownRefresh()
  40. })
  41. },
  42. onReachBottom() {
  43. if(this.total>this.list.length) {
  44. this.getUsersCommentByIdFn()
  45. }
  46. },
  47. methods: {
  48. async getUsersCommentByIdFn() {
  49. const {data: res} = await getUsersCommentById(this.params)
  50. this.params.pageNo ++
  51. let arr = res.list.map(item=>{
  52. if(item.images) {
  53. item.images = item.images.split(',')
  54. }
  55. return item
  56. })
  57. this.list.push(...res.list)
  58. this.total = res.total
  59. if(this.list.length>=this.total) this.status = 'nomore'
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .card {
  66. width: 100%;
  67. padding: 24rpx 28rpx;
  68. margin-bottom: 20rpx;
  69. }
  70. </style>