<template>
	<view>
		<view class="box-nav">
			<image style="width: 100%;" src="https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/%E9%A6%96%E9%A1%B5_20230830213855.png"></image>
			<view class="center-box flex jc-sb ai-c">
				<view class="box-item flex ai-c jc-c">
					<view class="flex jc-c ai-c relative" style="width: 230rpx;height: 230rpx;" @tap="toAnswer('顺序答题',false)">
						<image style="width: 230rpx;height: 230rpx;position: absolute;left: 0;top: 0;" src="../../../static/image/index/green_bg.png"></image>
							<view class="btn-item flex ai-c jc-c">
								<view class="text-center cor-fff" style="line-height: 40rpx;">
									<view class="fs16">顺序练习</view>
									<text class="fs14">{{getDoNum}}/{{subject=='1'?orderQuestion_subject1.length:orderQuestion_subject4.length}}</text>
								</view>
							</view>
					</view>
				</view>
				<view class="box-item flex ai-c jc-c">
					<view class="flex jc-c ai-c relative" style="width: 230rpx;height: 230rpx;" @tap="toExams('title=模拟考试')">
						<image style="width: 230rpx;height: 230rpx;position: absolute;left: 0;top: 0;" src="../../../static/image/index/orange_bg.png"></image>
							<view class="btn2-item flex ai-c jc-c">
								<view class="text-center cor-fff" style="line-height: 40rpx;">
									<view class="fs16">模拟考试</view>
									<text class="fs14">去考试</text>
								</view>
							</view>
					</view>
				</view>
			</view>
		</view>
		<view style="padding: 0 28rpx;margin-top: calc(100% - 718rpx);">
			<view class="tabs-box">
				<view class="wp33 flex ai-c jc-c" @tap="toVip">
					<view class="text-center wp100">
						<image style="width: 72rpx;height: 72rpx;margin: 0 auto"
							src="../../static/image/index/vipicon.png">
						</image>
						<view class="mt5">VIP课程</view>
					</view>
				</view>
				<view class="wp33 flex ai-c jc-c"  @tap="toAnswer('精简500题',true)">
					<view class="text-center wp100">
						<image style="width: 72rpx;height: 72rpx;margin: 0 auto"
							src="../../static/image/index/500icon.png">
						</image>
						<view class="mt5">精简500题</view>
					</view>
				</view>
				<view class="wp33 flex ai-c jc-c" @tap="toExclusive">
					<view class="text-center wp100">
						<image style="width: 72rpx;height: 72rpx;margin: 0 auto"
							src="../../static/image/index/zxicon.png">
						</image>
						<view class="mt5">专项练习</view>
					</view>
				</view>
				<view class="wp33 flex ai-c jc-c" @tap="toTestRoom">
					<view class="text-center wp100">
						<image style="width: 72rpx;height: 72rpx;margin: 0 auto;"
							src="../../static/image/index/realicon.png"></image>
						<view class="mt5">真实考场模拟</view>
					</view>
				</view>
				<view class="wp33 flex ai-c jc-c" @tap="toExams('title=考前密卷&isExam1=1')">
					<view class="text-center wp100">
						<image style="width: 72rpx;height: 72rpx;margin: 0 auto"
							src="../../static/image/index/testbeforeicon.png"></image>
						<view class="mt5">考前密卷</view>
					</view>
				</view>
				<view class="wp33 flex ai-c jc-c" @tap="toWrongList">
					<view class="text-center wp100">
						<image style="width: 72rpx;height: 72rpx;margin: 0 auto"
							src="../../static/image/index/worryicon.png"></image>
						<view class="mt5">错题收藏</view>
					</view>
				</view>
			</view>
		</view>
		<view style="padding: 0 28rpx;margin-top: 30rpx;" @tap="toClass">
			<view class="video-box">
				<view class="flex jc-sb ai-c wp100">
					<text style="color: #05C341;font-size: 36rpx;">科{{subject==1?'一':'四'}}精品视频课</text>
					<text class="cor-666 fs12">全部10节课 ></text>
				</view>
				<view class="flex ai-c mt20">
					<view class="contain-box relative">
						<image class="contain-box" src="../../../static/image/index/jpsp.png"></image>
						<image class="play_btn_2" src="../../static/image/index/play.png" />
					</view>
					<view class="ml15 text-center">
						<u-button :customStyle="{width:'200rpx',height:'66rpx',borderRadius: '33rpx'}" iconColor="#fff"
							text="去看视频" color="linear-gradient(90deg, #11DF20 0%, #00B74F 100%)" icon="play-circle">
						</u-button>
						<view class="cor-333 fs15 fw600 mt10">科{{subject==1?'一':'四'}}易错试题</view>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import { mapState,mapActions } from 'pinia' //引入映射函数
	import useUserStore from '@/jtools/store/user'
	import storage from '@/jtools/storage';
	import useQuestionStore from '@/jtools/store/question' //引入store
	export default {
		props:{
			subject:{
				type:[String,Number],
			},
			rightList:{
				type:Array
			},
			wrongList:{
				type:Array
			}
		},
		data() {
			return {
				allQuestionNum:0,
			}
		},
		mounted(){

		},
		computed: {
			...mapState(useUserStore, ["vipOnList", "token"]),
			...mapState(useQuestionStore, ["orderQuestion_subject1","orderQuestion_subject4"]) ,//映射函数，取出tagslist
			getDoNum(){
				return this.rightList.length+this.wrongList.length
			}
		},
		methods: {
			...mapActions(useUserStore, ['searchUserVip']),
			async toTestRoom(){
				// uni.navigateTo({
				// 	url:"/pages/index/trueTest"
				// })
				if (this.token) {
					await this.searchUserVip()
					const res = this.vipOnList.some(item => item.subjects == this.subject)
					if (!res) {
						uni.navigateTo({
							url:"/pages/index/videoVip?subject="+this.subject
						})
					}else{
						uni.navigateTo({
							url: "/pages/index/trueTest?subject="+this.subject
						})
					}
				} else {
					uni.redirectTo({
						url: '/pages/login/login'
					});
				}
			},
			toVip(){
				// if(storage.get('token')){
				// 	uni.navigateTo({
				// 		url:"/pages/index/videoVip?subject="+this.subject
				// 	})
				// }else{
				// 	uni.navigateTo({
				// 		url:'/pages/login/login'
				// 	})
				// }
				uni.showToast({
					title:'敬请期待',
					icon:'none'
				})
			},
			toClass(){
				uni.showToast({
					title:'敬请期待',
					icon:'none'
				})
			},
			toAnswer(title,val) {
				if(title=='精简500题'){
					uni.navigateTo({
						url:"/pages/questionBank/questionBank?navTitle="+title+"&subject="+this.subject+"&needVip="+val+"&isVip=1"
					})
				}else{
					uni.navigateTo({
						url:"/pages/questionBank/questionBank?navTitle="+title+"&subject="+this.subject+"&needVip="+val
					})
				}
			},
			toExams(val){
				if(storage.get('token')){
					uni.navigateTo({
						url:"/pages/questionBank/practiceExams?subject="+this.subject+'&'+val
					})
				}else{
					uni.navigateTo({
						url:'/pages/login/login'
					})
				}
			},
			toExclusive(){
				uni.navigateTo({
					url:"/pages/questionBank/exclusiveExercise?subject="+this.subject
				})
			},
			toWrongList(){
				uni.navigateTo({
					url:"/pages/questionBank/wrongQuestion?subject="+this.subject
				})
			}
		}
	}
