<template>
	<view class="view_template">
		<view class="view_body">
			<u-navbar :is-back="true" title='添加作业' title-color="#000" :border-bottom="false" :background="true" id="navbar">
			</u-navbar>
			<!-- 搜索 -->
			<view class="view_search" v-if="search">
				<u-search :show-action="false" :animation="true" bg-color="#fff" placeholder="搜索相关内容..."></u-search>
			</view>
			<!--导航栏 -->
			<view class="view_tabs">
				<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#2D7CE6" bg-color="0"></u-tabs>
			</view>
			<!-- 轮播图 -->
			<swiper :interval="5000" :duration="1000" is-scroll="true" :current="current" @change="updateCurrent" class="swiper">
				<!-- 口语 -->
				<swiper-item>
				</swiper-item>
				<!-- 写作 -->
				<swiper-item>
					<view v-for="(item,index) in Compose" :key="item.id">
						<view class="view_bages">
							<view class="lelts">{{item.examName}}</view>
							<text class="Bags active" @click="upType(index,1)">test1</text>
							<text class="Bags" @click="upType(index,2)">test2</text>
							<text class="Bags" @click="upType(index,3)">test3</text>
							<text class="Bags" @click="upType(index,4)">test4</text>
						</view>
						<view class="view_fff" v-if="listType[index]===1">
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 1
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 1
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton" @click="addIdList()">

								</view>
							</view>
						</view>
						<view class="view_fff" v-else-if="listType[index]===2">
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 2
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 2
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
						</view>
						<view class="view_fff" v-else-if="listType[index]===3">
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 3
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 3
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
						</view>
						<view class="view_fff" v-else-if="listType[index]===4">
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 4
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
							<view class="view_Do">
								<view class="view_English">
									<view class="Task">
										Test 4
									</view>
									<view class="grizzly">曲线图</view>
									<view class="yellow">政府</view>
								</view>

								<view class="view_pushbutton">

								</view>
							</view>
						</view>
					</view>
				</swiper-item>
				<!--听力  -->
				<swiper-item>
					<audiology></audiology>
				</swiper-item>
				<!-- 阅读 -->
				<swiper-item>
					<reading></reading>
				</swiper-item>


			</swiper>
		</view>
		<!-- 底部按钮 -->
		<view class="footer">
			<view class="footer_button">
				<view :class="search==true  ? 'button_andadd' :'button_show'">确定添加（4）</view>
				<view class="footer_button_right" v-if="search">口语模考</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import audiology from './components/audiology.vue'
	import reading from './components/reading.vue'
	export default {
		data() {
			return {
				postdata :{
					"key": "",
					"pageNum": 0,
					"mode": "home",
					"part": "part1",
					"order": "0",
					"type": "",
					"isStudy": 0,
					"isFavorite": 0,
					"isEvlua": 0,
					"isFun": 0,
					"level": 0,
					"isNew": 0
				},
				// 导航栏
				list: [{
						name: '口语'
					},
					{
						name: '写作'
					},
					{
						name: '听力'
					},
					{
						name: '阅读'
					}
				],
				radio: [{
					name: '1',
					disabled: false
				}],
				//口语
				slander: [],
				// 口语下拉框
				options:[
					{
						id:1,
						name:'Part1'
					},
					{
						id:2,
						name:'Part2'
					}
				],
				options2:[
					{
						id:1,
						name:'环境类'
					},
					{
						id:2,
						name:'学习类'
					}
				],
				arrowDown:false,
				categorize:'分类',
				// 写作
				Compose: [],
				num:0,
				// 下拉框的v-if布尔值
				arrow:false,
				selectedOption:'Part1',
				radioValue: '',
				part1: true,
				current: 0,
				search: true,
				listType: [],
				idList: [],
				
				

			}
		},
		components:{
			audiology,
			reading
		},
		onLoad() {
			this.getList()
			this.getCompose()
		},
		methods: {
			upType(index, num) {
				this.listType.splice(index, 1, num)
			},
			// 口语接口
			getList() {
				let add ={"key":"","pageNum":0,"mode":"home","part":"part1","order":"0","type":"","isStudy":0,"isFavorite":0,"isEvlua":0,"isFun":0,"level":0,"isNew":0}
				this.$u.post('https://api.admin-v2.langsi.online/admin-api/speaking/topic/home/list',add).then(res => {
					let keyArr = Object.keys(res.data)
					let valueArr = Object.values(res.data)
					this.slander = keyArr.map((item, index) => {
						return {
							label: item,
							list: valueArr[index]
						}
					})
				})
			},
			change(index) {
				this.current = index;
			},
			//写作接口
			getCompose() {
				this.$u.post('https://api.admin-v2.langsi.online/admin-api/speaking/topic/home/list').then(res => {
					this.Compose = res.data
					console.log(this.Compose)
					for (let i = 0; i < res.data.length; i++) {
						this.listType.push(1)
					}
				})
			},
			// 选中某个单选框时，由radio时触发
			radioCheck(index) {
				if (this.radioValue == this.list2[index].id) {
					this.radioValue = null
				} else {
					this.radioValue = this.list2[index].id
				}
			},
			//轮播图滑动和tabs保持一致
			updateCurrent(current, source) {
				this.current = current.detail.current
				if (this.current == 0) {
					this.search = true
				} else {
					this.search = false

				}

			},
			//下拉显示下拉框
			arrow_xl(){
				this.arrow=!this.arrow
			},
			arrow_xl2(){
				this.arrowDown=!this.arrowDown
			},
			// 下拉然后更新里面的值
		arrow_options(id){
			 this.options.forEach(item=>{
				 if(item.id== id){
					 this.selectedOption=item.name
				 }else if(id==2){
					 this.postdata.part="part2"
					 this.getList()
				 }else{
					 this.postdata.part="part1"
					 this.getList()
				 }
			 })
		},
			Classification(id){
				this.options2.forEach(item=>{
					if(item.id == id){
						this.categorize =item.name
					}
				})
			},
			radioGroupChange() {

			}
		}
	}
