123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <template>
- <view class="art-wrap">
- <view class="tabs">
- <view class="tab" v-for="(tab,index) in tabs" :key="index" @click="changeTab(tab)" :class="(tab.artCatId===artCatId)&&(tabs.length>1)?'active':''">{{tab.artCatTitle}}</view>
- </view>
- <view class="tab-container">
- <view class="item" v-for="(item,idx) in artList" :key="idx">
- <view class="content card" @click="showDetail(item)">
- <view class="top">
- <view class="lf">
- <view class="tag">{{item.artCatTitle}}</view>
- <view class="author" v-if="item.editorName">{{item.editorName}}</view>
- </view>
- <view class="rt"><span>{{MessageTimeFormat(item.issuedAt)}}</span></view>
- </view>
- <view class="info">
- <view class="title" v-if="item.artTitle">{{item.artTitle}}</view>
- <view class="footer">
- <view class="author">{{item.artAuthor?item.artAuthor:'未知'}}</view>
- <view class="time">{{item.issuedAt}}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {getToken} from '@/libs/auth.js';
- import {MessageTimeFormat} from '@/libs/index.js';
- import {getArtCatTop,getArtByPage} from '@/api/system/art.js'
- export default {
- data() {
- return {
- artCatId:"",
- tabs:[],
- artList:[],
- conditions: {
- page: 1,
- limit: 10
- },
- total:0
- }
- },
- onShow() {
- this.conditions={
- page: 1,
- limit: 10
- }
- this.artList=[]
- this.getArtCatTop()
- },
- methods:{
- MessageTimeFormat,
- changeTab(item){
- this.artCatId=item.artCatId
- this.conditions={
- page: 1,
- limit: 10
- }
- this.artList=[]
- this.getArtByPage()
- },
- getArtCatTop(){
- getArtCatTop().then((res)=>{
- this.tabs=res.data
- if(res.data.length>0){
- this.artCatId=res.data[0].artCatId
- this.getArtByPage()
- }
- })
- },
- getArtByPage(){
- let items=JSON.parse(JSON.stringify(this.artList))
- getArtByPage({
- ...this.conditions,
- artCatId:this.artCatId
- }).then((res)=>{
- this.artList=items.concat(res.data)
- this.total=res.total
- })
- },
- showDetail(){
- let baseUrl="http://h5.xazhyc.com"
- uni.navigateTo({
- url:`/pages/webview/webview?href=${baseUrl}/art/views/detail.html&artId=473700&name=通讯录`
- })
- }
- },
- onReachBottom() {
- if(this.total>=this.conditions.page*this.conditions.limit){
- this.conditions.page++
- this.getArtByPage()
- }
- },
- onPullDownRefresh() {
- this.conditions={
- page: 1,
- limit: 10
- }
- this.artList=[]
- this.getArtCatTop()
- uni.stopPullDownRefresh()
- }
- }
- </script>
- <style lang="scss" scoped>
- .art-wrap{
- padding: 24rpx;
- background-color: #f2f2f2;
- .tabs{
- overflow-x: auto;
- overflow-y: hidden;
- display: flex;
- background-color: #fff;
- border-radius: 16rpx;
- .tab{
- height: 88rpx;
- line-height: 88rpx;
- display: inline-block;
- padding: 0 32rpx;
- flex: 1 0 auto;
- font-size: 28rpx;
- color: #35364F;
- position: relative;
- text-align: center;
- &::after{
- display: block;
- width: 50%;
- border-bottom: 2px solid transparent;
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- content: "";
- }
- &.active{
- font-size: 34rpx;
- font-weight: 700;
- &::after{
- border-bottom: 2px solid #15CD85;
- }
- }
- }
- }
- .tab-container{
- background-color: #f2f2f2;
- .item{
- margin-top: 20rpx;
- .card{
- background: #FFFFFF;
- border-radius: 10rpx;
- padding: 24rpx;
- .top{
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-bottom: 20rpx;
- .lf{
- flex: 1;
- display: flex;
- align-items: center;
- .tag{
- font-size: 20rpx;
- display: inline-block;
- padding:4rpx 6rpx;
- border: 1px solid #15CD85;
- line-height: 1;
- color: #15CD85;
- border-radius: 4rpx;
- }
- .author{
- display: inline-block;
- padding-left: 5px;
- line-height: 1;
- color: #666;
- }
- }
- }
- .info{
- font-size: 24rpx;
- font-weight: 500;
- color: #B0B0B0;
- line-height:1;
- padding-top: 0.22rem;
- .title{
- font-size:32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #000000;
- line-height:48rpx;
- text-overflow: ellipsis;
- overflow: hidden;
- -webkit-line-clamp: 2;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- }
- .footer{
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-top: 10rpx;
- }
- }
- }
- }
- }
- }
- </style>
|