This commit is contained in:
shijingjing
2022-04-25 16:27:08 +08:00
parent fe0b027460
commit 73c49b1c91
3 changed files with 106 additions and 34 deletions

View File

@@ -45,7 +45,6 @@ export default {
categoryType: '1', categoryType: '1',
} }
}).then((res)=>{ }).then((res)=>{
console.log(res);
this.list = res.data.records this.list = res.data.records
}) })
}, },

View File

@@ -1,15 +1,15 @@
<template> <template>
<div class="newList"> <div class="newList">
<div class="header"> <div class="header" v-if="tabList.length">
<div class="header-tab"> <div class="header-tab">
<img src="https://cdn.cunwuyun.cn/dvcp/live/dh.png" alt="" class="more-icon" @click="toSelect()"> <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> <u-tabs :list="tabList" :current="currIndex" @change="changeTab" style="width:650rpx" :font-size="26"></u-tabs>
<!-- <div v-for="(item, index) in tabList" :key="index" @click="changeTab(index)" v-if="index < 5" :class="currIndex == index ? 'tab-item active-item' : 'tab-item'">{{item}}<span class="active-line" v-if="currIndex == index"></span></div> --> <!-- <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> -->
</div> </div>
</div> </div>
<div class="news-list"> <div class="news-list" v-if="newsList.length">
<div class="item" hover-class="bg-hover" v-for="(item, index) in newsList" :key="index" @click="toDetail(item)"> <!-- <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: type === '1' ? 'block' : 'flex'}"> <div class="item-wrapper solid" style="display: flex">
<div class="item-left flex1"> <div class="item-left flex1">
<h2 :style="{marginBottom: item.type === '1' ? '16rpx' : '30rpx'}" v-if="item.type != '1'">{{ item.title }}</h2> <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'"> <div class="item-video" v-if="item.type === '1'">
@@ -26,10 +26,19 @@
</div> </div>
<image v-if="item.type === '0'" :src="item.coverFile" mode="aspectFill" /> <image v-if="item.type === '0'" :src="item.coverFile" mode="aspectFill" />
</div> </div>
</div> -->
<div class="item" v-for="(item,index) in newsList" :key="index">
<div class="left">
<h2>{{ item.title }}</h2>
<p><span>通知公告</span>{{ item.createTime }}</p>
</div>
<div class="right">
<img :src="item.pictureUrl" alt="">
</div>
</div>
</div> </div>
<AiEmpty v-if="!newsList.length && isShowEmpty"/> <AiEmpty v-if="!newsList.length && isShowEmpty"/>
<div class="noMore" v-if="isMore && current !== 0">没有更多了噢</div>
</div>
</div> </div>
</template> </template>
@@ -38,17 +47,17 @@
name: 'newList', name: 'newList',
data () { data () {
return { return {
currIndex: 0, currIndex: '0',
title: '', title: '',
isLoading: false, isLoading: false,
newsList: [], newsList: [],
isShowEmpty: false, isShowEmpty: false,
isMore: false, isMore: false,
current: 0, current: 1,
areaId: '', areaId: '',
tabList: [], tabList: [],
parentId: '', parentId: '',
parentName: '' parentName: '',
} }
}, },
@@ -63,6 +72,9 @@
this.currIndex = uni.getStorageSync('newTypeIndex') this.currIndex = uni.getStorageSync('newTypeIndex')
this.getListInit() this.getListInit()
} }
// uni.$on('update',()=>{
// this.getListInit()
// })
document.title = this.parentName document.title = this.parentName
this.getList() this.getList()
this.getListInit() this.getListInit()
@@ -75,12 +87,13 @@
}, },
changeTab(index) { changeTab(index) {
this.currIndex = index this.currIndex = index
// this.newsList = []
this.getListInit() this.getListInit()
}, },
onConfirm () { onConfirm () {
this.isMore = false this.isMore = false
this.current = 0 this.current = 1
this.$nextTick(() => { this.$nextTick(() => {
this.getNewsList(this.areaId) this.getNewsList(this.areaId)
@@ -95,34 +108,43 @@
categoryType: '2', categoryType: '2',
} }
}).then((res)=>{ }).then((res)=>{
// console.log(res,'新闻分类');
var array = [] var array = []
res.data.records.map(item=>{ res.data.records.map(item=>{
array.push({ name: item.categoryName }) array.push({
name: item.categoryName,
id: item.id,
parentId: item.parentId,
})
}) })
this.tabList = array this.tabList = array
console.log(this.tabList[this.currIndex].parentId,'parentId');
}) })
}, },
// toNewList() {
// uni.navigateTo({url: `./newList?parentName=${this.parentName}`})
// },
getListInit() { getListInit() {
this.isMore = false this.isMore = false
this.current = 0 this.current = 1
this.newsList = [] this.newsList = []
this.getNewsList() this.getNewsList()
}, },
// 获取新闻列表
getNewsList() { getNewsList() {
if (this.isMore || this.isLoading) return // if (this.isMore || this.isLoading) return
var type = this.currIndex // var type = this.currIndex
if(this.currIndex == 0) { // if(this.currIndex == 0) {
type = '' // type = ''
// }
// this.isLoading = true
this.$http.post(`/app/apppublicityinfo/list?`, null, {
params: {
current: this.current,
moduleId: this.tabList[this.currIndex].parentId,
categoryId: this.tabList[this.currIndex].id,
} }
this.isLoading = true
this.$http.post(`/app/appnewscenterinfo/listForWxNew?current=${this.current + 1}&type=${type}&size=10&title=${this.title}&areaId=${this.areaId}`, null, {
withoutToken: 1
}).then(res => { }).then(res => {
console.log(res);
if (res.code === 0) { if (res.code === 0) {
this.isShowEmpty = true this.isShowEmpty = true
@@ -142,7 +164,7 @@
const data = res.data.records const data = res.data.records
this.newsList.push(...data) this.newsList.push(...data)
this.current = this.current + 1 this.current = this.current
this.isLoading = false this.isLoading = false
this.$nextTick(() => { this.$nextTick(() => {
@@ -181,18 +203,69 @@
right: 32rpx; right: 32rpx;
top: 20rpx; top: 20rpx;
} }
div {
height: 80px;
line-height: 80px;
font-size: 26px;
transition-duration: 1s;
padding: 0px 30px;
}
.tab-item{ .tab-item{
color: #666; color: #666;
position: relative;
} }
.active-item{ .active-item{
color: #3376FD; color: #3376FD;
font-weight: 600;
} }
.active-line{ .active-line{
width: 48px;
height: 4px;
background: #FFF;
position: absolute;
bottom: 14px;
left: 50%;
margin-left: -24px;
background-color: #3376FD; background-color: #3376FD;
} }
} }
.news-list{ .news-list{
padding-top: 20rpx; 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;
}
}
.right {
width: 224px;
height: 140px;
img {
width: 100%;
height: 100%;
}
}
}
} }
.news { .news {
min-height: 100vh; min-height: 100vh;