class_interaction_page.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="bg-white">
  3. <!-- 列表 -->
  4. <scroll-list ref="list" :option="option" @load="load" @refresh="refresh">
  5. <!-- 列表 -->
  6. <classroom-item v-for="(item, index) in list" :key="index" :data="item" />
  7. </scroll-list>
  8. </view>
  9. </template>
  10. <script>
  11. import Api from '../../api/api.js';
  12. import moment from 'moment';
  13. import ClassroomItem from './classroom_item.vue'
  14. export default {
  15. components: {
  16. ClassroomItem
  17. },
  18. data() {
  19. return {
  20. option: {
  21. size: 10,
  22. auto: true,
  23. loadDisabled: true
  24. },
  25. list: [],
  26. lastStartTime: '',
  27. page: 1
  28. };
  29. },
  30. computed: {
  31. },
  32. onReady() {},
  33. mounted() {
  34. },
  35. methods: {
  36. /// 初始化数据
  37. async requestData(isRefresh) {
  38. this.page = isRefresh ? 1 : this.page + 1
  39. var params = {
  40. "page": this.page,
  41. "rows": 10
  42. }
  43. var that = this
  44. Api.messageList(params).then( res => {
  45. if (res.code != 200) return;
  46. let data = res.data.content;
  47. var newList = []
  48. for (let i = 0; i < data.length; i++) {
  49. var item = data[i]
  50. var _startTime = moment(item.start_time).format('YYYY-MM-DD')
  51. item.isSection = that.lastStartTime != _startTime
  52. item.date = _startTime
  53. that.lastStartTime = _startTime
  54. }
  55. if (isRefresh) {
  56. that.list = data
  57. that.$refs.list.refreshSuccess({ list: that.list, total: res.data.totalSize });
  58. } else {
  59. that.list = [ ...that.list, ...data]
  60. this.$refs.list.loadSuccess({ list: this.list, total: res.data.totalSize });
  61. }
  62. })
  63. },
  64. // 刷新刷剧
  65. refresh(paging) {
  66. this.requestData(true)
  67. },
  68. load(paging) {
  69. this.requestData(false)
  70. },
  71. }
  72. };
  73. </script>
  74. <style scoped>
  75. </style>