提交 93adf98d 编写于 作者: huangwensu's avatar huangwensu

滚动添加节流

上级 89936c07
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
}, },
data() { data() {
return { return {
hasSearchDate: true, hasSearchDate: false,
jumPathThird: '/search-message-list', jumPathThird: '/search-message-list',
curmbFirst:'消息查询', curmbFirst:'消息查询',
curmbSecond:'消息详情', curmbSecond:'消息详情',
...@@ -98,25 +98,84 @@ export default { ...@@ -98,25 +98,84 @@ export default {
_this.getElmByID('scroll-set').style.height = _this.containerHeight - 152 + "px"; _this.getElmByID('scroll-set').style.height = _this.containerHeight - 152 + "px";
if(_this.hasSearchDate) { // 有查询日期 滚动条最顶部 if(_this.hasSearchDate) { // 有查询日期 滚动条最顶部
el.scrollTop = 10; el.scrollTop = 10;
el.addEventListener('scroll', function() { }else { // 没有查询日期 滚动条最底部
let allH, sh;
allH = el.scrollTop + el.clientHeight;
sh = el.scrollHeight;
if(el.scrollTop < 1 && _this.hasHistoryData) {
_this.getHistoryData(0);
}
if((sh - allH <= 1) && _this.hasForwardData) {
_this.getDeatailData(0);
}
})
}else {
el.scrollTop = el.scrollHeight; el.scrollTop = el.scrollHeight;
el.addEventListener('scroll', function() { }
if(el.scrollTop < 5 && _this.hasHistoryData) { let flag = true, timeoutId = null, downflag = true, downtimeoutId = null;
_this.getHistoryData(0); el.addEventListener('scroll', function() {
let allH, sh;
allH = el.scrollTop + el.clientHeight;
sh = el.scrollHeight;
if(el.scrollTop < 1 && _this.hasHistoryData) {
if(flag) {
flag = false;
timeoutId && clearTimeout(timeoutId);
timeoutId = setTimeout( () => {
_this.getHistoryData(0);
flag = true;
}, 150)
}
}
if((sh - allH < 1) && _this.hasForwardData && _this.hasSearchDate) {
if(downflag) {
downflag = false;
downtimeoutId && clearTimeout(downtimeoutId);
downtimeoutId = setTimeout( () => {
_this.getDeatailData(0);
downflag = true;
}, 150)
} }
}) }
} })
// if(_this.hasSearchDate) { // 有查询日期 滚动条最顶部
// el.scrollTop = 10;
// let flag = true, timeoutId = null;
// el.addEventListener('scroll', function() {
// let allH, sh;
// allH = el.scrollTop + el.clientHeight;
// sh = el.scrollHeight;
// if(el.scrollTop < 1 && _this.hasHistoryData) {
// if(flag) {
// flag = false;
// timeoutId && clearTimeout(timeoutId);
// timeoutId = setTimeout( () => {
// _this.getHistoryData(0);
// flag = true;
// }, 150)
// }
// }
// if((sh - allH < 1) && _this.hasForwardData) {
// if(flag) {
// flag = false;
// timeoutId && clearTimeout(timeoutId);
// timeoutId = setTimeout( () => {
// _this.getDeatailData(0);
// flag = true;
// }, 150)
// }
// }
// })
// }else { // 没有查询日期 滚动条最底部
// el.scrollTop = el.scrollHeight;
// let flag = true, timeoutId = null;
// el.addEventListener('scroll', function() {
// if(el.scrollTop < 1 && _this.hasHistoryData) {
// if(flag) {
// flag = false;
// timeoutId && clearTimeout(timeoutId);
// timeoutId = setTimeout( () => {
// _this.getHistoryData(0);
// flag = true;
// }, 150)
// }
// }
// })
// }
},100); },100);
}, },
methods: { methods: {
......
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
totalRows: 0, totalRows: 0,
tableData: [], tableData: [],
loading: false, loading: false,
hasSearchDate: true // 查询条件不包含日期 hasSearchDate: false // 查询条件不包含日期
}; };
}, },
computed: {}, computed: {},
...@@ -131,7 +131,7 @@ export default { ...@@ -131,7 +131,7 @@ export default {
// 查看消息详情 // 查看消息详情
edit(row) { edit(row) {
if(this.searchParam.chooseDate) this.hasSearchDate = false; if(this.searchParam.chooseDate) this.hasSearchDate = true;
this.$router.push({ this.$router.push({
path: `/search-message-detail`, path: `/search-message-detail`,
query: { query: {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册