</script>

<style scoped>
	.box-nav {
		width: 100%;
		position: relative;
		height: 500rpx;
	}

	.center-box {
		position: absolute;
		width: 100%;
		top: 170rpx;
		padding: 0 28rpx;
	}

	.box-item {
		width: 336rpx;
		height: 336rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		z-index: 999;
	}

	.btn-item {
		width: 193rpx;
		height: 193rpx;
		background: linear-gradient(0deg, #11DF20 0%, #00B74F 100%);
		border-radius: 50%;
	}

	.btn2-item {
		width: 193rpx;
		height: 193rpx;
		background: linear-gradient(0deg, #E95A0E 0%, #FF9600 100%);
		border-radius: 50%;
	}

	::v-deep .u-tabs__wrapper__nav__line {
		background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%) !important;
		bottom: 14rpx !important;
	}

	.tabs-box {
		width: 694rpx;
		height: 366rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		flex-wrap: wrap;
	}

	.video-box {
		padding: 20rpx;
		width: 694rpx;
		height: 369rpx;
		background: #DEEFE5;
		border: 2px solid #47DB87;
		border-radius: 16rpx;
	}

	.contain-box {
		width: 406rpx;
		height: 228rpx;
		background: #00B74F;
		border-radius: 16rpx;
	}
	.play_btn_2 {
		width: 65rpx;
		height: 65rpx;
		position: absolute;
		left: 165.5rpx;
		top: 78rpx
	}
</style>
