// 简化版列表的混入 export default { data() { return { list: [], params: { pageNo : 1, pageSize : 10, }, mixinListApi: '', isLoading: false } }, methods: { initData() { this.list = [] this.params.pageNo = 1 this.params.pageSize = 10 }, async getList() { this.isLoading = true if (!this.$api[this.mixinListApi]) { console.log('mixinApi不存在', this.mixinListApi); return } const res = await this.$api[this.mixinListApi]({ ...this.params }) if (res.code === 200 && res.result.record.length) { this.list = [...this.list, ...res.result.record] this.params.pageNo++ }else { uni.showToast({ title: '暂无数据', icon: 'none' }) } // 如果有在加载中 if (this.isLoading) { this.isLoading = false } // 有过有在下拉加载 uni.stopPullDownRefresh() }, }, async onShow() { await this.getList() }, onHide() { this.initData() }, async onPullDownRefresh() { this.initData() await this.getList() }, async onReachBottom() { await this.getList() } }