From dfef599cd1f6ad2b41348cc3e5f7fca71ac1b1cd Mon Sep 17 00:00:00 2001 From: chengkun <2500338766@qq.com> Date: Tue, 5 Jul 2022 11:13:31 +0800 Subject: [PATCH] =?UTF-8?q?feature-img-1.0:=E6=88=91=E7=9A=84=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/userInfo.js | 2 +- pages/userInfo/myCollection/myCollection.vue | 51 +++++++++++++------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/api/userInfo.js b/api/userInfo.js index bfcc313..4bfabfa 100644 --- a/api/userInfo.js +++ b/api/userInfo.js @@ -3,7 +3,7 @@ const serviceTitle = '/img' //GET 传参需要用 params //POST 传参需要用 data -//获取用户收藏列表 +//获取用户收藏分頁 export function listTiktokCollection(data) { return request({ url: `${serviceTitle}/img/mini/tiktok/listTiktokCollection`, diff --git a/pages/userInfo/myCollection/myCollection.vue b/pages/userInfo/myCollection/myCollection.vue index 85171a3..786dfd4 100644 --- a/pages/userInfo/myCollection/myCollection.vue +++ b/pages/userInfo/myCollection/myCollection.vue @@ -6,9 +6,9 @@ :style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" @click="targetDetail(item)" mode=""> - + @@ -25,34 +25,51 @@ imgWidth: 0, // 图片宽 imgHeight: 0, // 图片高 pageNum: 1, - pageSize: 10, + pageSize: 4, } }, created() { this.userInfo = uni.getStorageSync('userInfo') uni.getSystemInfo({ success: res => { - console.log(res) this.imgWidth = res.windowWidth - 60 + 'rpx' this.imgHeight = (res.windowWidth - 60) * 2 - 30 + 'rpx' this.getImgList() } }) }, + onLoad() { + this.getImgList(); + }, // 下拉刷新 onPullDownRefresh() { + //TODO 此處待優化 + console.log(1111) + this.pageNum = 1 + this.imgList = [] this.getImgList() uni.stopPullDownRefresh() }, + // 上划加载更多 + onReachBottom() { + console.log(2222) + if (this.imgList.length > 3) { + this.pageNum += 1 + this.getImgList() + } + }, methods: { - // 收藏图片列表 + // 收藏图片分頁 async getImgList() { const res = await listTiktokCollection({ - userId: this.userInfo.id + userId: this.userInfo.id, + pageNum: this.pageNum, + pageSize: this.pageSize }) if (res.data.code === 200) { - for (let i = 0; i < res.data.data.length; i++) { - this.imgList = res.data.data + console.log('res',res) + for (let i = 0; i < res.data.rows.length; i++) { + this.imgList = res.data.rows } } else { uni.showToast({ @@ -78,15 +95,15 @@ } }, }, - onload(e) { - console.log("加载了广告"); - }, - onclose(e) { - console.log("关闭了广告: " + e.detail); - }, - onerror(e) { - console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg); - } + // onload(e) { + // console.log("加载了广告"); + // }, + // onclose(e) { + // console.log("关闭了广告: " + e.detail); + // }, + // onerror(e) { + // console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg); + // } }