浏览代码

专利详情返回按钮优化

zhuliu 1 年之前
父节点
当前提交
5d578946fe
共有 1 个文件被更改,包括 23 次插入1 次删除
  1. 23 1
      src/views/project/patentDetails/index.vue

+ 23 - 1
src/views/project/patentDetails/index.vue

@@ -44,7 +44,8 @@ export default {
       patentNo: this.$route.params.patentNo,
       patentNo: this.$route.params.patentNo,
       components: 'PatentDetails',
       components: 'PatentDetails',
       menuList: [],
       menuList: [],
-      evidenceData: {}
+      evidenceData: {},
+      currentState:0,
     };
     };
   },
   },
   watch: {},
   watch: {},
@@ -94,6 +95,19 @@ export default {
   mounted() {
   mounted() {
     if(this.search && !this.search.fromPath){
     if(this.search && !this.search.fromPath){
       this.search.fromPath = window.history.length
       this.search.fromPath = window.history.length
+      this.currentState = window.history.state.key
+      var that = this
+      window.addEventListener('popstate', function(event) {
+        // console.log(event,that.currentState,event.state.key)
+        // 在这里处理历史记录变化时的逻辑
+        if(that.currentState<event.state.key){
+          that.search.fromPath += 1
+        }else{
+          that.search.fromPath -= 1
+        }
+        
+        that.currentState = event.state.key
+      })
       this.$s.setSession('search',this.search)
       this.$s.setSession('search',this.search)
     }
     }
     if (this.evidence) {
     if (this.evidence) {
@@ -222,6 +236,7 @@ export default {
         this.getContrast()
         this.getContrast()
       }
       }
       this.getPiZhuData()
       this.getPiZhuData()
+      this.currentState = window.history.state.key
       this.$router.push(
       this.$router.push(
         {
         {
           path: '/patentDetails/' + this.patentNo,
           path: '/patentDetails/' + this.patentNo,
@@ -243,6 +258,13 @@ export default {
       )
       )
     },
     },
   },
   },
+  destroyed(){
+     window.removeEventListener('popstate', function(event) {
+        // 在这里处理历史记录变化时的逻辑
+        
+      })
+  }
+ 
 };
 };
 </script>
 </script>
 <style lang="scss" scoped>
 <style lang="scss" scoped>