<template>
	<view class="content">
		<pcNav :data="'index'"></pcNav>
		<view style="height: 72rpx;"></view>
		<view class="swiperBox">
			<view class="swiperCont">
				<view class="tuijbox">
					<image src="../../static/pcimg/icon_tuijian@2x.png" mode="" class="tuijImg"></image>
					<span class="tuijTitle">推荐文章</span>
				</view>
				 <swiper class="swiper"  :autoplay="false"   :circular="true" :current="swpIndex">
					<swiper-item v-for="(item,index) in recommendList" v-if="(index+1)%2!=0">
						<view class="swpCont">
							<view class="swiper-item" @click="goDetail(item)">
								<view class="swpimgBox swpBr">
									<image :src="item.logoImg" mode="" class="swpimg"></image>
								</view>
								<view class="swpTitleBox">
									<view class="swpTitle">{{item.title}}</view>
									<view class="categoryName" @click.stop="goList(item)">{{item.categoryName}}</view>
								</view>
								
							</view>
							<view class="swiper-item" v-if="(index+1)<recommendList.length" @click="goDetail(item)">
								<view class="swpimgBox swpBr">
								   <image :src="recommendList[index+1].logoImg" mode="" class="swpimg"></image>
								</view>
								<view class="swpTitleBox">
									<view class="swpTitle">{{recommendList[index+1].title}}</view>
									<view class="categoryName">{{recommendList[index+1].categoryName}}</view>
								</view>
							</view>
						</view>
						
					</swiper-item>
					
				</swiper>
				<image src="../../static/pcimg/icon_arrow_zuo_sel@2x.png" mode="" class="swpImgleft" @click="swpBtnLeft"></image>
				<image src="../../static/pcimg/legtspx.png" mode="" class="swpImgright" @click="swpBtnRight"></image>
			</view>
		</view>
		
		<view class="main">
			<view class="mainCont">
				<view class="mainline" v-for="(item,index) in indexData.categoryList">
					<view class="mainlineTop">
						<view class="mainlineTopleft">
							<view class="mainlineTitle">{{item.name}}</view>
							<view class="mainlinecount">共{{item.count}}篇文章</view>
						</view>
						<view class="mainlineMore" @click="mainMore(item)">查看更多></view>
					</view>
					<view class="mainwzbox" v-if="item.children.length>0">
						<view class="mainwzline" v-for="(wz,wzindex) in item.children" @click="goDetail2(wz,item)" v-if="wzindex<4" :class="{'mainwzlineR':wzindex!=3}">
							<view class="mainwzImgBox">
							  <img :src="wz.logoImg" alt="" class="mainwzImg">	
							</view>
							<view class="wztitle">{{wz.title}}</view>
						</view>
						
					</view>
					
					
				</view>
				
				
			</view>
			
		</view>
		
		
		<view class="gotop" @click="gotoTop">
			<image src="../../static/pcimg/btn_top@2x.png" mode="" class="gotopImg"></image>
		</view>
		
		
		
		<!-- <view>
			<a class="table-btn" href="http://phone.66km.cn:8088/marketing/training/940C4BF0A2E04542A1A1AD244EAFB6E2.xlsx" target='_blank'>下载入口</a>
		</view> -->
		
		
		
	</view>
</template>

<script>
	import pcNav from '../../components/pcNav/pcNav.vue'
	export default {
		components: {
			pcNav,
		},
		data() {
			return {
				title: 'Hello',
				allCategory:[],
				navMoret:false,
				swpIndex:0,
				indexData:'',
				recommendList:[],
			}
		},
		onLoad() {
          
		   this.getindexData()
		},
		methods: {
			goList(item){
				console.log(item)
				uni.navigateTo({
					url:'list?code='+item.code+'&topName='+item.categoryName//+'&comment='+item.comment
				})
			},
			goDetail(item){
				console.log(item)
				uni.navigateTo({
					url:'detail?id='+item.id+'&topName='+item.categoryName+"&comment="+item.comment+'&parentCode='+item.code
				})
			},
			goDetail2(wz,item){
				/* console.log(item)
				console.log(wz) */
				 uni.navigateTo({
					url:'detail?id='+wz.id+'&topName='+item.name+"&comment="+item.comment+'&parentCode='+item.code
				}) 
			},
			gotoTop(){
				uni.pageScrollTo({ 
				　　　scrollTop: 0, duration: 300 
				}); 
			},
			
			swpBtnRight(){
				var length=this.recommendList.length
				var num=Math.ceil(length/2)
				if(this.swpIndex<num){
					this.swpIndex++
				}
				
			},
			swpBtnLeft(){
				if(this.swpIndex==0){
					
				}else{
					this.swpIndex--
				}
				
			},
           
			getindexData(){
				uni.showLoading({
					title: '加载中'
				})
				this.$http('/trainingOpenApi/indexData', {}, 'GET').then(res => {
					uni.hideLoading();
					this.indexData = res.data;
					this.recommendList=this.indexData.recommendList
				})
			},
			mainMore(item){
				console.log(item)
				uni.navigateTo({
					url:'list?code='+item.code+'&topName='+item.name+'&comment='+item.comment
				})
			}
		}
	}
