<template>
	<view class="studyList">
		
		<!-- 列表 -->
		<zs-list class="store-box" mt="0" @load="loadMore" :status="status">
			<view class="left">	
				<view class="store-item" v-for="(item,index) in list" :key="index" @click="goGoodsDetail(item.goodsId)">
					<zs-img :src="item.logoPath" width="344rpx" height="344rpx" mode=""></zs-img>
					<view class="info">
						<view class="title">
							{{item.goodsName}}
						</view>
						<view class="user-info">
							<image class="head" :src="item.logoPath" mode=""></image>
							<view class="user-name">
								{{item.shopName}}
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="right">
		
				<view class="store-item" v-for="(item,index) in list1" :key="index" @click="goGoodsDetail(item.goodsId)">
					<zs-img :src="item.logoPath" width="344rpx" height="344rpx" mode=""></zs-img>
					<view class="info">
						<view class="title">
							{{item.goodsName}}
						</view>
						<view class="user-info">
							<image class="head" :src="item.logoPath" mode=""></image>
							<view class="user-name">
								{{item.shopName}}
							</view>
						</view>
					</view>
				</view>
			</view>
		
		</zs-list>
		
	</view>
</template>

<script>
	import {studyGoods} from '@/api/study.js';
	export default {
		data() {
			return {
				status: 'more',
				list: [],
				list1: [],
				query:{
					columnId:'',
					currentPage:1,
					pageSize:10,
				}
			}
		},
		methods: {
			// 去商品详情
			goGoodsDetail(id){
				uni.navigateTo({
					url:'/study/studyGoodsDetail?id='+id
				})
			},
			loadMore() {
				this.studyGoodsList()
			},
			studyGoodsList(){
				this.status = 'loading'
				studyGoods(this.query).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++
						}
					}
				})
			},
		},
		created() {
		},
		onLoad(option) {
			this.query.columnId = option.id
			uni.setNavigationBarTitle({
				title: option.title
			});
		}
	}
</script>

<style lang="scss" >
.studyList{
	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>