From af91855fc1ee80b1b354c96e915bfe69b8d2b76d Mon Sep 17 00:00:00 2001 From: asd Date: Tue, 3 Dec 2019 16:00:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/IndexFind.vue | 136 +++++++++++++++++++++++++++++-- src/components/indexfindhead.vue | 2 +- 2 files changed, 132 insertions(+), 6 deletions(-) diff --git a/src/IndexFind.vue b/src/IndexFind.vue index 4a7a0e4..35120d9 100644 --- a/src/IndexFind.vue +++ b/src/IndexFind.vue @@ -8,6 +8,8 @@
+ +
{{text}}
@@ -16,6 +18,8 @@
+ +
{{text}}
+ +
{{text}}
@@ -58,12 +64,29 @@ mounted(){ // http://lawpro.earnest.pro/uploads/20191121/145e1911017ac255f25d6eb760d0bb4c.jpg var t=this; t.axios.post("http://lawpro.earnest.pro/api/login_main/indexsearch", {where:t.$route.query.word,type:0}).then((res)=>{ - window.console.log(res) + // window.console.log(res) for(let i in res.data.data){ res.data.data[i].avatar= res.data.data[i].avatar.substr(1) res.data.data[i].avatar= "http://lawpro.earnest.pro/"+res.data.data[i].avatar } - t.list=res.data.data + // t.list=res.data.data + if (res.data.code == 200) { + t.list = res.data.data; + window.$(window).scroll(() => { + var windowH = window.$(window).height(); //设备可见区域高度 + var documentH = window.$(document).height(); //整个网页的高度(包括未显示的部分) + var scrollH = window.$(window).scrollTop(); //滚动条滚动上去的高度 + //或者 scrollH = $(document).scrollTop(); + if (windowH + scrollH >= documentH) { + // do something + // alert(2); + window.console.log(1); + t.getlist(); + } + }); + } else { + t.text = "暂无数据"; + } }) t.axios.post("http://lawpro.earnest.pro/api/login_main/indexsearch", {where:t.$route.query.word,type:5}).then((res)=>{ @@ -72,7 +95,24 @@ mounted(){ res.data.data[i].avatar= res.data.data[i].avatar.substr(1) res.data.data[i].avatar= "http://lawpro.earnest.pro/"+res.data.data[i].avatar } - t.list2=res.data.data + if (res.data.code == 200) { + t.list2 = res.data.data; + window.$(window).scroll(() => { + var windowH = window.$(window).height(); //设备可见区域高度 + var documentH = window.$(document).height(); //整个网页的高度(包括未显示的部分) + var scrollH = window.$(window).scrollTop(); //滚动条滚动上去的高度 + //或者 scrollH = $(document).scrollTop(); + if (windowH + scrollH >= documentH) { + // do something + // alert(2); + window.console.log(1); + t.getlist(); + } + }); + } else { + t.text = "暂无数据"; + } + // t.list2=res.data.data }) t.axios.post("http://lawpro.earnest.pro/api/login_main/indexsearch", {where:t.$route.query.word,type:2}).then((res)=>{ @@ -81,15 +121,98 @@ mounted(){ res.data.data[i].img= res.data.data[i].img.substr(1) res.data.data[i].img= "http://lawpro.earnest.pro/"+res.data.data[i].img } - t.list3=res.data.data + // t.list3=res.data.data + if (res.data.code == 200) { + t.list3 = res.data.data; + window.$(window).scroll(() => { + var windowH = window.$(window).height(); //设备可见区域高度 + var documentH = window.$(document).height(); //整个网页的高度(包括未显示的部分) + var scrollH = window.$(window).scrollTop(); //滚动条滚动上去的高度 + //或者 scrollH = $(document).scrollTop(); + if (windowH + scrollH >= documentH) { + // do something + // alert(2); + window.console.log(1); + t.getlist(); + } + }); + } else { + t.text = "暂无数据"; + } }) }, + watch:{ + no(){ + this.page = 0 + this.dynamiclist = [] + this.lock = false; + this.getlist() + } + }, methods:{ + getlist() { + if (this.lock) { + return "lock"; + } + this.lock = true; + var t = this; + t.page += 1; + t.axios.post("http://lawpro.earnest.pro/api/login_main/indexsearch", {where:t.$route.query.word,type:0,page: t.page}).then((res)=>{ + window.console.log(res) + for(let i in res.data.data){ + if (res.data.code == 200) { + t.list = t.list.concat(res.data.data); + t.lock = false; + } else { + t.text = "暂无更多"; + } + res.data.data[i].avatar= res.data.data[i].avatar.substr(1) + res.data.data[i].avatar= "http://lawpro.earnest.pro/"+res.data.data[i].avatar + } + t.list=res.data.data + }) + + t.axios.post("http://lawpro.earnest.pro/api/login_main/indexsearch", {where:t.$route.query.word,type:5,page: t.page}).then((res)=>{ + window.console.log(res) + if (res.data.code == 200) { + t.list = t.list.concat(res.data.data); + t.lock = false; + } else { + t.text = "暂无更多"; + } + for(let i in res.data.data){ + res.data.data[i].avatar= res.data.data[i].avatar.substr(1) + res.data.data[i].avatar= "http://lawpro.earnest.pro/"+res.data.data[i].avatar + } + t.list2=res.data.data + }) + + t.axios.post("http://lawpro.earnest.pro/api/login_main/indexsearch", {where:t.$route.query.word,type:2,page: t.page}).then((res)=>{ + window.console.log(res) + for(let i in res.data.data){ + if (res.data.code == 200) { + t.list = t.list.concat(res.data.data); + t.lock = false; + } else { + t.text = "暂无更多"; + } + res.data.data[i].img= res.data.data[i].img.substr(1) + res.data.data[i].img= "http://lawpro.earnest.pro/"+res.data.data[i].img + } + t.list3=res.data.data + }) + + + }, getno(e){ window.console.log(e) this.no=e + this.page = 0 + this.dynamiclist = [] + this.lock = false; + this.getlist() }, todetail(e, type) { window.console.log(e); @@ -141,7 +264,10 @@ data(){ list:[], list1:[], list2:[], - list3:[] + list3:[], + page:0, + lock:false, + text: "加载中" } } } diff --git a/src/components/indexfindhead.vue b/src/components/indexfindhead.vue index a6b28e6..9ec2271 100644 --- a/src/components/indexfindhead.vue +++ b/src/components/indexfindhead.vue @@ -114,7 +114,7 @@ export default { isshow() { // this.show = !this.show; this.$router.push({ - path: `/index` + path: `/` }); }, shuru(){ From 250dd7ad6e398e2e2a1ea4eea472d491add0db34 Mon Sep 17 00:00:00 2001 From: asd Date: Tue, 3 Dec 2019 16:04:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/IndexFind.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/IndexFind.vue b/src/IndexFind.vue index 35120d9..bb100af 100644 --- a/src/IndexFind.vue +++ b/src/IndexFind.vue @@ -151,6 +151,12 @@ mounted(){ this.getlist() } }, + beforeRouteLeave(a,b,c){ + window.$(window).scroll(() => { + + }); + c() + }, methods:{ getlist() { if (this.lock) { @@ -209,10 +215,10 @@ methods:{ getno(e){ window.console.log(e) this.no=e - this.page = 0 - this.dynamiclist = [] - this.lock = false; - this.getlist() + // this.page = 0 + // this.dynamiclist = [] + // this.lock = false; + // this.getlist() }, todetail(e, type) { window.console.log(e);