Browse Source

feat(student): 学生端作业列表支持下拉刷新

- 添加 onPullDownRefresh 方法实现下拉刷新功能
- 优化 loadData 方法,重置分页数据和表格列表
- 修改 getList 方法,使用 concat 将新数据追加到表格列表中
master
liutong 2 years ago
parent
commit
9d062542b7
  1. 22
      pages/student/index/job_list.vue

22
pages/student/index/job_list.vue

@ -67,6 +67,12 @@ import memberApi from '@/api/member.js';
}, },
onShow(){ onShow(){
this.init()//初始化 this.init()//初始化
},
//下拉刷新
async onPullDownRefresh() {
//重置为第一页
await this.loadData()
await this.getList()
}, },
methods: { methods: {
//初始化 //初始化
@ -83,11 +89,16 @@ import memberApi from '@/api/member.js';
} }
}, },
//重置为第一页 //重置为第一页
loadData() { async loadData() {
setTimeout(() => { this.isReachedBottom = false; // 重置状态,以便下次触发加载更多
this.isReachedBottom = false; // 重置状态,以便下次触发加载更多
}, 1000); this.filteredData.page = 1//当前页码
this.filteredData.limit = 10//每页返回数据条数
this.filteredData.total = 10//数据总条数
this.tableList = []
}, },
//获取作业列表 //获取作业列表
async getList(){ async getList(){
this.loading = true this.loading = true
@ -114,7 +125,8 @@ import memberApi from '@/api/member.js';
return return
} }
this.tableList = res.data.data this.tableList = this.tableList.concat(res.data.data); // 使用 concat 方法 将新数据追加到数组中
console.log('列表',this.tableList) console.log('列表',this.tableList)
this.filteredData.total = res.data.total this.filteredData.total = res.data.total
this.filteredData.page++ this.filteredData.page++

Loading…
Cancel
Save