抖音小程序端
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.

136 lines
2.6 KiB

<template>
<view>
<view>
<swiper class="swiper-box" :autoplay="autoplay" :interval="interval" :duration="duration" :indicator-dots="indicatorDots">
<swiper-item v-for="(item, index) in banner" :key="index">
<image class="img" @click="linkTo(item)" :src="item.bannerImg"></image>
</swiper-item>
</swiper>
</view>
<view>
<uni-list v-for="(item, index) in userImgList" :key="index">
<!-- 展示用户相关信息 -->
<template>
<image class="head" :src="item.img"></image>
<view class="userName">{{item.username}}</view>
</template>
<!-- 展示用户对应三张图 -->
<template>
<view v-for="(pic,param) in item.imgList" :key="param">
<image class="threeImg" @click="linkTo(item)" :src="pic.imgUrl"></image>
</view>
</template>
</uni-list>
</view>
</view>
</template>
<script>
import {getBannerList,getUserImgList} from '@/api/creator.js'
export default {
data() {
return {
banner: [],
userImgList:[],
autoplay: true,
interval: 2000,
duration: 1000,
indicatorDots: true,
}
},
onLoad() {
this.getBanner();
this.getUserImgList();
},
methods: {
linkTo(item){
console.log(item.bannerImg)
uni.showModal({
content: '跳转啦',
showCancel: false
});
},
getUserDetails(item){
//TODO 点击跳转对应用户详情页面
console.log(item);
},
async getBanner(){
const res = await getBannerList()
if(res.data.code === 200){
this.banner = res.data.data
}else{
uni.showModal({
content: 'banner加载失败!',
showCancel: false
});
}
},
async getUserImgList(){
const res = await getUserImgList()
if(res.data.code === 200){
this.userImgList = res.data.data
console.log('userListImg',this.userImgList)
}else{
uni.showModal({
content: '用户图片列表加载失败!',
showCancel: false
});
}
}
}
}
</script>
<style scoped>
.swiper-box {
height: 100px;
border: 2rpx solid #18BC37;
}
.swiper-item {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
height: 200px;
color: #fff;
}
.img {
position: absolute;
width: 100%;
height: 100%;
}
.head {
flex: 1;
display: flex;
width:80rpx;
height:80rpx;
justify-content: space-between;
align-items: flex-end;
}
.userName {
flex: 1;
display: flex;
margin-left: 100rpx;
justify-content: space-between;
align-items: flex-end;
}
.threeImg {
height:300rpx;
width:200rpx;
}
</style>