2023-01-11 16:33:13 +08:00
|
|
|
export default {
|
|
|
|
|
onPullDownRefresh () {
|
|
|
|
|
this.store && this.store.reload();
|
|
|
|
|
this.store.loadedCallback = () => {
|
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
onReachBottom () {
|
|
|
|
|
if (this.store.status != "noMore") {
|
|
|
|
|
this.store.next && this.store.next();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
store: {},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
DataSource (url) {
|
|
|
|
|
var me = this;
|
|
|
|
|
return {
|
|
|
|
|
data: [],
|
|
|
|
|
status: "more",
|
|
|
|
|
empty: false,
|
|
|
|
|
total: 0,
|
2023-03-30 09:04:07 +08:00
|
|
|
header: {
|
|
|
|
|
"Content-Type": "application/json;charset=UTF-8",
|
|
|
|
|
},
|
2023-01-11 16:33:13 +08:00
|
|
|
params: {
|
2023-03-30 09:04:07 +08:00
|
|
|
currentPage: 1,
|
|
|
|
|
pageSize: 20,
|
2023-01-11 16:33:13 +08:00
|
|
|
},
|
|
|
|
|
reload () {
|
|
|
|
|
this.data = [];
|
|
|
|
|
this.status = "loading";
|
|
|
|
|
this.empty = false;
|
2023-03-30 09:04:07 +08:00
|
|
|
this.params.currentPage = 1;
|
2023-01-11 16:33:13 +08:00
|
|
|
this.next();
|
|
|
|
|
},
|
|
|
|
|
callBack: null,
|
|
|
|
|
firstCallBack: null,
|
|
|
|
|
loadedCallback: null,
|
|
|
|
|
next () {
|
|
|
|
|
me.$request({
|
|
|
|
|
url: url,
|
2023-03-30 09:04:07 +08:00
|
|
|
data: this.params,
|
2023-01-11 16:33:13 +08:00
|
|
|
header: this.header,
|
|
|
|
|
method: "POST",
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
console.warn(res);
|
2023-03-30 09:04:07 +08:00
|
|
|
let resultData = res.rows || res.data?.list || res.data?.records || [];
|
|
|
|
|
if (this.params.currentPage == 1) {
|
2023-01-11 16:33:13 +08:00
|
|
|
this.data = resultData;
|
|
|
|
|
if (resultData.length == 0 || resultData == 0) {
|
|
|
|
|
this.empty = true;
|
2023-03-30 09:04:07 +08:00
|
|
|
} else if (resultData.length < this.params.pageSize) {
|
2023-01-11 16:33:13 +08:00
|
|
|
this.status = "noMore";
|
|
|
|
|
} else if (res.total == resultData.length) {
|
|
|
|
|
this.status = "noMore";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.data.push(...resultData);
|
2023-03-30 09:04:07 +08:00
|
|
|
if (resultData.length < this.params.pageSize) {
|
2023-01-11 16:33:13 +08:00
|
|
|
this.status = "noMore";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-30 09:04:07 +08:00
|
|
|
if (this.params.currentPage == 1) {
|
2023-01-11 16:33:13 +08:00
|
|
|
this.firstCallBack && this.firstCallBack();
|
|
|
|
|
}
|
|
|
|
|
this.loadedCallback && this.loadedCallback();
|
2023-03-30 09:04:07 +08:00
|
|
|
this.params.currentPage++;
|
2023-01-11 16:33:13 +08:00
|
|
|
this.total = res.total;
|
|
|
|
|
this.loading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|