<template>
	<view class="content">
		<empty v-if="loaded && list.length == 0"></empty>
		<view class="action" v-for="item in list" @click="goAction(item)">
			<image :src="item.image_input[0]" mode="" class="action-img"></image>
			<view class="action-tit">
				{{item.title}}
			</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() {

		},
		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 = 'more'
				record({
					page: this.page,
					limit: this.limit
				}).then(res => {
					this.list = this.list.concat(res.data.data)
					this.page++
					if (res.data.data.lengt == this.limit) {
						this.loadingType = 'more'
					} else {
						this.loadingType = 'noMore'
					}
					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;
		}
	}
</style>