Files
dvcp_v2_wxcp_app/src/apps/AppInfotainment/newLIst.vue

432 lines
10 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()">
<u-tabs :list="tabList" :current="currIndex" @change="changeTab" style="width:650rpx" :font-size="26"></u-tabs>
2022-04-25 16:27:08 +08:00
<!-- <div v-for="(item, index) in tabList" :key="index" @click="changeTab(item.id)" v-if="index < 5" :class="currId == item.id ? 'tab-item active-item' : 'tab-item'">{{item.name}}<span class="active-line" v-if="currId == item.id"></span></div> -->
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 16:27:08 +08:00
<!-- <div class="item" hover-class="bg-hover" v-for="(item, index) in newsList" :key="index" @click="toDetail(item)">
<div class="item-wrapper solid" style="display: flex">
2022-04-24 17:42:09 +08:00
<div class="item-left flex1">
<h2 :style="{marginBottom: item.type === '1' ? '16rpx' : '30rpx'}" v-if="item.type != '1'">{{ item.title }}</h2>
<div class="item-video" v-if="item.type === '1'">
<p class="item-title">{{item.title}}</p>
<image class="play-btn" src="https://cdn.cunwuyun.cn/dvcp/pay-btn.png" />
<div class="mask"></div>
<image class="cover" :src="item.coverFile" mode="aspectFill" />
</div>
<div class="item-left__bottom item-active" :class="[item.photo ? 'item-active' : '']">
<span class="top-text" v-if="item.top == 1">置顶</span>
<span>{{tabList[item.detailType].name || ''}}</span>
<span>{{ item.createTime ? item.createTime.split(' ')[0] : '' }}</span>
</div>
</div>
<image v-if="item.type === '0'" :src="item.coverFile" mode="aspectFill" />
</div>
2022-04-25 16:27:08 +08:00
</div> -->
2022-04-25 16:38:32 +08:00
<div class="item" v-for="(item,index) in newsList" :key="index" v-if="newsList.length">
2022-04-25 16:27:08 +08:00
<div class="left">
<h2>{{ item.title }}</h2>
<p><span>通知公告</span>{{ item.createTime }}</p>
</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>
export default {
name: 'newList',
data () {
return {
2022-04-25 16:27:08 +08:00
currIndex: '0',
2022-04-24 17:42:09 +08:00
title: '',
isLoading: false,
newsList: [],
isShowEmpty: false,
isMore: false,
2022-04-25 16:27:08 +08:00
current: 1,
2022-04-24 17:42:09 +08:00
areaId: '',
2022-04-25 13:59:02 +08:00
tabList: [],
2022-04-25 14:10:36 +08:00
parentId: '',
2022-04-25 16:27:08 +08:00
parentName: '',
2022-04-24 17:42:09 +08:00
}
},
onLoad (params) {
2022-04-25 13:59:02 +08:00
this.areaId = params.areaId
this.getNewsList()
this.parentId = params.id
2022-04-25 14:10:36 +08:00
this.parentName = params.parentName
2022-04-24 17:42:09 +08:00
},
onShow() {
2022-04-25 16:38:32 +08:00
document.title = this.parentName
this.getList()
2022-04-25 13:59:02 +08:00
if(uni.getStorageSync('newTypeIndex')) {
this.currIndex = uni.getStorageSync('newTypeIndex')
this.getListInit()
}
2022-04-25 16:27:08 +08:00
// uni.$on('update',()=>{
// this.getListInit()
// })
2022-04-25 13:59:02 +08:00
this.getListInit()
2022-04-24 17:42:09 +08:00
},
methods: {
2022-04-25 14:10:36 +08:00
// 查看分类
2022-04-24 17:42:09 +08:00
toSelect() {
2022-04-25 14:10:36 +08:00
uni.navigateTo({url: `./select?parentId=${this.parentId}&index=${this.currIndex}`})
2022-04-24 17:42:09 +08:00
},
changeTab(index) {
2022-04-25 16:38:32 +08:00
this.newsList = []
2022-04-24 17:42:09 +08:00
this.currIndex = index
2022-04-25 16:38:32 +08:00
this.current = 1
2022-04-24 17:42:09 +08:00
this.getListInit()
},
onConfirm () {
this.isMore = false
2022-04-25 16:27:08 +08:00
this.current = 1
2022-04-24 17:42:09 +08:00
this.$nextTick(() => {
this.getNewsList(this.areaId)
})
},
2022-04-25 14:10:36 +08:00
// 获取新闻分类
2022-04-25 13:59:02 +08:00
getList() {
this.$http.post('/app/apppublicitycategory/list',null,{
params: {
parentId: this.parentId,
categoryType: '2',
}
}).then((res)=>{
2022-04-25 16:27:08 +08:00
// console.log(res,'新闻分类');
2022-04-25 13:59:02 +08:00
var array = []
res.data.records.map(item=>{
2022-04-25 16:27:08 +08:00
array.push({
name: item.categoryName,
id: item.id,
parentId: item.parentId,
})
2022-04-25 13:59:02 +08:00
})
this.tabList = array
2022-04-25 16:27:08 +08:00
console.log(this.tabList[this.currIndex].parentId,'parentId');
2022-04-25 13:59:02 +08:00
})
},
2022-04-25 14:10:36 +08:00
2022-04-24 17:42:09 +08:00
getListInit() {
this.isMore = false
2022-04-25 16:27:08 +08:00
this.current = 1
2022-04-24 17:42:09 +08:00
this.newsList = []
this.getNewsList()
},
2022-04-25 16:27:08 +08:00
// 获取新闻列表
2022-04-24 17:42:09 +08:00
getNewsList() {
2022-04-25 16:27:08 +08:00
this.$http.post(`/app/apppublicityinfo/list?`, null, {
params: {
current: this.current,
moduleId: this.tabList[this.currIndex].parentId,
categoryId: this.tabList[this.currIndex].id,
}
2022-04-24 17:42:09 +08:00
}).then(res => {
2022-04-25 16:27:08 +08:00
console.log(res);
2022-04-25 16:38:32 +08:00
2022-04-24 17:42:09 +08:00
if (res.code === 0) {
const data = res.data.records
this.newsList.push(...data)
2022-04-25 16:38:32 +08:00
this.current = this.current
}
}).catch((err) => {
console.log(err);
2022-04-24 17:42:09 +08:00
})
},
toDetail(item) {
if(item.detailType == 6 || item.detailType == 5) { //特色农产品 旅游故事
2022-04-25 13:59:02 +08:00
uni.navigateTo(`/subPages/live/products?id=${item.id}&detailType=${item.detailType}`)
2022-04-24 17:42:09 +08:00
}else {
2022-04-25 13:59:02 +08:00
uni.navigateTo(`/subPages/live/newsDetail?id=${item.id}&areaId=${this.areaId}&type=${this.currIndex}`)
2022-04-24 17:42:09 +08:00
}
},
},
2022-04-25 16:38:32 +08:00
onReachBottom () {
this.current ++,
this.getNewsList()
}
2022-04-24 17:42:09 +08:00
}
</script>
<style lang="scss" scoped>
.header-tab{
background-color: #fff;
position: relative;
padding: 0 100rpx 0 0;
.more-icon{
position: absolute;
width: 40rpx;
height: 38rpx;
right: 32rpx;
top: 20rpx;
}
2022-04-25 16:27:08 +08:00
div {
height: 80px;
line-height: 80px;
font-size: 26px;
transition-duration: 1s;
padding: 0px 30px;
}
2022-04-24 17:42:09 +08:00
.tab-item{
color: #666;
2022-04-25 16:27:08 +08:00
position: relative;
2022-04-24 17:42:09 +08:00
}
.active-item{
color: #3376FD;
2022-04-25 16:27:08 +08:00
font-weight: 600;
2022-04-24 17:42:09 +08:00
}
.active-line{
2022-04-25 16:27:08 +08:00
width: 48px;
height: 4px;
background: #FFF;
position: absolute;
bottom: 14px;
left: 50%;
margin-left: -24px;
2022-04-24 17:42:09 +08:00
background-color: #3376FD;
}
}
.news-list{
2022-04-25 16:27:08 +08:00
background: #FFF;
padding-top: 90px;
box-sizing: border-box;
.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;
}
p {
margin-top: 30px;
font-size: 22px;
color: #999999;
2022-04-25 16:38:32 +08:00
span {
margin-right: 15px;
}
2022-04-25 16:27:08 +08:00
}
}
.right {
width: 224px;
height: 140px;
2022-04-25 16:38:32 +08:00
margin-left: 40px;
2022-04-25 16:27:08 +08:00
img {
width: 100%;
height: 100%;
}
}
}
2022-04-24 17:42:09 +08:00
}
.news {
min-height: 100vh;
padding-top: 96rpx;
background: #fff;
}
.item-video {
position: relative;
height: 388rpx;
margin-bottom: 24rpx;
.mask {
position: absolute;
width: 100%;
height: 100%;
z-index: 11;
background: rgba(0, 0, 0, 0.16);
}
.play-btn {
position: absolute;
top: 50%;
left: 50%;
z-index: 121;
width: 80rpx;
height: 80rpx;
margin: 0;
transform: translate(-50%, -50%);
}
.item-title{
width: 100%;
padding: 0 30rpx 10rpx;
font-size: 28rpx;
font-weight: 500;
color: #FFF;
line-height: 40rpx;
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;
}
.cover {
display: block;
width: 100%!important;
height: 388rpx!important;
margin-left: 0!important;
}
}
div {
box-sizing: border-box;
}
.noMore {
line-height: 90rpx;
text-align: center;
color: #999;
font-size: 26rpx;
}
.news {
background: #fff;
}
.header {
position: fixed;
left: 0;
top: 0;
z-index: 10000;
width: 100%;
padding: 8rpx 0;
background: #fff;
.header-search {
display: flex;
align-items: center;
width: 690rpx;
height: 60rpx;
margin: 0 auto 8rpx;
padding: 0 32rpx;
background: #0D6DDC;
border-radius: 30rpx;
image {
flex-shrink: 1;
width: 32rpx;
height: 32px;
margin-right: 12rpx;
}
input {
flex: 1;
height: 100%;
font-size: 28rpx;
color: #fff;
}
}
}
.item {
padding: 0 30rpx;
&:first-child {
.item-wrapper {
padding-top: 0!important;
}
}
.item-wrapper {
padding: 30rpx 0 20rpx;
display: flex;
align-items: center;
}
.item-left {
flex: 1;
h2 {
margin-bottom: 32rpx;
color: #333333;
font-size: 30rpx;
font-weight: 700;
}
.item-left__bottom {
display: flex;
span {
margin-right: 10rpx;
color: #999999;
font-size: 22rpx;
&:last-child {
margin-right: 0;
}
}
.top-text{
font-size: 22rpx;
color: #EF4645;
margin-right: 16rpx;
}
}
}
image {
flex-shrink: 0;
width: 224rpx;
height: 140rpx;
// margin-left: 46rpx;
}
}
.no-more {
margin-top: 20rpx;
text-align: center;
color: #999;
image {
width: 400rpx;
height: 240rpx;
}
p {
text-align: center;
color: #999;
font-size: 28rpx;
}
}
2022-04-25 13:59:02 +08:00
::v-deep .emptyWrap .emptyImg {
margin-top: 40px;
}
2022-04-24 17:42:09 +08:00
</style>