<template>
	<view>
		<view class="card" v-for="(item,index) in plist" :key="index" @click="goDetail(item.id)">
			<view class="card-left">
				<image class="card-left-image" :src="item.main_image"></image>
			</view>
			<view class="card-right">
				<view class="right-title">{{item.title}}</view>
				<view class="right-box">
					<view class="box-content">
						<view class="content-text">{{item.address}}</view>
						<view class="content-text" style="margin-top: 20rpx;">{{item.start_time}}</view>
					</view>
					<view class="box-btn">正在进行中</view>
				</view>
			</view>
		</view>
		<uni-load-more :status="pstatus"></uni-load-more>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				ppage: 1,
				psize: 20,
				pstatus: 'more',
				plist: [],
			}
		},
		onLoad() {
			_this = this;
			_this.getMore();
		},
		onReachBottom: function() {
			if (_this.pstatus !== 'more') {
				return;
			}
			_this.getMore();
		},
		methods: {
			goDetail: function(id) {
				uni.navigateTo({
					url: '/pages/activity/activityDetail?id=' + id
				});
			},
			
			getMore() {
				_this.$req.ajax({
					path: "activity/listActivity",
					data: {
						ppage: _this.ppage,
						psize: _this.psize,
					}
				}).then((data) => {
					_this.pstatus = data.pstatus;
					_this.plist = _this.plist.concat(data.plist);
					_this.ppage += 1;
					console.log("列表数据", data)
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			}
		}
	}
</script>

<style lang="scss">
	.card {
		margin: 10rpx 20rpx 30rpx;
		padding: 20rpx 20rpx;
		border-radius: 12rpx;
		background-color: #FFFFFF;
		box-shadow: 5rpx 5rpx 10rpx 2rpx rgba(149, 149, 149, 0.3);
		display: flex;
		align-items: center;
		
		.card-left {
			width: 250rpx;
			height: 170rpx;
			border-radius: 12rpx;
			
			.card-left-image {
				width: 250rpx;
				height: 170rpx;
				border-radius: 12rpx;
			}
		}
		
		.card-right {
			flex: 1;
			height: 170rpx;
			margin-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			
			.right-title {
				width: 100%;
				font-weight: bold;
				overflow: hidden;
				text-overflow: ellipsis;
				-webkit-line-clamp: 1;
				display: -webkit-box;
				-webkit-box-orient: vertical;
			}
			
			.right-box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				
				.box-content {
					flex: 1;
					
					.content-text {
						width: 100%;
						font-size: 23rpx;
						color: #afafaf;
						overflow: hidden;
						text-overflow: ellipsis;
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
					}
				}
				
				.box-btn {
					margin-left: 15rpx;
					width: 140rpx;
					height: 50rpx;
					font-size: 24rpx;
					color: #CA151C;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 12rpx;
					border: 1rpx solid #CA151C;
				}
			}
		}
	}
</style>