</script>

<style lang="scss" scoped>
	.view_template {
		width: 100%;
		background: linear-gradient(183deg, #F0F6FF 0%, #FAFAFA 100%);
	}

	.view_body {
		height: 89vh;
		overflow-y: auto;
		width: 91.3%;
		margin: 0 auto;
		border-radius: 0rpx 0rpx 0rpx 0rpx;

		// padding: 32rpx;
		.view_search {
			height: 88rpx;
			margin: 0 auto;
			line-height: 88rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;

		}
		.view_button {
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			padding: 12rpx 24rpx;
			font-size: 20rpx;
			font-weight: 500;
			color: rgba(101, 116, 140, 0.8);
		}

		.view_buttons {
			background: #2D7CE6;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			padding: 12rpx 24rpx;
			font-size: 20rpx;
			font-weight: 500;
			color: #FFFFFF;
		}

		.view_fff {
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
		}

		.view_Do {
			display: flex;
			justify-content: space-between;
			padding: 28rpx 0rpx;
			margin: 0 28rpx;
			border-bottom: 2rpx solid #F2F2F2;
		}

		.view_pushbutton {
			display: flex;
		}

		.grizzly {
			background: #E1EEFF;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			font-size: 20rpx;
			font-weight: 500;
			color: #2D7CE6;
			padding: 6rpx 18rpx;
			margin-left: 12rpx;
		}

		.yellow {
			background: #FFEBD7;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			font-size: 20rpx;
			font-weight: 500;
			color: #FB9734;
			padding: 6rpx 18rpx;
			margin-left: 12rpx;
		}

		.view_English {
			display: flex;
			font-size: 24rpx;
			font-weight: 500;
			color: #2E4975;
		}

		 .active {
			z-index: 9;
			background:#2D7CE6;
			color: #fff;
		}

		.slander {
			height: 352rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
		}

		.slander_behavior {
			display: flex;
			justify-content: space-between;
			padding: 20rpx 0rpx;
			border-bottom: 2rpx solid #F2F2F2;
		}

		.slander_for {
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			padding: 0 30rpx;
		}

		.unite {
			font-size: 28rpx;
			font-family: 'PingFang';
			font-weight: 800;
			color: #2E4975;
			margin: 26rpx 0rpx;
		}

		.slander_an {
			background: #F4F4F4;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			font-size: 20rpx;
			font-family: 'PingFang';
			font-weight: 500;
			color: rgba(101, 116, 140, 0.8);
			padding: 10rpx;
			margin-right: 15rpx;
		}

		.pd_icon {
			margin-left: 8rpx;
		}

		.blue {
			background: rgba(45, 124, 230, 0.1);
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			color: #2D7CE6;
		}

		.part {
			font-size: 28rpx;
			font-family: 'PingFang';
			font-weight: 500;
			color: #2E4975;

		}

		.part2 {
			font-size: 28rpx;
			font-family: 'PingFang';
			font-weight: 500;
			color: #2E4975;
			margin-left: 20rpx;

		}

		.swiper {
			height: 62vh;
		}

		swiper-item {
			overflow: scroll;
		}
		.slander_left {
			width: 328rpx;
			text-overflow: ellipsis;
			white-space: nowrap;
			overflow: hidden
		}


	}

	.footer {
		width: 100%;
		background: #FFFFFF;
		box-shadow: 0rpx -6rpx 14rpx 0rpx rgba(177, 177, 177, 0.25);
		padding: 30rpx 32rpx;
	}

	.footer_button {
		display: flex;
		justify-content: space-between;
	}

	.button_ky {
		padding: 24rpx 52rpx;
		border-radius: 104rpx 104rpx 104rpx 104rpx;
		color: #2E4975;
		background-color: #FAFAFA;
	}

	.button_andadd {
		background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%);
		border-radius: 104rpx 104rpx 104rpx 104rpx;
		padding: 26rpx 125rpx;
		color: #fff;
	}

	.button_show {
		width: 100%;
		background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%);
		border-radius: 104rpx 104rpx 104rpx 104rpx;
		padding: 26rpx 125rpx;
		color: #fff;
		text-align: center;
	}

	.view_fff_bottom {
		margin-bottom: 54rpx;
	}

	.Task {
		font-size: 24rpx;
		font-weight: 500;
		color: #2E4975;
	}

	.view_left {
		display: flex;
		justify-content: left;
		margin-top: 20rpx;
	}

	.view_left_pd {
		position: relative;
		padding: 12rpx 32rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		margin-right: 15rpx;
		font-size: 24rpx;
	}

	.pull_Down {
		position: absolute;
		bottom: -130rpx;
		left: 50%;
		margin-left: -79rpx;
		box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0,0,0,0.25);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		background: #FFFFFF;
		border-bottom: 2rpx solid #F2F2F2;
		view {
			padding: 15rpx 50rpx;
			border-bottom: 2rpx solid #F2F2F2;
		}
	}
	.pull_DownTow{
	width: 150rpx;
	position: absolute;
	bottom: -133rpx;
	left: 50%;
	margin-left: -72rpx;
	box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0,0,0,0.25);
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	background: #FFFFFF;
	border-bottom: 2rpx solid #F2F2F2;
	text-align: center;
	view {
		padding: 15rpx 0rpx;
		border-bottom: 2rpx solid #F2F2F2;
	}
		
	}
	.pull_Down view:last-child {
		border: none;
	}

	.sl_body {
		background-color: #fff;
	}

	.footer_button_right {
		padding: 24rpx 62rpx;
		border: 1px solid #2D7CE6;
		border-radius: 104rpx 104rpx 104rpx 104rpx;
		color: #2D7CE6;
	}
</style>
