消息下啦刷新

parent ebb2a346
...@@ -59,7 +59,9 @@ ...@@ -59,7 +59,9 @@
"path": "pages/messageList/index", "path": "pages/messageList/index",
"style": { "style": {
"navigationBarTitleText": "消息", "navigationBarTitleText": "消息",
"navigationStyle": "custom" "navigationStyle": "custom",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
} }
}, },
{ {
......
...@@ -30,25 +30,59 @@ import { ref } from "vue"; ...@@ -30,25 +30,59 @@ import { ref } from "vue";
import { getEnumText } from "@/utils/utils"; import { getEnumText } from "@/utils/utils";
import _ from "lodash"; import _ from "lodash";
const list = ref([]); const list = ref([]);
let pageNo = 1;
const params = ref({
pageNo: 1,
pageSize: 10,
isEnd: false
});
const goToDetail = item => { const goToDetail = item => {
xma.navigateTo({ xma.navigateTo({
url: `/pages/user/feedbackDetails/index?id=${item.id}` 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 = () => { const getList = () => {
getMessagePageList({ if (params.value.isEnd === true)
pageNo: pageNo++, return new Promise(resolve => {
pageSize: 10 resolve();
}).then(res => { });
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 => { res.data.forEach(async v => {
v.typeText = await getEnumText("EnumMessageType", v.type); v.typeText = await getEnumText("EnumMessageType", v.type);
}); });
console.log(res.data); params.value.pageNo += 1;
list.value = _.concat(list.value, res.data); list.value = list.value.concat(res.data);
xma.hideLoading();
}); });
}; };
onPullDownRefresh(() => {
refresh().then(() => {
getList().then(() => {
xma.stopPullDownRefresh();
});
});
});
// 触底加载
onReachBottom(() => {
getList();
});
getList(); getList();
</script> </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