<style>
	.activeInner{
		background-color: #F3F5F7;
	}
	.activeList{
		height:255px;
		margin:15px;
		background-color: #fff;
		border-radius: 3px;
		overflow: hidden;
		position: relative;
	}
	.activeInnerTop{
		width:100%;
		height:190px;
		border-radius: 3px;
		overflow: hidden;
	}
	.activeInnerTitle{
		font-size:14px;
		color:#404040;
		font-weight: bold;
		margin:10px 0 8px 15px;
	}
	.activeDate{
		color:#B9B9B9;
		font-size: 12px;
		margin-left:15px;
	}
	.activeJoin{
		color:#fff;
		background-color: #000450;
		width:60px;
		height:22px;
		border-radius: 3px;
		text-align: center;
		line-height: 22px;
		position: absolute;
		right:12px;
		bottom:12px;
		font-size:12px;
	}
	.activeJieshu{
		background-color: #AFAFAF;
		color:#fff;
	}
</style>
<template>
	<view class="activeInner" style="height:100vh;">
		<u-empty v-if="dataList.length==0" text="暂无数据" mode="data"></u-empty>
		<scroll-view v-else :scroll-y="true" :enable-back-to-top="true" :enable-flex="true"
		 @scrolltolower="lower" :style="{ 'height': `calc(100%)-15`}">
			<view class="activeList" v-for="(item,index) in dataList" :key="index" @click="goActiveDetail(item)">
				<view class="activeInnerTop">
					<img :src="item.CoverImg" style="width:100%;height:100%;" alt="" />
				</view>
				<view class="activeInnerTitle">{{item.ActivityName}}</view>
				<view class="activeDate">{{item.StartTimeStr}} 至 {{item.EndTimeStr}}</view>
				<view class="activeJoin" v-if="item.ActivityStatus==0">未开始</view>
				<view class="activeJoin" v-if="item.ActivityStatus==1">马上加入</view>
				<view class="activeJoin activeJieshu" v-if="item.ActivityStatus==2">已结束</view>
			</view>
			<view style="padding:10px 0;">
				<u-loadmore :status="status" bg-color="transparent" :load-text="loadText" :font-size="24" :margin-top="0" :margin-bottom="0" />
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: '活动列表',
				msg: {
					pageIndex: 1,
					pageSize: 10,
					ActivityType: 1
				},
				dataList:[],
				pageCount: 1,
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
			}
		},
		created() {},
		mounted() {
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
		},
		onLoad(option) {
			this.msg.ActivityType = option.Id;
			this.getData(1);
		},
		methods: {
			getData(num){
				if (num == 1) {
					this.dataList = [];
				}
				this.request2({
						url: "/api/AppletTrade/GetCommerceActivityPage",
						data: this.msg,
					},
					(res) => {
						if (res.resultCode == 1) {
							this.dataList = this.dataList.concat(res.data.pageData);
							this.pageCount = res.data.pageCount;
						}
					}
				);
			},
			//滚动加载
			lower(e) {
				if (this.msg.pageIndex < this.pageCount) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.getData();
				} else {
					this.status = "nomore";
				}
			},
			//跳转至详情
			goActiveDetail(item){
				uni.navigateTo({
					url: '/pages/kotra/activeInnerDetail?Id=' + item.Id
				});
			}
		}
	}
</script>
