<template>
	<view class="jj-wrap">
		<view class="jj" v-for="cp in item[index].list" @click="navto('/pages/index/artListType?id=' + cp.id+'&type='+item[index].type+'&title='+encodeURI(cp.title))">
			<image :src="cp.image" mode="" class="jj-img"></image>
			<view class="jj-info">
				<view class="jj-tit-tit clamp2">
					{{cp.title}}
				</view>
				<view class="jj-val clamp2">
					{{cp.intr}}
				</view>
			</view>
		</view>
		<uni-load-more :status="item[index].loadingType"></uni-load-more>
	</view>
</template>

<script>
	import { articleList } from '@/api/user.js';
	export default {
		data() {
			return {
				index:0,
				cid:0,
				item:[{
					list: [],
					page: 1,
					limit: 10,
					title:'粟珈依安',
					loadingType: 'more',
					type: 3,
				},
				{
					list: [],
					page: 1,
					limit: 10,
					title:'康养家居',
					loadingType: 'more',
					type: 2,
				},
				{
					list: [],
					page: 1,
					limit: 10,
					title:'调理养护',
					loadingType: 'more',
					type: 0,
				},
				{
					list: [],
					page: 1,
					limit: 10,
					title:'专家专项',
					loadingType: 'more',
					type: 1,
				},{
					list: [],
					page: 1,
					limit: 10,
					title:'公司文化',
					loadingType: 'more',
					type: 4,
				}]
				
			}
		},
		onLoad(opt) {
			this.index = opt.type;
			this.cid = opt.id;
			uni.setNavigationBarTitle({
				title: this.item[this.index].title
			})
			this.getArticleList()
		},
		methods: {
			navto(url) {
				uni.navigateTo({
					url: url
				})
			},
			getArticleList() {
				let obj = this.item[this.index];
				if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading';
				articleList({
					page: obj.page,
					limit: obj.limit,
					fl:obj.type,
				}).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: 0 10rpx;
				padding-left: 15rpx;
				font-size: 32rpx;
				font-weight: bold;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				.jj-tit-tit {
					
				}
				.jj-val {
					font-size: 28rpx;
					font-weight: 500;
				}
			}
		}
	}
</style>
