<template>
	<view class="container">
		<image class="cbg" :src="base.imgHost('common_bg.png')"></image>
		<view class="wrap">
			<view class="wrap-title">
				<text v-if="info.course.year">{{info.course.year+'年'}}</text>
				<text v-if="info.course.type">{{info.course.type_detail?info.course.type_detail.name+' | ':''}}</text>
				{{info.course?info.course.name:''}}
			</view>
			<view class="wrap-btn">
				<image @click="toUrl(1)" :src="base.imgHost('mycourse-icon1.png')"></image>
				<block v-if="info.course">
					<image v-if="info.course.show_txl===1" @click="toUrl(2)" :src="base.imgHost('mycourse-icon2.png')"></image>
					
					<image v-if="info.course.is_arrange===1" @click="toUrl(3)" :src="base.imgHost('mycourse-icon3.png')"></image>
					<image v-if="info.course.is_fee===1" @click="toUrl(4)" :src="base.imgHost('mycourse-icon4.png')"></image>
				</block>
			</view>

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

<script>
	export default {
		components: {
		},
		data() {
			return {
				course_id:'',
				info:''
			}
		},
		onLoad(options) {
			this.course_id = options.id
			this.getCourseDetail(options.id)
		},
		onShow() {
		},
		methods:{
			async toUrl(type){
				const res = await this.$u.api.courseGetSign({
					course_id: this.course_id
				})
				this.info = res.detail
				if(type===1){
					uni.navigateTo({
						url:'/packages/mycourse/courseStatus?id='+this.course_id
					})
				}else if(type===2){
					if(this.info.status===0){
						this.base.toast("请等待审核通过")
						return
					}
					// 需要缴费
					if(this.info.course.is_fee===1){
						// if(this.info.status>1 || this.info.fee_status!=1){
						// 	this.base.toast("您还没有权限查看本班通讯录")
						// 	return
						// }
					}else{
						if(this.info.status>1){
							this.base.toast("您还没有权限查看本班通讯录")
							return
						}
					}
					console.log("detail-mobile",this.info.course.show_mobile)
					// return
					uni.navigateTo({
						url:'/packages/mycourse/courseTxl?id='+this.course_id+"&show_mobile="+this.info.course.show_mobile
					})
				}else if(type===3){
					if(this.info.course.is_arrange!=1){
						this.base.toast("当前课程没有课表")
						return
					}
					if(this.info.status===0){
						this.base.toast("请等待审核通过")
						return
					}
					// 需要缴费
					if(this.info.course.is_fee===1){
						if(this.info.status>1 || this.info.fee_status!=1){
							this.base.toast("您还没有权限查看本班课表")
							return
						}
					}else{
						if(this.info.status>1){
							this.base.toast("您还没有权限查看本班课表")
							return
						}
					}
					uni.navigateTo({
						url:'/packages/mycourse/courseContents?id='+this.course_id
					})
				}else if(type===4){
					if(this.info.course.is_fee!=1){
						this.base.toast("当前课程无需缴费")
						return
					}
					if(this.info.status===0){
						this.base.toast("请等待审核通过")
						return
					}
					if(this.info.status>1){
						this.base.toast("您无需上传缴费信息")
						return
					}
					uni.navigateTo({
						url:'/packages/mycourse/coursePay?id='+this.course_id
					})
				}
			},
			async getCourseDetail(id) {
				const res = await this.$u.api.courseGetSign({
					course_id: id
				})
				this.info = res.detail
			},
		}

	}
</script>

<style scoped lang="scss">
	.container{
		padding: 30rpx;
		width:100%;
		height:100vh;
		.cbg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100vh;
		}
		.wrap{
			position: relative;
			height:100%;
			&-title{
				color:32rpx;
				font-size: 32rpx;
				text-align: center;
				padding:120rpx 0;
			}
			&-btn{
				display: flex;
				align-items: center;
				justify-content: space-between;
				flex-wrap: wrap;
				padding:0 35rpx;
				image{
					width:280rpx;
					height:195rpx;
					margin-bottom:35rpx;
				}
			}
		}
	}
		

</style>