<template>
	<view class="active">
		<view class="top">
		</view>

		<view class="list" v-if="list.length>0">
			<view class="list-item" @click="detail(item.id)" v-for="(item,index) in list" :key='index'>
				<view class="tips">
					热
				</view>
				<view class="image" :style="{backgroundImage:'url('+ (item.cover_resource ? item.cover_resource.url : '../../static/images/avator.png') +')'}">
					
				</view>
				<!-- <image :src="item.cover_resource ? item.cover_resource.url : '../../static/images/avator.png'" mode="">
				</image> -->
				<view class="right">
					<view class="title">
						{{item.title}}
					</view>
					<view class="text">
						发布人：{{item.admin_name}}
					</view>
					<view class="time">
						{{item.published_at}}
					</view>
				</view>
			</view>

		</view>
		<view class="empty" v-else>
			<view class="enptyStatus">
				<image src="../../static/empty.png" mode=""></image>
				<view class="words">
					暂无内容
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				last: false,
			}
		},
		async onShow() {
			if(this.is_weixin()){
				this.navTitle()
			}
			this.list = []
			this.page = 1
			this.last = false
			await this.getTabList()
			await this.getList()
		},
		onReachBottom() {
			if (!this.last) {
				this.page++
			}
			console.log(this.page)
			this.getList()
		},
		methods: {
//判断是否是微信
			is_weixin() {
				let ua = navigator.userAgent.toLowerCase();
				return ua.indexOf('micromessenger') != -1;
			},
			navTitle() {
				let navTitle = document.getElementsByTagName('uni-page-head');
				navTitle[0].style.display = 'none'
			},
			getTabList() {
				this.$u.get('/inform/category-user-tree', {
					type: 1
				}).then(res => {
					console.log(res, 'pp')
					this.tab_list = res.data
					this.current_tab = res.data[0].id
				})
			},
			getList() {
				this.$u.get('/inform/information', {
					category_id: 1,
					page: this.page,
					per_page:15
				}).then(res => {
					console.log(res, 'ppp')
					let data = res.data.list
					console.log(res, 'course1')
					if (this.page > 1 && data.length == 0) {
						uni.showToast({
							title: '暂无更多',
							icon: 'none'
						})
						this.last = true
					} else {
						this.list = this.list.concat(data)
					}
				})
			},
			detail(id) {
				uni.navigateTo({
					url: '../activity/details?id=' + id
				})
			},
			//创建活动
			add() {
				uni.navigateTo({
					url: './add'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		position: relative;
		background-color: rgba(238, 238, 238, 1);


	}
.enptyStatus{
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			padding: 30px 10px;
			image{
				width: 120px;
				height: 150px;
				margin-top: 80px;
			}
			.words{
				color: #ffae21;
				font-size: 18px;
				padding-top: 16px;
			}
		}
	.add {
		position: fixed;
		bottom: 75px;
		right: 15px;
		text-align: center;
		z-index: 6;

		.add-buttom {
			width: 36px;
			height: 36px;
			background: #6A6A6A;
			display: inline-block;
			text-align: center;
			line-height: 36px;
			opacity: 1;
			border-radius: 50%;
		}

		.add-tips {
			font-size: 10px;
			font-family: PingFang SC;
			font-weight: bold;
			line-height: 14px;
			color: #292929;
			opacity: 1;
			margin-top: 3px;

		}
	}

	.active {
		position: relative;
		height: 100%;


		.top {
			height: 132px;
			background-image: url(../../static/images/active-bg.png);
			background-size: 100%;
			background-repeat: no-repeat;
		}

		.tab {
			display: flex;
			align-items: center;
			width: 80%;
			margin: 0 auto;

			// background-color: #18B566;


			.item,
			.active-item {
				margin-top: 17px;

				view {
					display: block;
				}

				font-size: 18px;
				font-family: PingFang SC;
				font-weight: bold;
				line-height: 20px;
				color: rgba(113, 113, 113, .43);
				opacity: 0.43;
				opacity: 1;
				flex: 1;
				text-align: center;

				.week {
					padding-bottom: 12px;
				}

				.line {
					width: 48px;
					height: 4px;
					background: #3B7653;
					opacity: 1;
					border-radius: 1px;
					display: block;
					margin: 0 auto;

				}
			}

			.active-item {
				font-size: 18px;
				font-family: PingFang SC;
				font-weight: bold;
				line-height: 20px;
				color: #3B7653;

				.week {
					padding-bottom: 8px;
				}

			}
		}

		.list {
			padding: 20px 16px;

			.list-item {
				background: #FFFFFF;
				opacity: 1;
				border-radius: 12px;
				padding: 20px 10px;
				position: relative;
				display: flex;
				align-items: center;
				margin-bottom: 20px;

				.tips {
					position: absolute;
					width: 52px;
					height: 21px;
					text-align: center;
					line-height: 21px;
					background: #FD6738;
					top: 0;
					right: 0;
					opacity: 1;
					border-radius: 0px 12px 0px 12px;
					font-size: 12px;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
				}

				.image {
					flex: 0 0 60px;
					width: 60px;
					height: 60px;
					margin-right: 6px;
					background-position: center;
					background-repeat: no-repeat;
					background-size: cover;
				}

				.right {
					flex: 1;

					.title {
						width: 220px;
						font-size: 16px;
						font-family: PingFang SC;
						font-weight: bold;
						line-height: 20px;
						color: #282828;
						overflow: hidden;
						opacity: 1;
						white-space: nowrap;
						/*设置不换行*/
						overflow: hidden;
						/*设置隐藏*/
						text-overflow: ellipsis;
						/*设置隐藏部分为省略号*/
					}

					.text {
						font-size: 13px;
						font-family: PingFang SC;
						font-weight: 400;
						line-height: 20px;
						color: rgba(40, 40, 40, .47);
						margin-top: 3px;
					}

					.time {
						font-size: 10px;
						font-family: PingFang SC;
						font-weight: 400;
						line-height: 20px;
						color: rgba(40, 40, 40, .47);
					}
				}
			}
		}
	}
</style>
