<template>
	<view class="mineActive">
		<statusBar :item="navBarData"></statusBar>
		<!-- 消息提示 -->
		<msgPop></msgPop>

		<view class="list">
			<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="lower">
				<view>
					<listBlock1 ref="listBlock1" :classList="activeList"></listBlock1>
				</view>
				<view class="loading">
					<view v-if="Loading==1">数据加载中...</view>
					<view v-if="Loading==2">没有更多了~~</view>
				</view>
			</scroll-view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				navBarData: {
					title: '我的活动',
					btn: 1
				},
				activeList: [],

				Loading: 0, //0默认值  1加载中 2没有更多了
				currentPage: 1, //页数
			};
		},
		// onUnload() {
		// 	this.$store.dispatch('asyncDelAll')
		// },
		methods: {
			gotoDetail(e) {
				let data = e.currentTarget.dataset.all
				uni.navigateTo({
					url: `/pages/activityDetail/activityDetail?acId=${data.acId}`,
				});
			},
			// 资源库触底
			lower() {
				console.log('没触底？');
				if (this.Loading == 2) return
				this.Loading = 1
				this.currentPage++
				setTimeout(this.getdata, 1000)
			},
			// 获取数据
			getdata() {
				let data = {
					oid: this.$store.state.user.openid, //用户id
					type: 2,
					currentPage: this.currentPage, //页数
					lim: 30
				}

				this.$request('/selectRegistered', "POST", data).then(res => {
					console.log('获取数据', res[0]);


					if (!res[0].length) {
						this.Loading = 2
					} else {
						this.Loading = 0
					}
					
					// console.log('this.currentPage',this.currentPage);
					if (this.currentPage == 1) {
						// console.log('haha');
						this.activeList = []
					}

					this.activeList = [...this.activeList, ...res[0]]

					// this.activeList = res[0]
				})
			}
		},
		onLoad() {
		},
		onShow() {

			this.Loading = 0
			this.currentPage = 1
			this.getdata()
			// 获取收藏事件
			this.$refs.listBlock1.getdata()
		}
	}
</script>

<style lang="scss">
	.loading {
		height: 30rpx;
		text-align: center;
		padding-top: 20rpx;
		padding-bottom: 100rpx;
		font-size: 26rpx;
		color: #888;
		line-height: 2em;
	}

	.mineActive {
		display: flex;
		flex-direction: column;
		height: 100vh;

		.list {
			flex: 1;
			overflow: hidden;
		}
	}
</style>