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

<template>
<view class="choiceness">
<uni-search-bar class="uni-mt-10" placeholder="请输入喜欢的艺术家代号吧~" clearButton="auto" cancelButton="none"
@confirm="search" />
<view class="choiceness-list">
<view class="imgList1">
<view class="first-box" :style="'width:'+imgWidth">
热门作品
</view>
<image v-for="(item,index) in imgList1" :key='index' class="img-box"
:style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" @click="targetDetail(item)"
mode=""></image>
</view>
<view class="imgList2">
<image v-for="(item,index) in imgList2" :key='index' class="img-box"
:style="'width:'+imgWidth+';height:'+imgHeight" :src="item.imgUrl" mode=""></image>
</view>
</view>
</view>
</template>
<script>
import {
imgLists
} from '@/api/index.js'
export default {
data() {
return {
imgList1: [], //图片列表
imgList2: [], //图片列表
imgWidth: 0, // 图片宽
imgHeight: 0, // 图片高
}
},
created() {
uni.getSystemInfo({
success: res => {
console.log(res)
this.imgWidth = res.windowWidth - 60 + 'rpx'
this.imgHeight = (res.windowWidth - 60) * 2 - 30 + 'rpx'
this.getImgList()
}
})
},
methods: {
// 图片列表分类实现瀑布流
async getImgList() {
const res = await imgLists()
if (res.data.code === 200) {
for (let i = 0; i < res.data.rows.length; i++) {
if (i % 2 == 0) {
this.imgList2.push(res.data.rows[i])
} else {
this.imgList1.push(res.data.rows[i])
}
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'error'
})
}
},
// 前往详情页
targetDetail(item) {
console.log('跳转', item)
if (item.id) {
uni.setStorage({
key: 'detailId',
data: item.id,
success() {
console.log(111111)
uni.redirectTo({
url: '../creator/imgDetail'
})
}
})
}
}
},
// onUnload() {
// uni.switchTab({
// url: '/pages/index/index'
// })
// },
}
</script>
<style lang="less">
.choiceness {
padding-right: 40rpx;
padding-top: 40rpx;
.uni-searchbar {
border: 1px solid #11A8FD;
border-radius: 16rpx;
padding: 0;
.uni-searchbar__box {
padding: 0;
border-radius: 16rpx !important;
}
}
.choiceness-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>