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.
 
 
 
 
 

156 lines
3.6 KiB

<template>
<view class="">
<view class="box">
<view class="left" ref="left">
<view class="item" v-for="(item,i) in leftList" :key="i" @click="goDetail(item)">
<image class="image" :src="item.headimg" mode="widthFix"></image>
<view class="content">
<view class="title">{{item.title}}</view>
<view class="flex-between">
<view class="text-overflow" style="display: flex;align-items: center;width: 200rpx;">
<image :src="showImg(item.author_img)" mode="" class="author-img"></image>
{{item.author}}
</view>
<view style="display: flex;">
<image src="https://static.ticket.sz-trip.com/yandu/images/index/eye.png" mode="" class="eye-img"></image>
{{item.view}}
</view>
</view>
</view>
</view>
</view>
<view class="right" ref="right">
<view class="item" v-for="(item,i) in rightList" :key="i" @click="goDetail(item)">
<image class="image" :src="item.headimg" mode="widthFix"></image>
<view class="content">
<view class="title">{{item.title}}</view>
<view class="flex-between">
<view class="text-overflow" style="display: flex;align-items: center;width: 200rpx;">
<image :src="showImg(item.author_img)" mode="" class="author-img"></image>
{{item.author}}
</view>
<view style="display: flex;">
<image src="https://static.ticket.sz-trip.com/yandu/images/index/eye.png" mode="" class="eye-img"></image>
{{item.view}}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: ['waterList'],
data() {
return {
leftList: [], //左边列图片
rightList: [], //右边列图片
leftHeight: 0, //左边列高度
rightHeight: 0, //右边列高度
}
},
mounted() {
},
watch:{
waterList: {
handler(newVal, oldVal) {
console.log(newVal, oldVal)
this.waterList = newVal
if(newVal.length > 0) {
this.setWaterFallLayout()
}
},
immediate: true
}
},
methods: {
//通过uni.getImageInfo,小程序支持
async setWaterFallLayout() {
for (let item of this.waterList) {
try {
let h = await this.getImgHeight(item.headimg)
if (this.leftHeight <= this.rightHeight) {
this.leftList.push(item)
this.leftHeight += h
} else {
this.rightList.push(item)
this.rightHeight += h
}
} catch (e) {}
}
},
getImgHeight(url) {
return new Promise((resolve, reject) => {
uni.getImageInfo({
src: url,
success: e => {
resolve(e.height)
},
fail: e => {
reject(e)
}
})
})
},
goDetail(item) {
if(item.outside_url) {
uni.navigateTo({
url: '/subPackages/webPage/webPage?url=' + encodeURIComponent(item.outside_url)
});
}else {
uni.navigateTo({
url: '/subPackages/strategyDetail?id=' + item.id
})
}
}
}
}
</script>
<style scoped lang="scss">
.box {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.left, .right {
width: 340rpx;
.item {
width: 340rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 11rpx 0rpx rgba(17,17,17,0.26);
border-radius: 27rpx;
overflow: hidden;
margin-bottom: 13.33rpx;
.image {
width: 340rpx;
}
.content {
background: #FFFFFF;
padding: 20rpx;
.title {
font-weight: 500;
font-size: 28rpx;
color: #000000;
line-height: 40rpx;
}
.flex-between {
font-weight: 500;
font-size: 24rpx;
color: #888888;
}
}
}
}
}
</style>