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); + // } }