Files
dvcp_v2_wechat_app/src/mods/AppContent/AppContent.vue
aixianling f914566c02 BUG 27603
2022-02-23 14:11:52 +08:00

228 lines
5.6 KiB
Vue

<template>
<div class="wrapper" :style="{ paddingTop: categorys.length ? '54px' : '10px' }" v-if="pageShow">
<div class="tabs">
<u-tabs
:list="categorys && categorys.map(e=>({name:e.categoryName}))"
font-size="36"
bg-color="transparent"
:bold="false"
inactive-color="#ccddff"
:is-scroll="true"
:gutter="16"
active-color="#fff"
:current="index"
@change="tabChange">
</u-tabs>
</div>
<div class="list-wrap" v-if="categoryList && categoryList.length">
<div class="list-card" hover-class="bg-hover" v-for="(category,index) in categoryList" :key="index"
@click="$linkTo('./contentDetail?id='+category.id)">
<div class="header">{{ category.title }}</div>
<div class="content-wrap" v-if="category.contentType==0 && category.files && category.files.length == 1">
<img class="img" :src="item.url" v-for="(item,index) in category.files" :key="index.id" alt="">
</div>
<div class="content-wrap" v-if="category.contentType==0 && category.files && category.files.length > 1">
<img class="min-img" :src="item.url" v-for="(item,index) in category.files && category.files.slice(0,3)"
:key="index.id" alt="">
</div>
<div class="content-wrap" v-if="category.contentType==1">
<img class="img" :src="category.pictureUrl" alt="">
<img class="play-icon" src="../../static/img/play.png" alt="">
</div>
<div class="bottom">
<div class="left">
<div class="tag">{{ category.categoryName || names }}</div>
{{ category.createTime }}
</div>
<div class="right">
<em>{{ category.viewCount }}</em>
人看过
</div>
</div>
</div>
</div>
<AiEmpty v-else></AiEmpty>
</div>
</template>
<script>
import {mapState} from "vuex";
export default {
name: "AppContent",
appName: "内容管理",
data() {
return {
index: 0,
names: "",
categorys: [],
categoryList: [],
pageShow: false,
search: {}
}
},
onLoad(option) {
this.$loading()
this.names = option.names;
this.search.areaId = option.areaId || this.user.areaId
this.getName();
if (option.names) {
uni.setNavigationBarTitle({
title: option.names
})
}
},
computed: {
...mapState(['user']),
active() {
return {
fontSize: "22px",
color: "#fff",
};
},
},
methods: {
getName() {
this.$instance.post("/app/appcontentmoduleinfo/listByName", null, {
params: {names: this.names}
}).then(res => {
if (res?.data) {
this.categorys = res.data[0]["categoryList"];
this.search.moduleId = res.data?.[0]?.id;
this.search.categoryId = res.data?.[0]?.categoryList?.[0]?.id;
this.getCategoryList();
} else {
this.$hideLoading()
}
})
},
tabChange(e) {
this.index = e
this.search.categoryId = this.categorys?.[e]?.id
this.getCategoryList();
},
getCategoryList() {
this.$instance.post("/app/appcontentinfo/list", null, {
params: {
...this.search,
size: 10
}
}).then(res => {
if (res?.data) {
this.categoryList = this.current > 1 ? [...this.categoryList, ...res.data.records] : res.data.records;
}
this.pageShow = true
this.$hideLoading()
})
},
},
onReachBottom() {
this.current++;
this.getCategoryList();
}
}
</script>
<style lang="scss" scoped>
.wrapper {
padding-top: 100px;
.list-wrap {
box-sizing: border-box;
padding: 32px;
.list-card {
width: 100%;
min-height: 100px;
background: #FFFFFF;
box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.02);
border-radius: 16px;
box-sizing: border-box;
padding: 32px;
margin-bottom: 24px;
.header {
font-size: 36px;
font-weight: 600;
color: #333333;
line-height: 50px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.content-wrap {
display: flex;
gap: 4px;
flex-wrap: wrap;
margin-top: 24px;
position: relative;
.img {
width: 100%;
height: 350px;
}
.min-img {
width: 204px;
height: 204px;
}
.play-icon {
width: 80px;
height: 80px;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
.bottom {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 24px;
.left {
display: flex;
align-items: center;
font-size: 28px;
font-weight: 400;
color: #999999;
.tag {
width: 144px;
height: 48px;
background: #EEEEEE;
border-radius: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
font-weight: 400;
color: #999999;
margin-right: 16px;
}
}
.right {
font-size: 28px;
font-weight: 400;
color: #999999;
display: flex;
align-items: center;
em {
font-style: normal;
color: #4181FF;
}
}
}
}
}
}
</style>