<script>
import {
get_lists
} from '@/config/api.js'
export default {
data() {
return {
list: [],
data: {
size: 10,
page: 1,
cat_id: 3
},
status:'loading'
}
},
onShow() {
this.getdata()
},
onReachBottom() {
this.getmore();
},
methods: {
goback() {
uni.navigateBack({
})
},
getdata() {
var that = this;
that.data.page = 1
that.status = 'loading'
get_lists({
params: this.data,
custom: {
auth: true
}
}).then(res => {
this.status = 'loadmore'
if (res.code == 1) {
that.list = res.data.data
}
}).catch(err => {
})
},
getmore() {
var that = this;
that.data.page = that.data.page + 1
this.status = 'loading'
get_lists({
params: this.data,
custom: {
auth: true
}
}).then(res => {
var data = res.data.data;
if (!data || data.length == 0) {
that.status = 'nomore';
} else {
this.status = 'loadmore'
}
for (var i = 0; i < data.length; i++) {
that.list.push(data[i]);
}
}).catch(err => {
})
},
}
}
</script>