</script>

<style scoped>
	
	.swiperBox{
		height: 356rpx;
		background: #F3F8FF;
		width: 100%;
	}
	.swiperCont{
		width: 1200rpx;
		margin: 0 auto;
		position: relative;
	}
	.tuijImg{
		width: 24rpx;height: 24rpx;
	}
	.tuijbox{
		display: flex;padding-top: 44rpx;padding-bottom: 30rpx;
	}
	.tuijTitle{
		font-size: 24rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #111111;
		padding-left: 7rpx;
		line-height: 24rpx;
	}
	.swpImgleft{
		width: 44rpx;
		height: 44rpx;
		position: absolute;
		top: 175rpx;
		left: -60rpx;
		cursor: pointer;
	}
	.swpImgright{
		width: 44rpx;
		height: 44rpx;
		position: absolute;
		top: 175rpx;
		right: -60rpx;
		cursor: pointer;
	}
	.swiper-item{
		width: 576rpx;
		height: 183rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(153, 153, 153, 0.25);
		border-radius: 9rpx;
		margin-top: 14rpx;
		position: relative;
		cursor: pointer;
	}
	.swiper-item:hover{
		box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(153, 153, 153, 0.25);
	}
	.swpCont{
		display: flex;
		height: 210rpx;
		justify-content: space-between;
	}
	.swpimg{
		width: 276rpx;
		height: 184rpx;
	}
	.swpimgBox{
		width: 276rpx;
		height: 184rpx;
		position: absolute;
		left: 0;
		top: -14rpx;
		
	}
	.swpBr{
		width: 276rpx;
		height: 184rpx;
		border-radius: 10rpx;
		overflow: hidden;
	}
	.swiper{
		height: 200rpx;
	}
	.swpTitleBox{
		padding-left: 296rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		height: 160rpx;
		padding-top: 10rpx;
		
	}
	
	.swpTitle{
		width: 260rpx;
		height: 44rpx;
		font-size: 16rpx;
		font-weight: 500;
		color: #3C3C3C;
		line-height: 22rpx;
		 text-overflow: -o-ellipsis-lastline;
		  overflow: hidden;
		  text-overflow: ellipsis;
		  display: -webkit-box;
		  -webkit-line-clamp: 2;
		  line-clamp: 2;
		  -webkit-box-orient: vertical;
	}
	.swpTitleBox:hover .swpTitle{
		color: #FF4F00;
	}
	.categoryName{
		line-height: 24rpx;
		width: 84rpx;
		height: 24rpx;
		background: rgba(63, 144, 247, 0.1);
		border-radius: 14rpx;
		font-size: 12rpx;
		color: #3F90F7;
		text-align: center;
		white-space: nowrap; 
		overflow: hidden; 
		text-overflow: ellipsis; 
	}
	.mainCont{
		width: 1200rpx;
		margin: 0 auto;
	}
	.mainline{
		padding-top: 48rpx;
	}
	.mainlineTop{
		display: flex;
		justify-content: space-between;
	}
	.mainlineTopleft{
		display: flex;
	}
	.mainlineTitle{
		font-size: 20rpx;
		font-weight: 500;
		color: #111111;
		line-height: 33rpx;
	}
	.mainlinecount{
		font-size: 14rpx;
		font-weight: 400;
		color: #999999;
        line-height: 33rpx;
		padding-left: 16rpx;
	}
	.mainlineMore{
		font-size: 14rpx;
		color: #333333;
	}
	.mainwzbox{
		display: flex;
		padding-top: 30rpx;
		
	}
	.mainwzImg{
		width: 276rpx;
		height: 184rpx;
	}
	.mainwzImgBox{
		border-radius: 8rpx;
	    overflow: hidden;
		height: 184rpx;
		border: 1rpx solid #eeeeee;
	}
	.mainwzline{
		width: 276rpx;
		height: 260rpx;
		background: #FFFFFF;
		
	}
	.mainwzlineR{
	  margin-right: 32rpx;	
	}
	.wztitle{
		width: 250rpx;
		font-size: 15rpx;
		color: #333333;
		line-height: 22rpx;
		height: 44rpx;
		text-overflow: -o-ellipsis-lastline;
		 overflow: hidden;
		 text-overflow: ellipsis;
		 display: -webkit-box;
		 -webkit-line-clamp: 2;
		 line-clamp: 2;
		 -webkit-box-orient: vertical;
		 padding:0 13rpx ;
		 padding-top: 16rpx;
		 font-weight: 600;
		
	}
	.mainwzline:hover{
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(153, 153, 153, 0.2);
		border-radius: 6rpx;
		cursor: pointer;
	}
	.mainwzline:hover .wztitle{
		color: #FF4F00;
	}
	.mainlineMore:hover{
		color: #FF4F00;
		cursor: pointer;
	}
	.gotopImg{
		width: 60rpx;
		height: 60rpx;
	}
	.gotop{
		position: fixed;
		right:15vh ;
		bottom: 100rpx;
		cursor: pointer;
	}
</style>
