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.

221 lines
4.6 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">
时间:{{item.dateRange}}
</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)
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
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);
},
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_name_tow: 'release_time',
sort_type: "DESC",
sort_type_tow: '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){
m.dateRange = that.util.splitTime(m.start_time,m.over_time)
}
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;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 999
}
.exhibit_list {
padding: 0 30rpx;
padding-top: 85rpx;
padding-bottom: 150rpx;
}
.exhibit_item {
width: 100%;
padding: 30rpx 0;
padding-top: 20rpx;
border-bottom: 1px solid #fafaf9;
display: flex;
justify-content: space-between;
align-items: flex-start;
position: relative;
}
.exhibit_item img {
width: 310rpx;
height: 183rpx;
border-radius: 10rpx;
}
.exhibit_item>view {
width: 370rpx;
}
.exhibit_item>view view {
margin-bottom: 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;
position: absolute;
bottom: 20rpx;
right: 0;
}
.exhibit_item view.state span {
background-color: #f8ebdb;
border-radius: 10rpx;
color: #dea166;
font-size: 26rpx;
padding: 6rpx 20rpx;
display: inline-block;
width: 120rpx;
text-align: center;
}
.exhibit_item view.state span.finish {
background-color: #989898;
color: #fff;
}
</style>