<template>
	<view class="page">
		<u-navbar :is-back="false" :border-bottom="false" :background="background">
			<view style="width: 100%;padding: 0 10rpx;">
				<view class="flztoa inlbhhe ">
					<view class="indihh">
						<text style="font-size: 44rpx;color:  #374B6E;;">最新</text>
						<view
							style="width: 26rpx;height: 4rpx;background: #374B6E;border-radius: 4rpx;margin-top: 10rpx;">
						</view>
					</view>
					<navigator class="indihh" url="/pages/index/hykt" open-type="redirect" hover-class="none">
						<text>会员</text>
					</navigator>
					<navigator class="indihh" url="/pages/index/zylx" open-type="redirect" hover-class="none">
						<text>治愈练习</text>
					</navigator>
					<navigator class="indihh" url="/pages/index/hd" open-type="redirect" hover-class="none">
						<text>活动</text>
					</navigator>
				</view>
			</view>
		</u-navbar>
		<navigator hover-class="none" class="inbddwwer" url="./SearchPage">
			<view class="fzctob inbddwddre">
				<image src="/static/index/ina1.png"
					style="width: 40rpx;height: 40rpx;min-width: 40rpx;margin-right: 12rpx;"></image>
				<input type="text" disabled value="" placeholder-style="color: #CCCCCC;font-size: 28rpx;"
					placeholder="搜索你感兴趣的内容" />
			</view>
		</navigator>

		<view class="flztoa" style="padding:30rpx 50rpx;">
			<navigator class="incfh" url="../index/kc" hover-class="none">
				<image src="/static/index/ibb5.png" style="width: 68rpx;height: 68rpx;"></image>
				<text>课程</text>
			</navigator>
			<navigator class="incfh" url="../index/ztsp" hover-class="none">
				<image src="/static/index/ibb6.png" style="width: 68rpx;height: 68rpx;"></image>
				<text>主题视频</text>
			</navigator>
			<navigator class="incfh" url="../user/cp" hover-class="none">
				<image src="/static/index/ibb7.png" style="width: 68rpx;height: 68rpx;"></image>
				<text>测评</text>
			</navigator>
			<navigator class="incfh" url="../index/jiehuo" open-type="redirect" hover-class="none">
				<image src="/static/index/ibb8.png" style="width: 68rpx;height: 68rpx;"></image>
				<text>解惑</text>
			</navigator>
		</view>
		<view class="pages-banner-box">
			<view class="banner-box">
				<image src="/static/index/index-bg.png" style="width: 100%;" mode="widthFix"></image>
			</view>
			<view class="banner-list">
				<scroll-view scroll-y style="width: 100%;" type="custom" lower-threshold="20">
				  <grid-view type="masonry" cross-axis-count="2">
						<view class="scroll-item-box">
							<view class="list-item">
								<image src="/static/index/index-bg-1.png" mode="" style="width: 100%;height: 100%;" @click="goToUrl('/pages/user/cp')"></image>
							</view>
						</view>
						<view class="scroll-item-box">
							<view class="list-item">
								<image src="/static/index/index-bg-2.png" mode="" style="width: 100%;height: 100%;"></image>
							</view>
						</view>
						<view class="scroll-item-box">
							<view class="list-item">
								<image src="/static/index/index-bg-3.png" mode="" style="width: 100%;height: 100%;"></image>
							</view>
						</view>
						<view class="scroll-item-box">
							<view class="list-item">
								<image src="/static/index/index-bg-4.png" mode="" style="width: 100%;height: 100%;"></image>
							</view>
						</view>
						<view class="scroll-item-box">
							<view class="list-item">
								<image src="/static/index/index-bg-5.png" mode="" style="width: 100%;height: 100%;"></image>
							</view>
						</view>
				  </grid-view>
				</scroll-view>
			</view>
		</view>

		<view class="inyyeddf">
			<view class="indhuyr">
				<view class="indjbrr"></view>
				<text>最新资讯</text>
			</view>
			<view class="inyyelb">
				<view class="inyyelbks" @click="toDetail(item.id)" v-for="(item,index) in ArticleList" :key="index">
					<image class="indkkimg" :src="item.img" mode="aspectFill"></image>
					<view class="fsxto">
						<view class="indkktxta"><text>{{item.title}}</text></view>
						<view class="indkktxtb u-line-1"><text>{{item.desc}}</text></view>
						<view class="indkktxtc"><text>{{item.type_name}}</text></view>
					</view>
				</view>
			</view>
		</view>

		<!-- <view class="inyyeddf">
			<view class="indhuyr">
				<view class="indjbrr"></view>
				<text>资讯</text>
			</view>

			<view class="inyyshiy" style="overflow-x: scroll;">
				<image class="inckkeer1" :src="`../../static/zy/zy0${index+1}.png`" mode="aspectFill" v-for="(item,index) in list"
					:key="index" @click="godetails('4',item.to_id,item)"></image>
			</view>
		</view> -->

		<view class="inyyeddf">
			<view class="indhuyr">
				<view class="indjbrr"></view>
				<text>课程</text>
			</view>

			<view>
				<view class="zytlidde" @click="goKcDetails(item)"
					v-for="(item,index) in newCourseList" :key="index">
					<view class="zytyyrimg" style="overflow: hidden;">
						<image :src="item.cover" mode="aspectFill" style="width: 100%; height: 100%;"></image>
					</view>
					<view class="zytyyopf">
						<view class="zytyotxta"><text>{{item.title}}</text></view>
						
						<view class="flztoa zytyotxtb">
							<text>{{item.lecturer_name}}</text>
						</view>
						<view class="flztoa zytyotxtc" style="margin-top: 6rpx;">
							<text>
								<text style="padding-right: 10rpx;">折扣价格: {{item.current_price}}</text>
								<text>原价格: {{item.original_price}}</text>
							</text>
							<image src="/static/zy/zyb3.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
						</view>
						<view class="flztoa">
							<view class="fzctob zytyotxtc">
								<text>{{item.play_count}}播放量 - 共{{item.chapter_num}}课时</text>
								<!-- <image v-show="xqaxuye" @click="xqaxuye = false" src="/static/zy/zyb1.png" style="width: 36rpx;height: 36rpx;margin-left: 20rpx;" mode=""></image>
								<image  v-show="!xqaxuye"  @click="xqaxuye = true" src="/static/zy/zyb2.png" style="width: 36rpx;height: 36rpx;margin-left: 20rpx;" mode=""></image> -->
							</view>
							<!-- 分钟 -->
							<text class="zytyotxtd">{{item.time}}</text>
						</view>
					</view>
				</view>
				<view class="zyhxyyer"></view>
			</view>
			
		</view>
		<!-- <view class="inyyeddf">
			<view class="indhuyr">
				<view class="indjbrr"></view>
				<text>讲师</text>
			</view>
			<view class="inyyshiy" style="overflow-x: scroll;">
				<image class="inckkeer1" :src="item.img" mode="aspectFill" v-for="(item,index) in type_3"
					:key="index" @click="godetails(item.to_type,item.to_id)"></image>
			</view>
		</view> -->


		<view style="height: 130rpx;"></view>
		<tabBar :active-index="activeIndex" @change="onTabBarChange"></tabBar>
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#ffffff',
				},
				page: 1,
				num: 10,
				banner: [],
				ArticleList: [], //最新咨询
				type_1: [], //小视频
				newCourseList: [], //课程
				type_3: [], //讲师
				sh: 0,
				activeIndex: 0,
			}
		},
		onLoad(res) {
			// #ifdef MP
				if(res.scene){
					uni.setStorageSync('invite_id',res.scene);
				}
			// #endif
			// this.getArticleList();
			// this.getHomeView();
			// this.getSh();

		},
		onShow() {
			this.activeIndex = 0;
			this.getcureList();
			this.getnewCourse();
		},
		methods: {
			goToUrl(u){
				uni.navigateTo({
					url: u
				})
			},
			onTabBarChange(index) {
				this.activeIndex = index;
			},
			getcureList(){
				this.$request.getcureList({}).then(res => {
					console.log(res)
					this.list = res.data.splice(0,3);
				}).catch(err => {
					console.log(err)
				})
			},
			// 获取资讯列表
			getSh() {
				this.$post({
					data: {
						do: 'Sh',
						data: {

						}
					}
				}).then(res => {
					this.sh = res.data.sh;
				}).catch(err => {
					this.sh = 0;
				})
			},
			// 获取资讯列表
			getArticleList() {
				this.$post({
					data: {
						do: 'articlelist',
						data: {
							page: this.page,
							num: this.num,
							type_id: 1
						}
					}
				}).then(res => {
					this.ArticleList = res.data.data
				}).catch(err => {
					this.ArticleList = []
				})
			},
			// 获取小视频 课程 讲师展示
			getHomeView() {
				this.$post({
					data: {
						do: 'HomeView'
					}
				}).then(res => {
					this.banner = res.data.banner
					this.type_1 = res.data.type_1
					this.type_2 = res.data.type_2
					this.type_3 = res.data.type_3
				})
			},
			// 获取课程
			getnewCourse() {
				let that = this;
				that.$request.getnewCourse({}).then(res => {
					this.newCourseList = res.data.splice(0,5);
				}).catch(err => {
					console.log(err)
				})
			},
			godetails(type, id,item) {
				if (type == '1') {
					uni.navigateTo({
						url: './kcxq-x?id=' + id
					})
				} else if (type == '2') {
					uni.navigateTo({
						url: './zxshi?id=' + id
					})
				} else if (type == '3') {
					uni.navigateTo({
						url: './hykt'
					})
				} else if (type == '4') {
					uni.navigateTo({
						url: './zyDetail?item=' + JSON.stringify(item)
					})
				}
			},
			// 资讯详情
			toDetail(id) {
				uni.navigateTo({
					url: './zxxq?id=' + id
				})
			},
			goKcDetails(id) {
				let item = JSON.stringify(i);
				uni.navigateTo({
					url: './kcxq-x?item=' + item
				})
			},
			tokc() {
				// if(uni.getStorageSync('is_lecturer')==1){
				uni.navigateTo({
					url: "../index/rmkc"
				})
				// }else{
				//     uni.navigateTo({
				//         url:"../user/rmkc" 
				//     })
				// }
			}

		}
	}
</script>

<style lang="scss" scoped>

	.page{
		background: #fff !important;
	}
	.pages-banner-box{
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
	}
	.banner-box{
		width: 100%;
		height: auto;
		border-radius: 6px;
	}
	.banner-box image {
		display: inline-block;
	}
	.banner-list{
		margin-top: 10rpx;
	}
	.scroll-item-box {
	  padding: 10rpx 10rpx 0 10rpx;
	  box-sizing: border-box;
	  border-radius: 6px;
	  overflow: hidden;
	}
	.list-item{
		background-color: #d9d9d9;
		height: 120rpx;
	}
	.scroll-item-box:nth-of-type(1) .list-item{
		height: 250rpx;
	}
	.incfh text{
		margin: 0;
	}

</style>
