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
//POST 传参需要用 data
//获取用户收藏列表
//获取用户收藏分頁
export function listTiktokCollection(data) {
return request({
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)"
mode=""></image>
</view>
<view class="ad-view">
<!-- <view class="ad-view">
<ad adpid="__UNI__069D14D" type="banner" @load="onload" @close="onclose" @error="onerror"></ad>
</view>
</view> -->
</view>
</view>
</template>
@ -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);
// }
}
</script>

Loading…
Cancel
Save