From 854788c1a7d96d3d693e45b7efc09fc56d5a933f Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Sat, 3 Jun 2023 11:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=86=E9=A2=91=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/short_video/nvueSwiper/index.nvue | 133 ++++++------------------ 1 file changed, 32 insertions(+), 101 deletions(-) diff --git a/pages/short_video/nvueSwiper/index.nvue b/pages/short_video/nvueSwiper/index.nvue index 877e446..7f25313 100644 --- a/pages/short_video/nvueSwiper/index.nvue +++ b/pages/short_video/nvueSwiper/index.nvue @@ -203,7 +203,7 @@ + :style="'width: '+ windowWidth +'px; height: '+ windowHeight +'px;'" :refresher-triggered="isTriggered" @scrolltolower="getGoods()" > @@ -388,10 +388,11 @@ where: { category_id: -1, page: 1, - limit: 10 + limit: 5 }, communityId:'', - Listcount:'' + Listcount:'', + loadMore: true, } }, watch: { @@ -426,7 +427,6 @@ } }, onLoad(options) { - console.log(options); this.getOptions(options); this.videoID = options.id; this.isUser = options.user == 1 ? true : false; @@ -451,27 +451,6 @@ }, onReady: function() {}, methods: { - async GetList(){ - // if(this.cateGoods.length > ) - console.log(this.Listcount); - if(this.cateGoods.length < this.Listcount){ - console.log('123'); - const {data} = await graphicLstApi({ - category_id:-1, - page: this.page++, - limit: this.limit, - }) - this.cateGoods.push(...data.list) - if(data.list.length < this.limit){ - this.$util.Tips({ - title: '没有更多了', - }); - } - } - // console.log(this.cateGoods.length); - - }, - giveStart(item) { let status = item.relevance_id ? 0 : 1 graphicStartApi(item.community_id, { @@ -514,6 +493,7 @@ this.page = 1; this.loadVideo = true; this.dataList = []; + this.loadMore = true; n == 1 ? this.get() : ''; n == 2 ? this.getFocusList() : ''; n == 3 ? this.getGoods() : ''; @@ -528,12 +508,17 @@ this.navTap(1) }, async getGoods() { + if (!this.loadMore) { + return; + } const { data } = await graphicLstApi(this.where) - console.log(data); - this.Listcount=data.count - this.cateGoods = data.list + this.cateGoods.push(...data.list) + this.where.page++ + if(data.list.length < this.where.limit){ + this.loadMore = false + } }, /** * 获取个人用户信息 @@ -713,68 +698,15 @@ this.communityId = this.dataList[this.k]['community_id']; }, animationfinish(event) { - // 1.这里进行判断,如果是最后一个视频就进入 get() 方法加载视频进入列表 - if (this.k == this.dataList.length - 1 && this.currentNav !== 2) { - this.loadVideo = true; - this.GET() - }else if(this.currentNav == 2){ - this.loadVideo = true - this.getFocusList() - } - }, - //每一组结束时新的请求 - GET() { let that = this - if (!that.loadVideo) return - that.loadVideo = true - if(this.currentNav !== 2 ){ - that.isUser ? - myVideoList(that.userUid, { - page: that.page, - limit: that.limit, - is_star: that.isSatrt, - community_id: that.videoID - }).then(res => { - that.videoData(res.data.list) - that.loadVideo = false - }).catch(err => { - return uni.showToast({ - title: err, - icon: 'none', - duration: 2000 - }); - }) : - videoList({ - page: that.page, - limit: that.limit, - id: that.videoID - }).then(res => { - that.loadVideo = false - that.videoData(res.data.list) - }).catch(err => { - return uni.showToast({ - title: err, - icon: 'none', - duration: 2000 - }); - }) - }else if(this.currentNav == 2 ){ - that.isUser ? - myVideoList(that.userUid, { - page: that.page, - limit: that.limit, - is_star: that.isSatrt, - community_id: that.videoID - }).then(res => { - that.videoData(res.data.list) - that.loadVideo = false - }).catch(err => { - return uni.showToast({ - title: err, - icon: 'none', - duration: 2000 - }); - }) : this.getFocusList() + if (!that.loadVideo || !that.loadMore) return + if (this.k == this.dataList.length - 1 && this.currentNav === 1) { + that.loadVideo = false + this.get() + } + if (this.k == this.dataList.length - 1 && this.currentNav === 2) { + that.loadVideo = false + this.getFocusList() } }, get() { @@ -787,8 +719,10 @@ is_star: that.isSatrt, community_id: that.videoID }).then(res => { - console.log(res); that.videoData(res.data.list) + if (res.data.list.length < that.limit) { + this.loadMore = false; + } }).catch(err => { return uni.showToast({ title: err, @@ -802,6 +736,9 @@ id: that.videoID }).then(res => { that.videoData(res.data.list) + if (res.data.list.length < that.limit) { + this.loadMore = false; + } }).catch(err => { return uni.showToast({ title: err, @@ -809,26 +746,20 @@ duration: 2000 }); }) + that.loadVideo = true }, getFocusList() { let that = this; - if (!that.loadVideo) return - that.loadVideo = true focusArticleLst({ page: that.page, limit: that.limit, type: 2 }).then(res => { - console.log(res); - that.loadVideo = false - // const arr=[] - // res.data.list.forEach(item=>{ - // if(item.is_type == '2'){ - // return arr.push(item) - // } - // }) - // this.limit=arr.length + that.loadVideo = true that.videoData(res.data.list) + if (res.data.list.length < that.limit) { + this.loadMore = false; + } }).catch(err => { return uni.showToast({ title: err,