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.

199 lines
4.3 KiB

<template>
<view class='content'>
<view class="tabsnav">
<u-tabs lineWidth="50" lineHeight="2" :scrollable="false" :list="tablist" lineColor="#dea166"
:is-scroll="false" :current="current" @change="exhibitChange"></u-tabs>
</view>
<view>
<u-empty v-if="dataList.length==0" marginTop="250"></u-empty>
<view class="exhibit_list" v-else='dataList.length>0'>
<view class='exhibit_item' v-for='item in dataList' @click='todetail(item.id)'>
<img :src="item.head_upload.url" alt="">
<view>
<view>{{item.name}}</view>
<view class="time">时间:{{cancelTime(item.start_time)}}至{{cancelTime(item.over_time)}}</view>
<view class='state'>
<span :class="item.state==1?'ongoing':'finish'">{{item.state==1?'当前展出':'已结束'}}</span>
</view>
</view>
</view>
</view>
</view>
<tabbar :current-page="3"></tabbar>
</view>
</template>
<script>
import tabbar from "../../components/tabbar/tabbar.vue"
export default{
components:{
tabbar
},
data(){
return{
tablist:[{
name: '全部',
idx: ""
}, {
name: '当前展览',
idx: 1
}, {
name: '往期回顾',
idx: 0
}],
current: 0,
currentPage: 1,
isLoading: false,
dataList:[]
}
},
onLoad() {
this.loadExhibit(1)
},
onPullDownRefresh() {
if (!this.isLoading) {
this.loadExhibit(this.currentPage + 1);
}
},
onReachBottom() {
if (!this.isLoading) {
this.loadExhibit(this.currentPage + 1);
}
},
methods:{
exhibitChange(e){
this.current = e.index;
this.loadExhibit(1);
},
cancelTime(str){
return str?str.substring(0,10):''
},
todetail(id){
uni.navigateTo({
url: "/pages/exhibit/detail?id="+id
});
},
loadExhibit(page){
uni.hideKeyboard()
var that = this;
that.isLoading = true;
this.util.request({
api: '/api/mobile/exhibit-hall/index',
customLoading: false,
data: {
page: page,
page_size: 6,
state:this.tablist[this.current].idx,
sort_name:'state',
sort_type:'DESC'
},
utilSuccess: function(r) {
var res = r.data;
that.isLoading = false;
var hasNoMore = r.total < 6 && page > 1;
console.log("hasNoMore", hasNoMore)
if (hasNoMore || res.length == 0 && page > 1) {
uni.stopPullDownRefresh(); // 服务器总条数 < 每页条数, 会将第一页的条数重新返回
// 已加载到最后一页
uni.showToast({
title: '已加载到最后一页',
icon: 'none'
});
return;
}
var dataList = that.dataList;
// for (var m of res) {
// if (m.created_at.indexOf('T') > 0)
// m.created_at = m.created_at.split("T")[0] + " " + m.created_at.split("T")[
// 1].split(".")[0];
// m.poster = (weixin.isNull(m.poster) ? "../../static/rishang.png" : m
// .poster_url)
// }
if (page == 1) {
dataList = res;
} else {
dataList.push(...res);
}
that.currentPage = page;
that.dataList = dataList;
},
utilFail: function(res) {
if (page == 1) {
that.currentPage = page;
}
that.util.alert(res);
}
});
}
}
}
</script>
<style>
.tabsnav{
background-color: #fbf3ea;
}
.exhibit_list{
padding:0 30rpx;
}
.exhibit_item{
width:100%;
padding:30rpx 0;
padding-top:20rpx;
border-bottom:1px solid #fafaf9;
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.exhibit_item img{
width:310rpx;
height:183rpx;
border-radius: 10rpx;
}
.exhibit_item>view{
width:370rpx;
}
.exhibit_item>view view{
margin-top:10rpx;
}
.exhibit_item>view view:first-child{
width: 100%;
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
/* 这里是超出几行省略 */
overflow: hidden;
font-size:30rpx;
}
.exhibit_item view.time{
font-size: 24rpx;
color:#6e6e6e;
}
.exhibit_item view.state{
text-align: right;
}
.exhibit_item view.state span{
background-color: #f8ebdb;
border-radius: 10rpx;
color:#dea166;
font-size: 30rpx;
padding:6rpx 20rpx;
display: inline-block;
}
.exhibit_item view.state span.finish{
background-color: #989898;
color:#fff;
}
</style>