61 lines
1.3 KiB
Vue
61 lines
1.3 KiB
Vue
|
<template>
|
||
|
<view class="loadmore">
|
||
|
<u-loadmore :status="loadStatus" :bgColor="bgColor" margin-bottom="20"></u-loadmore>
|
||
|
</view>
|
||
|
</template>
|
||
|
<script>
|
||
|
/*
|
||
|
* @description 下拉加载
|
||
|
* @property {String} bgColor 背景色
|
||
|
* @property {Number} page 初始页码
|
||
|
* @event {Function} callback 下拉刷新请求的接口
|
||
|
**/
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
loadStatus: 'loadmore',
|
||
|
timer: true,
|
||
|
tpage: Number,
|
||
|
}
|
||
|
},
|
||
|
props: {
|
||
|
bgColor: String,
|
||
|
page: Number,
|
||
|
},
|
||
|
created() {
|
||
|
this.tpage = this.page;
|
||
|
},
|
||
|
methods: {
|
||
|
reachBottom() {
|
||
|
if(!this.timer) return false;
|
||
|
this.loadStatus = "loading";
|
||
|
this.tpage++;
|
||
|
this.$emit('callback', { page: this.tpage });
|
||
|
// this.$emit('callback', { page: this.tpage }).then(length => {
|
||
|
// if(length == 0) {
|
||
|
// this.tpage--;
|
||
|
// this.status = 'nomore';
|
||
|
// } else {
|
||
|
// this.status = 'loading';
|
||
|
// }
|
||
|
// }).catch(() => {
|
||
|
// this.loadStatus = "nomore";
|
||
|
// this.tpage--;
|
||
|
// })
|
||
|
// this.$parent.callback({ page: this.tpage }).then(length => {
|
||
|
// if(length == 0) {
|
||
|
// this.tpage--;
|
||
|
// this.status = 'nomore';
|
||
|
// } else {
|
||
|
// this.status = 'loading';
|
||
|
// }
|
||
|
// }).catch(() => {
|
||
|
// this.loadStatus = "nomore";
|
||
|
// this.tpage--;
|
||
|
// })
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
<style lang="scss" scoped>
|
||
|
</style>
|