创作者微信小程序端
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.
 
 
 
 

269 lines
6.8 KiB

<template>
<view class="choiceness">
<uni-segmented-control :current="statusCurrent" :values="statusList" :style-type="styleType"
:active-color="activeColor" @clickItem="onClickStatus" />
<uni-segmented-control :current="typeCurrent" :values="typeList" :style-type="styleType"
:active-color="activeColor" @clickItem="onClickType" />
<view class="choiceness-list">
<image v-for="(item,index) in creatorImgList" :key='index' class="img-box"
:style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" @click="targetDetail(item)"
mode=""></image>
<view class="ivOver" v-if="flag">-----已经到底啦-----</view>
</view>
</view>
</template>
<script>
import {
listType,listTiktokImgIn
} from '@/api/index.js'
export default {
data() {
return {
statusCurrent: 0,
activeColor: '#007aff',
styleType: 'text',
statusList: ['待审核','审核拒绝','已上架','已下架'],
typeList:[],
typeIdList:[],
typeCurrent: 0,
typeId: 1,
status: 0,
pageNum: 1,
pageSize: 10,
creatorImgList: [],
userInfo: {},
imgWidth: 0, // 图片宽
imgHeight: 0, // 图片高
flag: false
}
},
onLoad() {
this.listTiktokImgIn();
},
created(){
const userInfoSync = uni.getStorageSync("userInfo");
this.userInfo = userInfoSync;
this.queryListType();
uni.getSystemInfo({
success: res => {
console.log(res)
this.imgWidth = res.windowWidth - 130 + 'rpx'
this.imgHeight = res.windowWidth - 130 + 'rpx'
}
})
},
// 下拉刷新
onPullDownRefresh(){
this.pageNum = 1
this.creatorImgList = []
this.listTiktokImgIn();
this.flag = false;
uni.stopPullDownRefresh();
},
// 上划加载更多
onReachBottom() {
console.log(2222)
if (this.creatorImgList.length > this.pageSize*this.pageNum-1) {
this.flag = false;
this.pageNum += 1
this.listTiktokImgIn()
}else{
this.flag = true;
}
},
methods: {
// 前往详情页
targetDetail(item) {
console.log('跳转', item)
if (item.id) {
uni.setStorage({
key: 'detailId',
data: item.id,
success() {
console.log(111111)
uni.navigateTo({
url: '../material/imgDetail'
})
}
})
}
},
onClickStatus(e1){
let that = this;
that.flag = false;
that.creatorImgList = [];
that.status = e1.currentIndex;
console.log('status',that.status)
uni.showLoading({
title: "加载中",
mask: true,
success() {
// 查询指定艺术家图片集合
const param = {
creatorId: that.userInfo.id,
typeId: that.typeId,
pageSize: that.pageSize,
pageNum: 1,
status: that.status
};
listTiktokImgIn(param).then(res => {
console.log('that.typeId',that.typeId);
console.log('that.status',that.status);
if(res.data.code === 200){
that.creatorImgList.push(...res.data.rows)
console.log('调用成功1!', that.creatorImgList);
}else {
uni.showModal({
content: "艺术家图片列表数据加载失败!",
showCancel: false,
});
}
});
},
complete() {
uni.hideLoading();
},
});
},
onClickType(e2){
let that = this;
that.flag = false;
that.creatorImgList = [];
that.typeId = that.typeIdList[e2.currentIndex];
console.log('typeId',that.typeId)
uni.showLoading({
title: "加载中",
mask: true,
success() {
// 查询指定艺术家图片集合
const param = {
creatorId: that.userInfo.id,
typeId: that.typeId,
pageSize: that.pageSize,
pageNum: 1,
status: that.status
};
listTiktokImgIn(param).then(res => {
console.log('that.typeId',that.typeId);
console.log('that.status',that.status);
if(res.data.code === 200){
that.creatorImgList.push(...res.data.rows)
console.log('调用成功2!', that.creatorImgList);
}else {
uni.showModal({
content: "艺术家图片列表数据加载失败!",
showCancel: false,
});
}
});
},
complete() {
uni.hideLoading();
uni.getSystemInfo({
success: res => {
console.log(res)
if(that.typeId === 1){
that.imgWidth = res.windowWidth - 130 + 'rpx'
that.imgHeight = res.windowWidth - 130 + 'rpx'
}else if(that.typeId === 2){
that.imgWidth = res.windowWidth - 130 + 'rpx'
that.imgHeight = res.windowWidth + 20 + 'rpx'
}else if(that.typeId === 3){
that.imgWidth = res.windowWidth - 130 + 'rpx'
that.imgHeight = res.windowWidth + 20 + 'rpx'
}else if(that.typeId === 4){
that.imgWidth = res.windowWidth - 60 + 'rpx'
that.imgHeight = res.windowWidth - 130 + 'rpx'
}else if(that.typeId === 5){
that.imgWidth = res.windowWidth - 130 + 'rpx'
that.imgHeight = res.windowWidth - 130 + 'rpx'
}else if(that.typeId === 6){
that.imgWidth = res.windowWidth - 130 + 'rpx'
that.imgHeight = res.windowWidth - 130 + 'rpx'
}
}
})
},
});
},
// 获取图片分类列表
async queryListType() {
const res = await listType();
if (res.data.code === 200) {
for (let s of res.data.data) {
this.typeList.push(s.typeName);
this.typeIdList.push(s.id);
}
//console.log('typeList', this.typeList)
console.log('typeIdList', this.typeIdList)
} else {
uni.showModal({
content: "图片分类列表加载失败!",
showCancel: false,
});
}
},
//查询指定艺术家图片集合
async listTiktokImgIn() {
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo) {
console.log('havent userInfo')
} else {
console.log('have userInfo')
}
const res = await listTiktokImgIn({
pageNum: this.pageNum,
pageSize: this.pageSize,
typeId: this.typeId,
status: this.status,
creatorId: userInfo.id
})
if (res.data.code === 200) {
this.creatorImgList.push(...res.data.rows)
console.log('creatorImgList',this.creatorImgList);
} else {
uni.showModal({
content: '艺术家图片列表加载失败!',
showCancel: false
});
}
}
}
}
</script>
<style lang="less">
.choiceness {
padding-top: 20rpx;
.choiceness-list {
display: flex;
flex-wrap: wrap;
justify-content: flex-first;
flex-direction: row;
image {
margin-top: 10rpx;
margin-left: 10rpx;
margin-right: 5rpx;
border-radius: 10rpx;
}
}
}
.ivOver{
width: 100%;
height:50px;
line-height: 50px;
text-align: center;
background: #fff;
font-size: 20rpx;
}
</style>