Files
dvcp_v2_wxcp_app/library/apps/AppInfotainment/newsList.vue

412 lines
7.8 KiB
Vue
Raw Normal View History

2022-04-24 17:42:09 +08:00
<template>
<div class="newList">
2022-04-25 16:27:08 +08:00
<div class="header" v-if="tabList.length">
2022-04-24 17:42:09 +08:00
<div class="header-tab">
<img src="https://cdn.cunwuyun.cn/dvcp/live/dh.png" alt="" class="more-icon" @click="toSelect()">
2022-04-29 21:16:30 +08:00
<u-tabs :list="tabList" :current="currIndex" @change="changeTab" :font-size="26"></u-tabs>
2022-05-07 14:23:09 +08:00
<!-- <scroll-view :scroll-x="true" :scroll-with-animation="true" @scroll="scroll" :scroll-left="left" upper-threshold="60">
2022-05-07 10:57:22 +08:00
<div v-for="(item, index) in tabList" :key="index" @click="changeTab(index)" :class="currIndex == index ? 'tab-item active-item' : 'tab-item'">
{{ item.name }}
<span class="active-line" v-if="currIndex == index"></span>
</div>
</scroll-view> -->
2022-04-24 17:42:09 +08:00
</div>
</div>
2022-04-25 16:38:32 +08:00
<div class="news-list" v-if="tabList.length">
2022-04-25 17:51:40 +08:00
<div class="item" v-for="(item,index) in newsList" :key="index" v-if="newsList.length" @click="toDetail(item.id)">
2022-04-25 16:27:08 +08:00
<div class="left">
<h2>{{ item.title }}</h2>
2022-07-08 11:22:57 +08:00
<p><span>{{ item.categoryName }}</span>{{ item.createTime }}</p>
2022-04-25 16:27:08 +08:00
</div>
2022-04-25 16:38:32 +08:00
<div class="right" v-if="item.pictureUrl.length">
2022-04-25 16:27:08 +08:00
<img :src="item.pictureUrl" alt="">
</div>
2022-04-24 17:42:09 +08:00
</div>
2022-04-25 16:38:32 +08:00
<AiEmpty description="暂无数据" v-if="!newsList.length" style="background: #f3f4f5;"/>
2022-04-24 17:42:09 +08:00
</div>
2022-04-25 16:38:32 +08:00
<AiEmpty description="暂无数据" v-else/>
2022-04-24 17:42:09 +08:00
</div>
</template>
<script>
2022-04-29 20:09:43 +08:00
export default {
name: 'newsList',
data() {
return {
currIndex: 0,
title: '',
isLoading: false,
newsList: [],
isShowEmpty: false,
current: 1,
areaId: '',
tabList: [],
parentId: '',
parentName: '',
}
},
onLoad(params) {
this.parentId = params.id
this.parentName = params.parentName
2022-04-29 21:16:30 +08:00
uni.$on('update', (tabIndex) => {
2022-05-07 10:57:22 +08:00
this.currIndex = tabIndex
2022-04-29 21:16:30 +08:00
})
2022-04-29 20:09:43 +08:00
},
onShow() {
document.title = this.parentName
this.getList().then(() => this.getListInit())
},
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
methods: {
// 查看分类
toSelect() {
uni.navigateTo({url: `./select?parentId=${this.parentId}&index=${this.currIndex}`})
2022-04-24 17:42:09 +08:00
},
2022-04-29 20:09:43 +08:00
// 切换tab栏
changeTab(index) {
this.newsList = []
this.currIndex = index
this.current = 1
2022-04-25 13:59:02 +08:00
this.getListInit()
2022-04-24 17:42:09 +08:00
},
2022-05-07 14:23:09 +08:00
// scroll(e) {
// console.log(e);
// },
2022-04-29 20:09:43 +08:00
// 获取新闻分类
getList() {
return this.$http.post('/app/apppublicitycategory/list', null, {
params: {
parentId: this.parentId,
categoryType: '2',
}
}).then((res) => {
var array = []
res.data.records.map(item => {
array.push({
name: item.categoryName,
id: item.id,
parentId: item.parentId,
2022-04-25 13:59:02 +08:00
})
})
2022-04-29 20:09:43 +08:00
return this.tabList = array
})
2022-04-24 17:42:09 +08:00
},
2022-04-29 20:09:43 +08:00
getListInit() {
this.current = 1
this.newsList = []
2022-04-25 16:38:32 +08:00
this.getNewsList()
2022-04-29 20:09:43 +08:00
},
// 获取新闻列表
getNewsList() {
this.$http.post(`/app/apppublicityinfo/list?`, null, {
params: {
current: this.current,
moduleId: this.currIndex == 0 ? this.tabList[0].parentId : this.tabList[this.currIndex].parentId,
categoryId: this.tabList[this.currIndex].id,
}
}).then(res => {
if (res.code === 0) {
this.newsList = this.current == 1 ? res.data.records : [...this.newsList, ...res.data.records]
}
})
},
// 查详情
toDetail(id) {
uni.navigateTo({url: `./newsDetail?id=${id}`})
},
},
onReachBottom() {
this.current++,
2022-05-05 11:44:10 +08:00
this.getNewsList()
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
}
2022-04-24 17:42:09 +08:00
</script>
<style lang="scss" scoped>
2022-04-29 20:09:43 +08:00
.header-tab {
background-color: #fff;
position: relative;
padding: 0 100px 0 0;
2022-05-07 10:57:22 +08:00
box-sizing: border-box;
2022-04-29 20:09:43 +08:00
.more-icon {
position: absolute;
width: 40px;
height: 38px;
right: 32px;
top: 20px;
}
2022-05-07 10:57:22 +08:00
// ::v-deep .uni-scroll-view-content {
// display: flex;
// }
2022-04-29 20:09:43 +08:00
div {
height: 80px;
line-height: 80px;
font-size: 26px;
transition-duration: 1s;
padding: 0px 30px;
2022-05-07 14:23:09 +08:00
white-space:nowrap;
2022-04-29 20:09:43 +08:00
}
.tab-item {
color: #666;
2022-04-24 17:42:09 +08:00
position: relative;
}
2022-04-29 20:09:43 +08:00
.active-item {
color: #3376FD;
font-weight: 600;
}
.active-line {
width: 48px;
height: 4px;
2022-04-25 16:27:08 +08:00
background: #FFF;
2022-04-29 20:09:43 +08:00
position: absolute;
bottom: 14px;
left: 50%;
margin-left: -24px;
background-color: #3376FD;
}
}
.news-list {
background: #FFF;
padding-top: 90px;
box-sizing: border-box;
2022-04-25 16:27:08 +08:00
2022-04-29 20:09:43 +08:00
.item {
padding: 30px 30px 20px 30px;
display: flex;
justify-content: space-between;
border-bottom: 1px solid #DDDDDD;
.left {
h2 {
font-size: 30px;
color: #333333;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
2022-04-25 16:27:08 +08:00
}
2022-04-29 20:09:43 +08:00
p {
margin-top: 30px;
font-size: 22px;
color: #999999;
span {
margin-right: 15px;
2022-04-25 16:27:08 +08:00
}
}
2022-04-29 20:09:43 +08:00
2022-04-25 16:27:08 +08:00
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.right {
width: 224px;
height: 140px;
margin-left: 40px;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
img {
width: 100%;
height: 100%;
}
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
}
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.news {
min-height: 100vh;
padding-top: 96px;
background: #fff;
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.item-video {
position: relative;
height: 388px;
margin-bottom: 24px;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.mask {
position: absolute;
width: 100%;
height: 100%;
z-index: 11;
background: rgba(0, 0, 0, 0.16);
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
.play-btn {
position: absolute;
top: 50%;
left: 50%;
z-index: 121;
width: 80px;
height: 80px;
margin: 0;
transform: translate(-50%, -50%);
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
.item-title {
width: 100%;
padding: 0 30px 10px;
font-size: 28px;
font-weight: 500;
color: #FFF;
line-height: 40px;
position: absolute;
bottom: 0;
left: 0;
word-break: break-all;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
background: rgba(0, 0, 0, .4);
box-sizing: border-box;
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
.cover {
display: block;
width: 100% !important;
height: 388px !important;
margin-left: 0 !important;
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
}
div {
box-sizing: border-box;
}
.noMore {
line-height: 90px;
text-align: center;
color: #999;
font-size: 26px;
}
.news {
background: #fff;
}
.header {
position: fixed;
left: 0;
top: 0;
z-index: 10000;
width: 100%;
padding: 8px 0;
background: #fff;
.header-search {
display: flex;
align-items: center;
width: 690px;
height: 60px;
margin: 0 auto 8px;
padding: 0 32px;
background: #0D6DDC;
border-radius: 30px;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
image {
flex-shrink: 1;
width: 32px;
height: 32px;
margin-right: 12px;
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
input {
flex: 1;
height: 100%;
font-size: 28px;
color: #fff;
2022-04-24 17:42:09 +08:00
}
}
2022-04-29 20:09:43 +08:00
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.item {
padding: 0 30px;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
&:first-child {
2022-04-24 17:42:09 +08:00
.item-wrapper {
2022-04-29 20:09:43 +08:00
padding-top: 0 !important;
2022-04-24 17:42:09 +08:00
}
2022-04-29 20:09:43 +08:00
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.item-wrapper {
padding: 30px 0 20px;
display: flex;
align-items: center;
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.item-left {
flex: 1;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
h2 {
margin-bottom: 32px;
color: #333333;
font-size: 30px;
font-weight: 700;
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.item-left__bottom {
display: flex;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
span {
margin-right: 10px;
color: #999999;
font-size: 22px;
&:last-child {
margin-right: 0;
2022-04-24 17:42:09 +08:00
}
}
2022-04-29 20:09:43 +08:00
.top-text {
font-size: 22px;
color: #EF4645;
margin-right: 16px;
}
2022-04-24 17:42:09 +08:00
}
}
2022-04-29 20:09:43 +08:00
image {
flex-shrink: 0;
width: 224px;
height: 140px;
// margin-left: 46px;
}
}
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
.no-more {
margin-top: 20px;
text-align: center;
color: #999;
2022-04-24 17:42:09 +08:00
2022-04-29 20:09:43 +08:00
image {
width: 400px;
height: 240px;
2022-04-24 17:42:09 +08:00
}
2022-04-25 13:59:02 +08:00
2022-04-29 20:09:43 +08:00
p {
text-align: center;
color: #999;
font-size: 28px;
2022-04-25 13:59:02 +08:00
}
2022-04-29 20:09:43 +08:00
}
::v-deep .emptyWrap .emptyImg {
margin-top: 40px;
}
2022-04-24 17:42:09 +08:00
</style>