<template>
	<app-layout>
	<view class="page">
		<view class="center">
			<view class="item" v-for="(item,index) in VisitList" :key="index" @click="goPage(item.id)">
					<view style="width: 100%;height: 396rpx;">
						<image style="width: 100%;height: 396rpx;" :src="item.cover_img" mode=""></image>
					</view>
				<view class="main-between pl" >
					<view class="main-between-y">
						<view class="title t-omit">{{item.name}}</view>
						<view class="desc t-omit" :style="{width: is_myself===0?'':'100%'}">活动时间：{{`${item.begin_time}-${item.end_time}`}}</view>
					</view>
					<view v-if="is_myself===0" class="right-bt">
						<view style="width: 118rpx;" class="t-omit">{{item.num}}</view>
						<view class="ee">名额仅剩</view>
					</view>
				</view>
				<view class="line"></view>
				<view class="main-between cross-center addr">
					<view class="t-omit" :style="{width: is_myself===0?'400rpx':'100%'}">活动地点：{{item.address}}</view>
					<button v-if="is_myself===0" class="appointment-now" style="padding: 0;border-radius: 0;" size="mini" :style="{'background-color':item.is_already_appoint==1?'#908d89':getTheme.background}">{{item.is_already_appoint==1?'已预约':'去预约'}}</button>
				</view>
			</view>
			<appNoData v-if="VisitList.length===0" :title="'暂无预约'"></appNoData>
			<view class="no-more" v-if="noMore && VisitList.length>0">没有更多了...</view>
		</view>
	</view>
	</app-layout>
</template>

<script>
	import {mapGetters} from 'vuex'
	import appNoData from '@/components/page-component/app-no-goods/app-no-goods.vue'
	export default {
		components:{
			appNoData
		},
		data() {
			return {
				page:1,
				is_myself:0,
				VisitList:[],
				noMore:false
			};
		},
		computed:{
			...mapGetters('mallConfig', {
			    getTheme: 'getTheme',
			}),
		},
		onLoad(option) {
			'is_myself' in option?this.is_myself=option.is_myself:''
			this.getVisitList()
		},
		onReachBottom() {
			if(!this.noMore){
			this.page++
			this.getVisitList()
			}
		},
		methods:{
			goPage(id){
				uni.navigateTo({
					url:`/pages/case/appointment/appointment?id=${id}&is_myself=${this.is_myself}`
				})
			},
			getVisitList(){
				this.$showLoading()
				this.$request({
					url:this.$api.user.visit_list,
					methods:'post',
					data:{
						page:this.page,
						is_myself:this.is_myself
					}
				}).then(res=>{
					if(res.code===0){
						if(this.page==1){
							this.VisitList=res.data.list
						}else{
							this.VisitList=this.VisitList.concat(res.data.list) 
						}
						if(res.data.list.length<20){
							this.noMore=true
						}
					}
					this.$hideLoading()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.no-more {
		font-size: 24rpx;
		font-weight: 500;
		color: #666666;
		margin-top: 37rpx;
		text-align: center;
	}
	.page{
		position: relative;
		min-height: 100vh;
	}
	.tpbg{
		width: 750rpx;
		height: 368rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: -1;
	}
	.w{
		width: 750rpx;
	}
	.center{
		width: 750rpx;
		height: auto;
		background: #F8F8F8;
		border-radius: 20rpx;
		overflow: hidden;
		padding: 36rpx;
		.tagf{
			padding-bottom: 26rpx;
		}
		.tag{
			min-width: 131rpx;
			height: 51rpx;
			background: #EFEFEF;
			border-radius: 10rpx;
			font-size: 24rpx;
			font-weight: 500;
			color: #999999;
			text-align: center;
			line-height: 51rpx;
			padding: 0 15rpx;
			margin-right: 20rpx;
		}
		.active{
			background: #A18353;
			color: #FFFFFF;
		}
		.item{
			width: 678rpx;
			height: auto;
			background: #FFFFFF;
			border-radius: 14rpx;
			margin:0 auto 24rpx;
			overflow: hidden;

			.pl{
				padding: 28rpx 22rpx;
				margin-top: 25rpx;
				.title{
					width: 480rpx;
					font-size: 32rpx;
					font-weight: bold;
					color: #222222;
				}
				.desc{
					width: 480rpx;
					font-size: 22rpx;
					font-weight: 500;
					color: #999999;
				}
				.right-bt{
					width: 118rpx;
					height: 82rpx;
					background: #FFFFFF;
					border: 2rpx solid #A18353;
					

					font-size: 30rpx;
					font-weight: 500;
					color: #A18353;
					text-align: center;
					.ee{
						font-size: 18rpx;
					}
				}
			}
			.line{
				padding: 0 28rpx;
				background-color: #D8D8D8;
				width: 100%;
				height: 1px;
			}
			.addr{
				padding: 24rpx 22rpx 32rpx 28rpx;
				font-size: 22rpx;
				font-weight: 500;
				color: #999999;
				line-height: 22rpx;
			}
			.appointment-now{
				width: 118rpx;
				font-size: 22rpx;
				height: 100%;
				color: #fff;
				margin: 0;
			}
		}
	}
</style>
