|
|
|
<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 == item.id ? 'tab-a' : '')" @tap="tabClick(item.id)" v-for="item in categortList" :key="item.id">{{item.name}}</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="content-box">
|
|
|
|
<view class="list-box">
|
|
|
|
<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>{{item.visit}}</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>
|
|
|
|
<LoadStatus :loadStatus="loadStatus"></LoadStatus>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { articleCategory, getArticleList } from "@/api/article";
|
|
|
|
import { getArticle } from "@/api/home";
|
|
|
|
import LoadStatus from '@/components/LoadStatus.vue'
|
|
|
|
export default{
|
|
|
|
components: {
|
|
|
|
LoadStatus
|
|
|
|
},
|
|
|
|
data(){
|
|
|
|
return{
|
|
|
|
categortList: [],
|
|
|
|
articleList: [],
|
|
|
|
page: 0,
|
|
|
|
size: 10,
|
|
|
|
isLoading: true,
|
|
|
|
active: null,
|
|
|
|
loadStatus: '没有更多了...'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad(option) {
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.getArticleCategort().then(()=>{
|
|
|
|
this.active= this.$yroute.query.active;
|
|
|
|
this.getArticleList()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onReachBottom() {
|
|
|
|
this.page = this.page + 1
|
|
|
|
this.getArticleList()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getArticleCategort(){
|
|
|
|
return new Promise((reslove)=>{
|
|
|
|
articleCategory().then((res)=>{
|
|
|
|
this.categortList = res.data
|
|
|
|
this.active = this.categortList[0].id
|
|
|
|
reslove()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getArticleList() {
|
|
|
|
if(!this.isLoading) return
|
|
|
|
uni.showLoading({
|
|
|
|
title: '加载中...'
|
|
|
|
})
|
|
|
|
this.loadStatus = '加载中...'
|
|
|
|
getArticleList({
|
|
|
|
page: this.page,
|
|
|
|
size: this.size,
|
|
|
|
cid: this.active
|
|
|
|
}).then((res) => {
|
|
|
|
if(res.data.content.length < this.size){
|
|
|
|
this.isLoading = false
|
|
|
|
this.loadStatus = '没有更多了...'
|
|
|
|
} 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(id) {
|
|
|
|
this.active = id
|
|
|
|
this.isLoading = true
|
|
|
|
this.articleList = []
|
|
|
|
this.getArticleList()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|