From 150f832c8a08a673fa0f513f32fe167124537214 Mon Sep 17 00:00:00 2001 From: zhangsir Date: Wed, 20 Mar 2024 14:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BE=8B565=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/portal/case/Index.vue | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/views/portal/case/Index.vue b/src/views/portal/case/Index.vue index b47d5ccb..2ac5827d 100644 --- a/src/views/portal/case/Index.vue +++ b/src/views/portal/case/Index.vue @@ -621,6 +621,7 @@ export default { } dataList(allData[random]) })() + this.pageScroll = JSON.parse(sessionStorage.getItem("pagesScroll")) }, mounted() { let $this = this; @@ -699,7 +700,10 @@ export default { // window.addEventListener("scroll", this.handleScroll); // 获取年 this.getYears(); - + if(this.pageScroll){ + this.queryCondition.pageIndex = parseInt(this.pageScroll.pages) + this.queryCondition.type = this.pageScroll.type + } }, beforeDestroy() { // window.removeEventListener("scroll", this.handleScroll); @@ -789,6 +793,12 @@ export default { apiCase.startReadTimer(refId) } this.$router.push({ path: '/case/detail', query: { id } }); + this.pageScroll = { + pages: this.queryCondition.pageIndex, + scrollTop: window.pageYOffset, + type: this.queryCondition.type + } + sessionStorage.setItem('pagesScroll', JSON.stringify(this.pageScroll)) }, tylClick() { window.open("https://m.qingxuetang.com/x/?appId=qxtcorp306130"); @@ -1290,6 +1300,16 @@ export default { // 给所有的赋值 this.caseList.count = res.result.count; this.caseList.showPagCount = res.result.count; + this.$nextTick(() => { + if(JSON.parse(sessionStorage.getItem("pagesScroll"))){ + window.scrollTo({ + left: 0, + top: JSON.parse(sessionStorage.getItem("pagesScroll")).scrollTop, + behavior: 'smooth' + }) + sessionStorage.removeItem("pagesScroll") + } + }); } else { this.$message.error(res.message); }