Files
dvcp_v2_wechat_app/src/project/pingchang/AppNewFarmerBank/handpick.vue
2023-05-15 15:08:01 +08:00

199 lines
5.1 KiB
Vue

<template>
<div class="handpick">
<div class="list" v-for="(item,index) in list" :key="index" @click="$linkTo(`./pickDetail?id=${item.id}`)">
<div class="title-info" v-if="item.girdName">
{{item.girdName}}
</div>
<div class="top">
<div class="left" >
<div class="type-info">{{item.createUserName}}<span>{{item.title}}</span></div>
</div>
<div class="right" @click.stop="upCount(item.id, index)">
<img :src="item.upStatus == 0 ? 'https://cdn.cunwuyun.cn/wxmp/fengdu/zan.png' : 'https://cdn.cunwuyun.cn/wxmp/fengdu/zan-active.png'" alt="">
<span>{{ item.upCount || 0 }}</span><span v-if="item.upCount > 99">+</span>
</div>
</div>
<p class="content-info">{{item.content}}</p>
<div class="imgs" v-if="item.images.length">
<image v-for="(img, i) in item.images" :key="i" class="banner" :src="img.url"/>
</div>
<div class="imgs" v-if="!item.images.length && item.videos.length">
<image v-for="(video, i) in item.videos" :key="i" class="banner" :src="video.facePicture.toString()"/>
</div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: "handpick",
appName: "精选动态",
computed: {
...mapState(['user'])
},
data() {
return {
list: [],
flag: false,
current: 1,
moduleId: ''
}
},
methods: {
getModule() {
this.$instance.post(`/app/appintegraluserapply/queryModuleByName`).then(res => {
if (res?.data) {
this.moduleId = res.data
this.getList()
}
})
},
getList() {
this.$instance.post(`/app/appcontentinfo/list-web`, null, {
params: {
moduleId: this.moduleId,
current: this.current,
girdId: this.user.girdId,
containContent: true,
}
}).then(res => {
if (res?.data) {
this.allList = res.data.records
let newList = this.current==1? res.data.records : [...this.list, ...res.data.records]
let mapList = newList.map(e => {
return {
...e,
images: e?.files.filter(i => (i.postfix == '.jpg' || i.postfix == '.jpeg' || i.postfix == '.png')),
videos: e?.files.filter(i => (i.postfix == '.mp4' || i.postfix == '.MP4')),
}
})
this.list = mapList.map(v => {
return {
...v,
images: v.images.length > 3 ? v.images.slice(0, 3) : v.images,
videos: v.videos.length > 3 ? v.videos.slice(0, 3) : v.videos,
upStatus: 0
}
})
}
})
},
// 点赞
upCount(id,index) {
if (this.flag) return
this.flag = true
this.$instance.post(`/app/appcontentinfo/supportById?id=${id}`).then(res => {
if (res?.code == 0) {
this.flag = false
this.list[index].upStatus = 1
this.$u.toast(`点赞成功`)
}
}).finally(() => this.flag = false)
},
},
onShow() {
this.getModule()
},
onReachBottom() {
this.current++
this.getList()
},
}
</script>
<style lang="scss" scoped>
.handpick {
padding: 24px 32px;
box-sizing: border-box;
.list {
padding: 32px 24px;
box-sizing: border-box;
background: #FFF;
border-radius: 12px;
margin-bottom: 24px;
.title-info {
font-family: PingFangSC-SNaNpxibold;
font-weight: 600;
font-size: 34px;
color: #333;
letter-spacing: 0;
line-height: 40px;
margin-bottom: 16px;
}
.type-info {
font-family: PingFangSC-Regular;
font-size: 34px;
color: #687DA6;
line-height: 40px;
span {
display: inline-block;
font-family: PingFangSC-Regular;
font-size: 26px;
color: #666;
line-height: 40px;
margin-left: 20px;
}
}
.top {
display: flex;
justify-content: space-between;
margin-bottom: 28px;
.left {
width: calc(100% - 100px);
p {
overflow:hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
}
.right {
width: 100px;
text-align: right;
img {
width: 40px;
height: 40px;
vertical-align: bottom;
}
span {
font-size: 28px;
font-weight: 400;
color: #687DA6;
}
}
}
.content-info {
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
font-family: PingFangSC-Regular;
font-size: 28px;
color: #333;
line-height: 42px;
margin-bottom: 24px;
}
.imgs {
display: flex;
flex-wrap: wrap;
background: #FFF;
image,
video {
width: 200px;
height: 200px;
margin: 0 12px 0 0;
}
image:nth-child(3n + 0),
video:nth-child(3n + 0) {
margin: 0;
}
}
}
}
</style>