diff --git a/pages/index/order.vue b/pages/index/order.vue index 1e5585b..46b6ae0 100644 --- a/pages/index/order.vue +++ b/pages/index/order.vue @@ -28,8 +28,7 @@ - + @@ -38,14 +37,33 @@ export default { data() { return { - list: [] + list: [], + count: '', + form: { + page: 1, + status: 'loadmore', + }, }; }, onShow() { - this.storeinvoicelist() + this.initial() + }, + onReachBottom() { + if (this.form.status != 'nomore') { + this.form.page = ++this.form.page; + this.storeinvoicelist() + } + }, methods: { + initial() { + this.form = { + page: 1, + status: 'loadmore', + }, + this.storeinvoicelist() + }, clickoange(e) { if (e.status == 2 || e.status == 4 || e.status == 3) { uni.pro.navigateTo('index/orderinfo', { @@ -61,10 +79,29 @@ } }, async storeinvoicelist() { + this.form.status = 'loading'; let res = await this.api.storeinvoicelist({ - store_id: uni.getStorageSync('userId') + store_id: uni.getStorageSync('userId'), + page: this.form.page }) - this.list = res.data + if (this.form.page == 1 && res.data.list.length == 0) { + this.form.status = 'nomore' + return false; + } else { + setTimeout(() => { + if (this.form.page == 1) { + this.list = res.data.list + } else { + this.list = [...this.list, ...res.data.list]; + } + if (res.data.list.length < 10 || res.data.list.length > res.data.count) { + this.form.status = 'nomore'; + } else { + this.form.status = 'loadmore'; + } + }, 500) + } + console.log(this.list) }, } }