<template>
	<view class="jj-wrap">
		<view class="jj" v-for="cp in list" @click="navto('/pages/index/artDetail?id=' + cp.id)">
			<image :src="cp.image_input[0]" mode="" class="jj-img"></image>
			<view class="jj-info">
				<view class="jj-tit-tit clamp2">
					{{cp.title}}
				</view>
				<view class="jj-val clamp">
					更新时间{{cp.add_time}}
				</view>
			</view>
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>

<script>
	import { article,articleList } from '@/api/user.js';
	import {
		loadIndexs,
		getArticleList
	} from '@/api/index.js';
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				loadingType: 'more',
				cid: 0,
			}
		},
		onLoad(opt) {
			this.cid = opt.cid
			this.tit = decodeURI(opt.tit)
			uni.setNavigationBarTitle({
				title: this.tit 
			})
			this.getArticleList()
		},
		methods: {
			navto(url) {
				uni.navigateTo({
					url: url
				})
			},
			getArticleList() {
				let obj = this
				if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading'
				article({
					page: obj.page,
					limit: obj.limit
				},obj.cid).then(({data}) => {
					obj.list = obj.list.concat(data)
					obj.page++
					if(data.length == obj.limit) {
						obj.loadingType = 'more'
					}else {
						obj.loadingType = 'noMore'
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff;
		min-height: 100%;
	}
	.jj-wrap {
		background-color: #fff;
		// margin: 20rpx 0;
		.jj {
			margin: auto;
			width: 689rpx;
			height: 202rpx;
			border-bottom: 1px solid #e5e5e5;
			padding: 20rpx;
			padding-left: 0;
			display: flex;
			&:last-of-type {
				border-bottom: none;
			}
			.jj-img {
				flex-shrink: 0;
				width: 222rpx;
				height: 158rpx;
				background-color: #bfa;
				border-radius: 10rpx;
			}
			.jj-info {
				width: 450rpx;
				// flex-shrink: 0;
				padding: 10rpx;
				padding-left: 15rpx;
				font-size: 32rpx;
				font-weight: bold;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.jj-tit-tit {
					
				}
				.jj-val {
					padding-top: 20rpx;
					font-size: 28rpx;
					font-weight: 500;
				}
			}
		}
	}
</style>
