<template>
	<view class="community">
		
		<!-- 列表 -->
		<zs-list mt="0" @load="loadMore" :status="status">
			<view class="left">	
				<view class="store-item" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
					<zs-img :src="item.coverImg" width="344rpx" height="256rpx" mode="widthFix"></zs-img>
					<view class="info">
						<view class="title">
							{{item.communityTitle}}
						</view>
						<view class="user-info">
							<image class="head" :src="item.publishLogo" mode=""></image>
							<view class="user-name">
								研学官方账号
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="right">
		
				<view class="store-item" v-for="(item,index) in list1" :key="index" @click="goDetail(item)">
					<zs-img :src="item.coverImg" width="344rpx" height="256rpx" mode="widthFix"></zs-img>
					<view class="info">
						<view class="title">
							{{item.communityTitle}}
						</view>
						<view class="user-info">
							<image class="head" :src="item.publishLogo" mode=""></image>
							<view class="user-name">
								研学官方账号
							</view>
						</view>
					</view>
				</view>
			</view>
		
		</zs-list>

	</view>
</template>

<script>
	import {getItem} from '@/api/study.js';
	export default {
		data() {
			return {
				status: 'more',
				id:0,
				list: [
					
				],
				list1: [
					
				],
			}
		},
		methods: {
			loadMore() {
				if(this.id){
					this.getItem()
				}
			},
			goDetail(item){
				uni.navigateTo({
					url:'./detail?id='+item.tabId,
					success(res) {
						console.log(1111111);
						res.eventChannel.emit('detail', item)
					}
				})
			},
			//获取社区分类列表
			getItem(){
				this.status = 'loading'
				getItem({communityId:this.id,currentPage:1,pageSize:10,state:2}).then(res=>{
					if(res.state == 'Success'){
						let list = []
						let list1 = []
						res.content.records.map((item,index)=>{
							if(index%2){
								list1.push(item)
							}else{
								list.push(item)
							}
						})
						this.list = this.list.concat(list)
						this.list1 = this.list1.concat(list1)
						let total = this.list.length+this.list1.length
						if(total>=res.content.total){
							this.status = 'noMore'
						}else{
							this.status = 'more'
							this.query.currentPage++
						}
					}
				})
			},
		},
		onLoad(options) {
			console.log(options.id);
			this.id = options.id
			this.getItem()
		}
	}
</script>

<style lang="scss" >
.community{
	background: #FFFFFF;
	padding: 20rpx;
	.zs-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		.left {
			
		}
	
		.right {
			
		}
		
		.store-item{
			box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0,0,0,0.08);
			border-radius: 16rpx;
			width: 344rpx;
			margin-top: 20rpx;
			.info{
				padding: 20rpx;
				.title{
					color: #222222;
					font-size: 24rpx;
					width: 100%;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;      /* 显示的最大行数 */
					overflow: hidden;
				}
				.user-info{
					display: flex;
					align-items: center;
					margin-top: 20rpx;
					.head{
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
					}
					.user-name{
						color: #AAAAAA;
						font-size: 20rpx;
						margin-left: 12rpx;
					}
				}
			}
		}
	}
}
</style>