You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
277 lines
5.7 KiB
277 lines
5.7 KiB
<template> |
|
<view class="list-page"> |
|
|
|
<view class="search-box"> |
|
<view class="search-content acea-row row-middle"> |
|
<view class="search-icon"> |
|
<image src="../../../static/images/search.png"> </image> |
|
</view> |
|
<input type="text" placeholder="请输入相关关键词" /> |
|
<view class="search-btn">搜一下</view> |
|
</view> |
|
<view class="resource-tabs acea-row row-between-wrapper"> |
|
<view :class="'tab ' + (active == 1 ? 'tab-a' : '')" data-i="1" @tap="tabClick">今日大事</view> |
|
<view :class="'tab ' + (active == 2 ? 'tab-a' : '')" data-i="2" @tap="tabClick">商业资讯</view> |
|
<view :class="'tab ' + (active == 3 ? 'tab-a' : '')" data-i="3" @tap="tabClick">政府政策</view> |
|
<view :class="'tab ' + (active == 4 ? 'tab-a' : '')" data-i="4" @tap="tabClick">生活资讯</view> |
|
</view> |
|
</view> |
|
<view class="content-box"> |
|
<view class="list-box" v-if="active == 1"> |
|
<view class="list-item acea-row row-between row-middle" v-for="(item,index) in articleList" :key="index" |
|
@click="toDetail(item.id)"> |
|
<view class="item-l"> |
|
<view class="title-box acea-row"> |
|
<image src="../../../static/images/hot.png" v-if="item.isHot"></image> |
|
<view class="title line2">{{item.title}}</view> |
|
</view> |
|
<view class="acea-row row-middle row-between"> |
|
<view class="auth">{{item.author}}</view> |
|
<view class="auth time">{{item.createTime.split(' ')[0]}}</view> |
|
<view class="see acea-row row-middle"> |
|
<text>200</text> |
|
<image src="../../../static/images/eye.png"></image> |
|
</view> |
|
</view> |
|
</view> |
|
<view class="item-r"> |
|
<image :src="item.imageInput" mode="aspectFill"></image> |
|
</view> |
|
</view> |
|
</view> |
|
<view class="list-box" v-if="active == 2"> |
|
<view>2</view> |
|
</view> |
|
<view class="list-box" v-if="active == 3"> |
|
<view>3</view> |
|
</view> |
|
<view class="list-box" v-if="active == 4"> |
|
<view>4</view> |
|
</view> |
|
</view> |
|
|
|
|
|
<view class="loadStatus-box">{{loadStatus}}</view> |
|
</view> |
|
</template> |
|
|
|
<script> |
|
import { |
|
getArticle |
|
} from "@/api/home"; |
|
export default { |
|
data() { |
|
return { |
|
active: '1', |
|
articleList: [], |
|
page: 0, |
|
size: 10, |
|
isLoading: true, |
|
loadStatus: '没有更多了...' |
|
} |
|
}, |
|
onLoad(option) { |
|
this.active=option.active; |
|
}, |
|
mounted() { |
|
this.getArticleList() |
|
}, |
|
onReachBottom() { |
|
this.page = this.page + 1 |
|
this.getArticleList() |
|
}, |
|
methods: { |
|
getArticleList() { |
|
if (!this.isLoading) return |
|
uni.showLoading({ |
|
title: '加载中...' |
|
}) |
|
this.loadStatus = '加载中...' |
|
getArticle({ |
|
page: this.page, |
|
size: this.size, |
|
isHot: 0 |
|
}).then((res) => { |
|
if (res.data.content.length < this.size) { |
|
this.loadStatus = '没有更多了...' |
|
this.isLoading = false |
|
} else { |
|
this.isLoading = true |
|
this.loadStatus = '上拉加载更多...' |
|
} |
|
this.articleList = this.articleList.concat(res.data.content) |
|
uni.hideLoading() |
|
}) |
|
}, |
|
toDetail(id) { |
|
this.$yrouter.push({ |
|
path: '/pages/life/articleDetail/index', |
|
query: { |
|
id: id |
|
} |
|
}) |
|
}, |
|
tabClick(e) { |
|
this.setData({ |
|
active: e.currentTarget.dataset.i, |
|
}) |
|
}, |
|
} |
|
} |
|
</script> |
|
|
|
<style lang="less"> |
|
.list-page { |
|
width: 100%; |
|
min-height: 100vh; |
|
background: #EEEEEE; |
|
|
|
.search-box { |
|
width: 100%; |
|
padding: 32rpx 40rpx 0 40rpx; |
|
background: #fff; |
|
|
|
.search-icon { |
|
width: 35rpx; |
|
height: 35rpx; |
|
margin-right: 12rpx; |
|
|
|
image { |
|
width: 100%; |
|
height: 100%; |
|
} |
|
} |
|
|
|
.search-content { |
|
width: 100%; |
|
padding: 0 0 0 50rpx; |
|
border: 2rpx solid #FF5100; |
|
border-radius: 8rpx; |
|
font-size: 28rpx; |
|
border-right: 0; |
|
|
|
input { |
|
color: #BFBFBF; |
|
} |
|
|
|
.search-btn { |
|
width: 132rpx; |
|
height: 70rpx; |
|
background: linear-gradient(39deg, #FF5100 0%, #FFA074 100%); |
|
line-height: 68rpx; |
|
text-align: center; |
|
color: #fff; |
|
border-radius: 8rpx; |
|
margin-left: auto; |
|
} |
|
} |
|
} |
|
|
|
.resource-tabs { |
|
width: 100%; |
|
background: #fff; |
|
|
|
.tab { |
|
width: 150rpx; |
|
padding: 22rpx 0; |
|
font-size: 32rpx; |
|
color: #707070; |
|
position: relative; |
|
font-weight: 500; |
|
text-align: center; |
|
} |
|
|
|
.tab::after { |
|
display: block; |
|
content: ''; |
|
width: 84rpx; |
|
height: 12rpx; |
|
border-radius: 8rpx; |
|
background: #FF5100; |
|
position: absolute; |
|
bottom: -6rpx; |
|
left: 50%; |
|
margin-left: -40rpx; |
|
opacity: 0; |
|
transform: scaleX(0); |
|
transition: all .2s ease, opacity .15s ease; |
|
} |
|
|
|
.tab-a { |
|
color: #1D1D1D; |
|
font-weight: 600; |
|
} |
|
|
|
.tab-a::after { |
|
opacity: 1; |
|
transform: scaleX(1); |
|
} |
|
} |
|
|
|
.list-box { |
|
width: 100%; |
|
padding: 26rpx 40rpx 0; |
|
|
|
.list-item { |
|
width: 100%; |
|
background: #fff; |
|
border-radius: 12rpx; |
|
padding: 26rpx 32rpx 21rpx 32rpx; |
|
font-size: 24rpx; |
|
color: #707070; |
|
margin-bottom: 24rpx; |
|
|
|
.item-l { |
|
width: calc(100% - 260rpx); |
|
display: flex; |
|
flex-direction: column; |
|
justify-content: space-between; |
|
height: 130prx; |
|
|
|
.title-box { |
|
font-size: 32rpx; |
|
color: #4A4A4A; |
|
|
|
image { |
|
width: 19rpx; |
|
height: 22rpx; |
|
margin-right: 20rpx; |
|
} |
|
|
|
.title { |
|
margin-top: -10rpx; |
|
margin-bottom: 25rpx; |
|
} |
|
} |
|
|
|
.see { |
|
// margin-left: 20rpx; |
|
|
|
image { |
|
width: 24rpx; |
|
height: 24rpx; |
|
margin-left: 6rpx; |
|
} |
|
} |
|
} |
|
|
|
.item-r { |
|
width: 240rpx; |
|
|
|
image { |
|
width: 100%; |
|
height: 130rpx; |
|
border-radius: 16rpx; |
|
} |
|
} |
|
} |
|
} |
|
|
|
.loadStatus-box { |
|
text-align: center; |
|
font-size: 28rpx; |
|
color: #000; |
|
padding: 30rpx 0; |
|
} |
|
} |
|
</style>
|
|
|