<template>
	<view class="content">
		<view class="list">
			<list-info :type="type" :data="item" v-for="(item,index) in list" :key="index"></list-info>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	import listInfo from '@/components/list-info/index.vue'
	export default {
		components: {
			listInfo
		},
		data() {
			return {
				type: '',
				list: [],
				page: 1,
				limit: 10,
				last_page: 1
			}
		},
		onLoad(option) {
			this.type = option.type
			if(this.type == 'info') {
				uni.setNavigationBarTitle({
					title: '资讯'
				})
			}
			if(this.type == 'article') {
				uni.setNavigationBarTitle({
					title: '文章'
				})
			}
			if(this.type == 'video') {
				uni.setNavigationBarTitle({
					title: '视频'
				})
			}
		},
		onShow() {
			this.list = []
			this.getlist()
		},
		onPullDownRefresh() {
			
		},
		onReachBottom() {
			if(this.last_page == this.page) {
				uni.$u.toast('已经到底了')
				return
			} else {
				this.page++
				this.getlist()
			}
		},
		methods: {
			getlist() {
				var _this = this
				$api.req({
					url: _this.type,
					method: 'GET',
					data: {
						page: _this.page,
						limit: _this.limit,
						is_boutique: 1,
						format_type: 'normal'
					}
				}, function(res) {
					if(res.code == 10000) {
						_this.list = _this.list.concat(res.data.list)
						_this.last_page = res.data.last_page
					}
				})
			},
		}
	}
</script>

<style lang="scss">

</style>
