消息下啦刷新

parent ebb2a346
......@@ -59,7 +59,9 @@
"path": "pages/messageList/index",
"style": {
"navigationBarTitleText": "消息",
"navigationStyle": "custom"
"navigationStyle": "custom",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
}
},
{
......
......@@ -30,25 +30,59 @@ import { ref } from "vue";
import { getEnumText } from "@/utils/utils";
import _ from "lodash";
const list = ref([]);
let pageNo = 1;
const params = ref({
pageNo: 1,
pageSize: 10,
isEnd: false
});
const goToDetail = item => {
xma.navigateTo({
url: `/pages/user/feedbackDetails/index?id=${item.id}`
});
};
const refresh = () => {
return new Promise((resolve, reject) => {
list.value = [];
params.value.pageNo = 1;
params.value.isEnd = false;
resolve();
});
};
const getList = () => {
getMessagePageList({
pageNo: pageNo++,
pageSize: 10
}).then(res => {
if (params.value.isEnd === true)
return new Promise(resolve => {
resolve();
});
xma.showLoading({
title: "加载中...",
mask: true
});
return getMessagePageList(params.value).then(res => {
if (res.data.length < params.value.pageSize) {
params.value.isEnd = true;
}
res.data.forEach(async v => {
v.typeText = await getEnumText("EnumMessageType", v.type);
});
console.log(res.data);
list.value = _.concat(list.value, res.data);
params.value.pageNo += 1;
list.value = list.value.concat(res.data);
xma.hideLoading();
});
};
onPullDownRefresh(() => {
refresh().then(() => {
getList().then(() => {
xma.stopPullDownRefresh();
});
});
});
// 触底加载
onReachBottom(() => {
getList();
});
getList();
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment