Browse Source

feature-img-1.0:我的收藏优化

feature-1.0
chengkun 4 years ago
parent
commit
dfef599cd1
  1. 2
      api/userInfo.js
  2. 51
      pages/userInfo/myCollection/myCollection.vue

2
api/userInfo.js

@ -3,7 +3,7 @@ const serviceTitle = '/img'
//GET 传参需要用 params //GET 传参需要用 params
//POST 传参需要用 data //POST 传参需要用 data
//获取用户收藏列表 //获取用户收藏分頁
export function listTiktokCollection(data) { export function listTiktokCollection(data) {
return request({ return request({
url: `${serviceTitle}/img/mini/tiktok/listTiktokCollection`, url: `${serviceTitle}/img/mini/tiktok/listTiktokCollection`,

51
pages/userInfo/myCollection/myCollection.vue

@ -6,9 +6,9 @@
:style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" @click="targetDetail(item)" :style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" @click="targetDetail(item)"
mode=""></image> mode=""></image>
</view> </view>
<view class="ad-view"> <!-- <view class="ad-view">
<ad adpid="__UNI__069D14D" type="banner" @load="onload" @close="onclose" @error="onerror"></ad> <ad adpid="__UNI__069D14D" type="banner" @load="onload" @close="onclose" @error="onerror"></ad>
</view> </view> -->
</view> </view>
</view> </view>
</template> </template>
@ -25,34 +25,51 @@
imgWidth: 0, // imgWidth: 0, //
imgHeight: 0, // imgHeight: 0, //
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 4,
} }
}, },
created() { created() {
this.userInfo = uni.getStorageSync('userInfo') this.userInfo = uni.getStorageSync('userInfo')
uni.getSystemInfo({ uni.getSystemInfo({
success: res => { success: res => {
console.log(res)
this.imgWidth = res.windowWidth - 60 + 'rpx' this.imgWidth = res.windowWidth - 60 + 'rpx'
this.imgHeight = (res.windowWidth - 60) * 2 - 30 + 'rpx' this.imgHeight = (res.windowWidth - 60) * 2 - 30 + 'rpx'
this.getImgList() this.getImgList()
} }
}) })
}, },
onLoad() {
this.getImgList();
},
// //
onPullDownRefresh() { onPullDownRefresh() {
//TODO
console.log(1111)
this.pageNum = 1
this.imgList = []
this.getImgList() this.getImgList()
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
}, },
//
onReachBottom() {
console.log(2222)
if (this.imgList.length > 3) {
this.pageNum += 1
this.getImgList()
}
},
methods: { methods: {
// //
async getImgList() { async getImgList() {
const res = await listTiktokCollection({ const res = await listTiktokCollection({
userId: this.userInfo.id userId: this.userInfo.id,
pageNum: this.pageNum,
pageSize: this.pageSize
}) })
if (res.data.code === 200) { if (res.data.code === 200) {
for (let i = 0; i < res.data.data.length; i++) { console.log('res',res)
this.imgList = res.data.data for (let i = 0; i < res.data.rows.length; i++) {
this.imgList = res.data.rows
} }
} else { } else {
uni.showToast({ uni.showToast({
@ -78,15 +95,15 @@
} }
}, },
}, },
onload(e) { // onload(e) {
console.log("加载了广告"); // console.log("广");
}, // },
onclose(e) { // onclose(e) {
console.log("关闭了广告: " + e.detail); // console.log("广: " + e.detail);
}, // },
onerror(e) { // onerror(e) {
console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg); // console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg);
} // }
} }
</script> </script>

Loading…
Cancel
Save