<template>
	<view class="content">
		<empty v-if="loaded && list.length == 0"></empty>
		<view class="action" v-for="item in list" >
			<image :src="item.article.image_input[0]" mode="" class="action-img"></image>
			<view class="action-tit">
				<!-- {{item.status == 1 ? '已通过': (item.status == -1 ? '未通过': '待审核')}} -->
				{{item.article.title}}
			</view>
			<view class=" time">
				<view class="">
					赠送：{{item.article.give_certificate}}骑行券
				</view>
				<view class="">
					审核结果：{{item.status == 1 ? '已通过': (item.status == -1 ? '未通过': '待审核')}}
				</view>
			</view>
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>
<script>
	import {
		articleList,
		record,
	} from '@/api/index.js'
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				list: [],
				loadingType: 'more',
				loaded: false,
				type: 0,
			};
		},
		onLoad(opt) {
			if(opt.type) {
				this.type = opt.type
			}
		},
		onShow() {
			this.getActionList()
		},
		onReachBottom() {
			this.getActionList()
		},
		methods: {
			goAction(item) {
				if(this.type == 0) {
					uni.navigateTo({
						url: '/pages/shop/action?id=' + item.id
					})
				}
				
			},
			getActionList() {
				if (this.loadingType == 'loading' || this.loadingType == 'noMore') {
					return
				}
				this.loadingType = 'loading'
				record({
					page: this.page,
					limit: this.limit
				}).then(res => {
					this.list = this.list.concat(res.data.data)
					console.log(res.data.data);
					this.page++
					try{
						if (res.data.data.length == this.limit) {
							this.loadingType = 'more'
						} else {
							this.loadingType = 'noMore'
						}
					}catch(e){
						console.log(e);
						//TODO handle the exception
					}
					
					this.loaded = true
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	page {
		background-color: #f2f2f2;
		height: auto;
		min-height: 100%;
	}

	.action {
		width: 700rpx;
		margin: 25rpx auto;
		border-radius: 35rpx;
		overflow: hidden;
		background-color: #fff;

		.action-img {
			width: 700rpx;
			height: 300rpx;
			background-color: #333;
		}

		.action-tit {
			min-height: 100rpx;
			font-size: 34rpx;
			font-weight: 500;
			color: #0E0E0E;
			display: flex;
			align-items: center;
			padding: 15rpx;
			padding-left: 30rpx;
		}
	}
	.time {
		font-size: 12rpx;
		padding: 20rpx;
		padding-top: 0;
	}
</style>