<template>
	<view class="history">
		<view class="" v-if="list.length>0">


			<view class="item" v-for="(item,index) in list" :key='index' @click="detail(item.id)">
				<view :class="item.check_status==1 ? 'tips' : item.check_status==2 ? 'fail':'loading'">
					{{item.check_status_text}}
				</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="name">
						{{item.category_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: [1, 1, 1, 1, 1],
				page: 1,
				last:false
			}
		},
		onShow() {
			if(this.is_weixin()){
				this.navTitle()
			}
		
			this.list = []
			this.page=1
			this.last=false
			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'
			},
			getList() {
				let id = this.$store.state.vuex_user.id
				this.$u.get('/inform/information', {
					admin_id: id,
					page: this.page,
					per_page:15
				}).then(res => {
					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: './details?id=' + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.history {
		padding: 10px 15px;
		overflow: hidden;
.enptyStatus{
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			padding: 30px 10px;
			image{
				width: 120px;
				height: 150px;
				margin-top: 100px;
			}
			.words{
				color: #ffae21;
				font-size: 18px;
				padding-top: 18px;
			}
		}
		.item {
			background: #F4F9FD;
			padding: 12px 10px;
			border-radius: 12px;
			display: flex;
			align-items: center;
			position: relative;
			margin-bottom: 10px;

			.tips,
			.fail,
			.loading {
				position: absolute;
				padding: 0 5px;
				top: 0;
				right: 0;
				height: 20px;
				line-height: 20px;
				font-size: 11px;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 20px;
				color: #FFFFFF;
				border-radius: 12px 12px 0px 12px;
			}

			.tips {
				background: #3B7652;
			}

			.fail {
				background: rgba(136, 136, 136, 1);
			}

			.loading {
				background: rgba(242, 74, 20, 1);
			}

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

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

					opacity: 1;
				}

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

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