抖音小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.5 KiB

<template>
<view class="myCollection">
<view class="myCollection-list">
<view class="imgList1">
<image v-for="(item,index) in imgList" :key='index' class="img-box"
:style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" @click="targetDetail(item)"
mode=""></image>
</view>
</view>
</view>
</template>
<script>
import {
listTiktokCollection
} from '@/api/userInfo.js'
export default {
data() {
return {
userInfo: {}, // 用户信息
imgList: [], // 图片列表
imgWidth: 0, // 图片宽
imgHeight: 0, // 图片高
pageNum: 1,
pageSize: 10,
}
},
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()
}
})
},
// 下拉刷新
onPullDownRefresh() {
this.getImgList()
uni.stopPullDownRefresh()
},
methods: {
// 收藏图片列表
async getImgList() {
const res = await listTiktokCollection({
userId: this.userInfo.id
})
if (res.data.code === 200) {
console.log('图片结果为:',res)
for (let i = 0; i < res.data.data.length; i++) {
this.imgList = res.data.data
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
},
// 前往详情页 //TODO bug待修复
targetDetail(item) {
console.log('跳转', item)
if (item.id) {
uni.setStorage({
key: 'detailId',
data: item.id,
success() {
console.log(111111)
uni.navigateTo({
url: '../../creator/imgDetail'
})
}
})
}
},
},
// onUnload() {
// uni.switchTab({
// url: '/pages/index/index'
// })
// },
}
</script>
<style lang="less">
.myCollection {
padding-right: 40rpx;
padding-top: 40rpx;
.uni-searchbar {
border: 1px solid #11A8FD;
border-radius: 16rpx;
padding: 0;
margin-left: 40rpx;
.uni-searchbar__box {
padding: 0;
border-radius: 16rpx !important;
}
}
.myCollection-list {
display: flex;
.first-box {
border-radius: 16rpx;
font-size: 16px;
margin-top: 40rpx;
margin-left: 40rpx;
color: #fff;
line-height: 60rpx;
text-align: center;
height: 60rpx;
background-color: #11A8FD;
display: inline-block;
vertical-align: top;
}
image {
margin-top: 40rpx;
margin-left: 40rpx;
border-radius: 16rpx;
}
}
}
</style>