作者 xuqiang

提交

<template>
<view class="waterfalls-box" :style="{ height: height + 'px' }">
<!-- #ifdef MP-WEIXIN -->
<view
v-for="(item, index) of list"
class="waterfalls-list"
:key="item[idKey]"
:id="'waterfalls-list-id-' + item[idKey]"
:ref="'waterfalls-list-id-' + item[idKey]"
:style="{
'--offset': offset + 'px',
'--cols': cols,
top: allPositionArr[index].top || 0,
left: allPositionArr[index].left || 0,
}"
@click="$emit('wapper-lick', item)"
>
<image
class="waterfalls-list-image"
mode="widthFix"
:class="{ single }"
:style="imageStyle"
:src="item[imageSrcKey] || ' '"
@load="imageLoadHandle(index)"
@error="imageLoadHandle(index)"
@click="$emit('image-click', item)"
/>
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view
v-for="(item, index) of list"
class="waterfalls-list"
:key="item[idKey]"
:id="'waterfalls-list-id-' + item[idKey]"
:ref="'waterfalls-list-id-' + item[idKey]"
:style="{
'--offset': offset + 'px',
'--cols': cols,
...listStyle,
...(allPositionArr[index] || {}),
}"
@click="$emit('wapper-lick', item)"
>
<image
class="waterfalls-list-image"
:class="{ single }"
mode="widthFix"
:style="imageStyle"
:src="item.image || ' '"
@load="imageLoadHandle(index)"
@error="imageLoadHandle(index)"
@click="$emit('image-click', item)"
/>
<view class="userInfo" @click="$emit('user-lick', item)" :style="{height: listType != 'mainAct' ? '90rpx' : '60rpx'}">
<view class="userDesc">
{{item.title}}
</view>
<view class="userIconLike" v-if="listType != 'mainAct'">
<view class="userIcon">
<image :src="item.user.avatar" mode=""></image>
{{item.user.nickname}}
</view>
<view class="likeNum">
<image src="../../static/image/dianzan2.png" mode=""></image>
{{item.like_num}}
</view>
</view>
</view>
<view class="statusTxt" v-if="listType == 'findPlay' && item.switch == '1'">
精选
</view>
<view class="statusTxt" v-if="listType == 'mainAct'">
{{item.state_text}}
</view>
<!-- "check_status": 审核状态:0=审核中,1=已通过,2=未通过 -->
<view class="statusTxt" v-if="listType == 'myStory' && item.check_status != '1'">
{{item.check_status == '0' ? '审核中' : '未通过'}}
</view>
</view>
<!-- #endif -->
</view>
</template>
<script>
export default {
props: {
showStatus:{type: Boolean,default:false},
list: { type: Array, required: true },
listType:{ type: String},
// offset 间距,单位为 px
offset: { type: Number, default: 10 },
// 列表渲染的 key 的键名,值必须唯一,默认为 id
idKey: { type: String, default: "id" },
// 图片 src 的键名
imageSrcKey: { type: String, default: "image_url" },
// 列数
cols: { type: Number, default: 2, validator: (num) => num >= 2 },
imageStyle: { type: Object },
// 是否是单独的渲染图片的样子,只控制图片圆角而已
single: { type: Boolean, default: false },
// #ifndef MP-WEIXIN
listStyle: { type: Object },
// #endif
},
data() {
return {
topArr: [], // left, right 多个时依次表示第几列的数据
allPositionArr: [], // 保存所有的位置信息
allHeightArr: [], // 保存所有的 height 信息
height: 0, // 外层包裹高度
oldNum: 0,
num: 0,
};
},
created() {
this.refresh();
},
methods: {
imageLoadHandle(index) {
const id = "waterfalls-list-id-" + this.list[index][this.idKey],
query = uni.createSelectorQuery().in(this);
query
.select("#" + id)
.fields({ size: true }, (data) => {
this.num++;
this.$set(this.allHeightArr, index, data.height);
if(this.num === 1){
uni.showLoading({
title:'加载中...'
})
}
if (this.num === this.list.length) {
for (let i = this.oldNum; i < this.num; i++) {
const getTopArrMsg = () => {
let arrtmp = [...this.topArr].sort((a, b) => a - b);
return {
shorterIndex: this.topArr.indexOf(arrtmp[0]),
shorterValue: arrtmp[0],
longerIndex: this.topArr.indexOf(arrtmp[this.cols - 1]),
longerValue: arrtmp[this.cols - 1],
};
};
const { shorterIndex, shorterValue } = getTopArrMsg();
const position = {
top: shorterValue + "px",
left: (data.width + this.offset) * shorterIndex + "px",
};
this.$set(this.allPositionArr, i, position);
this.topArr[shorterIndex] =
shorterValue + this.allHeightArr[i] + this.offset;
this.height = getTopArrMsg().longerValue - this.offset;
}
this.oldNum = this.num;
uni.hideLoading()
// 完成渲染 emit `image-load` 事件
this.$emit("image-load");
}
})
.exec();
},
refresh() {
let arr = [];
for (let i = 0; i < this.cols; i++) {
arr.push(0);
}
this.topArr = arr;
this.num = 0;
this.oldNum = 0;
this.height = 0;
},
},
};
</script>
<style lang="scss" scoped>
// 这里可以自行配置
$border-radius: 10px;
.waterfalls-box {
position: relative;
width: 100%;
overflow: hidden;
.waterfalls-list {
position: relative;
width: calc((100% - var(--offset) * (var(--cols) - 1)) / var(--cols));
position: absolute;
background-color: #fff;
border-radius: $border-radius;
// 防止刚开始渲染时堆叠在第一幅图的地方
left: calc(-50% - var(--offset));
.waterfalls-list-image {
width: 100%;
will-change: transform;
border-radius: $border-radius;
display: block;
&.single {
border-radius: $border-radius;
}
}
.userInfo{
background: linear-gradient(135deg,rgba(0,0,0,0.00), rgba(0,0,0,0.60));
border-radius: 0 0 $border-radius $border-radius;
position:absolute;
bottom: 0;
width: 100%;
.userDesc{
font-size: 26rpx;
color: #fff;
padding: 0 24rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp:1;
-webkit-box-orient:vertical;
height: 45rpx;
line-height: 45rpx;
}
.userIconLike{
display: flex;
justify-content: space-between;
font-size: 20rpx;
color: rgba(255,255,255,0.80);
padding: 0 24rpx;
.userIcon{
display: flex;
align-items: center;
image{width: 38rpx;height: 38rpx;margin-right: 10rpx;border-radius: 100%;}
}
.likeNum{
display: flex;
align-items: center;
image{width: 28rpx;height: 28rpx;margin-right: 5rpx;}
}
}
}
.statusTxt{
width: 100rpx;
height: 48rpx;
background: rgba(0,53,46,0.50);
text-align: center;
line-height: 48rpx;
font-size: 20rpx;
color:#fff;
position:absolute;
top: 0;
right: 0;
border-radius: 0 $border-radius 0 0;
}
}
}
</style>
... ... @@ -7,6 +7,9 @@
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"compatible" : {
"ignoreVersion" : true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持
},
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
... ...
... ... @@ -28,7 +28,7 @@
<swiper class="imgSwiper" @change="changeImg" :indicator-dots="articleInfo.images.length > 1 ? true : false" :indicator-active-color="'#35655f'" :indicator-color="'rgba(0,0,0,0.3)'" :circular="true" :duration="300">
<swiper-item v-for="(item,index) in articleInfo.images" :key="index" @click="closeAllAlert">
<view class="swiper-item" :style="{'align-items':swiperHeight >= 480 ? 'flex-start' : 'center'}">
<image :src="item" mode="widthFix" :mode="swiperHeight < 500 || swiperHeight > 501 ? 'widthFix' : 'aspectFill'" :class="{tempH:swiperHeight >= 500 && swiperHeight <= 501}"></image>
<image :src="item" :mode="swiperHeight < 480 || swiperHeight > 481 ? 'widthFix' : 'aspectFill'" :class="{tempH:swiperHeight >= 480 && swiperHeight <= 481}"></image>
</view>
</swiper-item>
</swiper>
... ... @@ -262,6 +262,7 @@
uni.getSystemInfo({
success: function (res) {
that.swiperHeight = res.windowWidth/image.width * image.height;
console.log('轮播高度',that.swiperHeight)
}
});
}
... ...
... ... @@ -188,7 +188,55 @@
<view class="otherContent" :style="{
height:userInfo.group_id == '2' ? 'calc(100vh - 450rpx - 24rpx - '+statusBarHeight+'rpx - 88rpx - 88rpx)' : 'calc(100vh - 338rpx - 24rpx - 88rpx - 88rpx - '+statusBarHeight+'rpx)'
}">
<waterfallsFlow v-if="showList" :list="list" @wapper-lick="wapperLick"></waterfallsFlow>
<u-waterfall v-model="list" ref="uWaterfall" v-if="showList">
<template v-slot:left="{ leftList }">
<view class="demo-warter" v-for="(item, index) in leftList" :key="index">
<!-- 微信小程序需要hx2.8.11版本才支持在template中引入其他组件,比如下方的u-lazy-load组件 -->
<u-lazy-load @click="wapperLick(item)" threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
<view class="userInfo" :style="{height:'90rpx'}">
<view class="userDesc">
{{item.title}}
</view>
<view class="userIconLike">
<view class="userIcon">
<image :src="item.user.avatar" mode=""></image>
{{item.user.nickname}}
</view>
<view class="likeNum">
<image src="../../static/image/dianzan2.png" mode=""></image>
{{item.like_num}}
</view>
</view>
</view>
<view class="statusTxt" v-if="item.switch == '1'">
精选
</view>
</view>
</template>
<template v-slot:right="{ rightList }">
<view class="demo-warter" v-for="(item, index) in rightList" :key="index">
<u-lazy-load @click="wapperLick(item)" threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
<view class="userInfo" :style="{height: '90rpx'}">
<view class="userDesc">
{{item.title}}
</view>
<view class="userIconLike">
<view class="userIcon">
<image :src="item.user.avatar" mode=""></image>
{{item.user.nickname}}
</view>
<view class="likeNum">
<image src="../../static/image/dianzan2.png" mode=""></image>
{{item.like_num}}
</view>
</view>
</view>
<view class="statusTxt" v-if="item.switch == '1'">
精选
</view>
</view>
</template>
</u-waterfall>
</view>
</scroll-view>
</view>
... ... @@ -277,7 +325,6 @@
<script>
import {mapState} from "vuex"
import share from '@/components/share.vue'
import waterfallsFlow from "@/components/maramlee-waterfalls-flow/maramlee-waterfalls-flow.vue";
import sendGift from '@/components/sendGift.vue'
import payType from '@/components/payType.vue'
export default{
... ... @@ -326,7 +373,6 @@
}
},
components:{
waterfallsFlow,
sendGift,
payType,
share
... ... @@ -341,6 +387,12 @@
},
onLoad(e) {
this.param.user_id = e.id
if(e.id != undefined){
this.current_page = 1
this.last_page = 0
this.param.page = 1
this.list = []
}
uni.getLocation({
type: 'gcj02',
success: (res) => {
... ... @@ -580,6 +632,7 @@
</script>
<style lang="scss" scoped>
$border-radius: 10px;
/* 导航栏区域 */
.navBarWrap{height: 88rpx;padding: 0 32rpx;display: flex;align-items: center;justify-content: space-between;}
.navBarWrap image{width: 44rpx;height: 44rpx;}
... ... @@ -658,5 +711,67 @@
image{width: 48rpx;height: 48rpx;}
}
}
/* 其他信息区域 */
.otherInfoWrap{height: calc(100vh - 88rpx - 473rpx);border-radius: 60rpx 60rpx 0 0;background: #fff;}
.otherInfoWrap .otherTabList{height: 88rpx;padding: 0 69rpx;display: flex;position: relative;}
.otherTabList .otherTabItem{flex: 1;text-align: center;line-height: 88rpx;color: #969799;font-size: 28rpx;font-weight: 600;}
.otherTabItem.active{color: #35655f;}
.otherTabList .otherTabLine{position: absolute;width: 48rpx;height: 5rpx;background: #35655f;bottom: 18rpx;transition: 0.5s;}
.otherContent{height: calc(100vh - 88rpx - 473rpx - 88rpx);padding: 0 20rpx;
.demo-warter{
border-radius: 8px;
margin: 5px;
background-color: #ffffff;
position: relative;
.userInfo{
background: linear-gradient(135deg,rgba(0,0,0,0.00), rgba(0,0,0,0.60));
border-radius: 0 0 $border-radius $border-radius;
position:absolute;
bottom: 0;
width: 100%;
.userDesc{
font-size: 26rpx;
color: #fff;
padding: 0 24rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp:1;
-webkit-box-orient:vertical;
height: 45rpx;
line-height: 45rpx;
}
.userIconLike{
display: flex;
justify-content: space-between;
font-size: 20rpx;
color: rgba(255,255,255,0.80);
padding: 0 24rpx;
.userIcon{
display: flex;
align-items: center;
image{width: 38rpx;height: 38rpx;margin-right: 10rpx;border-radius: 100%;}
}
.likeNum{
display: flex;
align-items: center;
image{width: 28rpx;height: 28rpx;margin-right: 5rpx;}
}
}
}
.statusTxt{
width: 100rpx;
height: 48rpx;
background: rgba(0,53,46,0.50);
text-align: center;
line-height: 48rpx;
font-size: 20rpx;
color:#fff;
position:absolute;
top: 0;
right: 0;
border-radius: 0 $border-radius 0 0;
}
}
}
</style>
... ...
... ... @@ -270,7 +270,6 @@
<script>
import {mapState} from "vuex"
import waterfallsFlow from "@/components/maramlee-waterfalls-flow/maramlee-waterfalls-flow.vue"
import iCircle from '@/components/xiaoran-circle/xiaoran-circle.vue'
import share from '@/components/share.vue'
export default{
... ... @@ -305,7 +304,6 @@
}
},
components:{
waterfallsFlow,
iCircle,
share
},
... ...