设备接口列表对接

This commit is contained in:
仲么了
2023-04-04 08:47:19 +08:00
parent 0325347e06
commit feb7d7b6ed
8 changed files with 184 additions and 169 deletions

View File

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