<template>
	<view class="">
		 <view class="zxkjyr" style="padding: 0  42rpx;padding-top: 12rpx;">
			 
		 	<view :class="['zxkjyra',Inv==0?'zxkjyrff':'']" @click="Inv=0">
		 		<text>直播课程</text>
		 		<view class="zxkjxh"></view>
		 	</view>
			
			<view :class="['zxkjyra',Inv==1?'zxkjyrff':'']" @click="Inv=1">
				<text>录制课程</text>
				<view class="zxkjxh"></view>
			</view>
			
		 	<view :class="['zxkjyra',Inv==2?'zxkjyrff':'']" @click="Inv=2">
		 		<text>下架课程</text>
		 		<view class="zxkjxh"></view>
		 	</view>
			
		 </view>
		 
		<view class=" ">
			<view style="margin-top: 30rpx;">
				<view class="fsxto sclixmy" v-for="(item,index) in list" :key="index">
					<view class="fzctob">
						<view class="sckjert" style="overflow: hidden;">
							<image :src="item.img" mode="aspectFill" style="width: 100%; height: 100%;"></image>
						</view>
						<view class="fsxto" style="width: 100%;margin-left: 24rpx;">
							<view class="cphrry"><text>{{item.title}}</text></view>
                            <!--  -->
							<view class="cptxtyra" style="margin-bottom: 10rpx;"><text>{{item.type_title}}</text></view>
							<view class="fzctob kcwwerrt">
								<text>{{lecturer_name}}</text>
							</view>
						</view>
					</view>
					<view style="border-top: 2rpx dashed #e8e8e8;width: 107%;margin-left: -24rpx;margin-top: 22rpx;"></view>
					<view class="flztoa" style="margin-top: 26rpx;">
						<view class="fzctob">
							<text class="wdjga">¥</text>
							<text class="wdjgb">{{item.price}}</text>
							<!-- <text class="wdjgc">.00</text> -->
							<!-- <text class="scjga">原价¥{{item.line_price}}</text> -->
						</view>
						<!-- <navigator class="kcdrry" url="../lecturer/wdkc-zhixj" hover-class="none">
							<image src="/static/lecturer/wdkca1.png" style="width: 136rpx;min-width: 136rpx;height: 50rpx;" mode=""></image>
						</navigator> -->
						<!-- #ifdef APP-PLUS -->
						<view class="toLive" @click="toLive(item)" v-if="Inv==0">
							去直播
						</view>
						<!-- #endif -->
							
							            <view class="kcdrry" @click="unshelfCourse(item.id)">
								<image v-if="Inv!=2" src="/static/lecturer/wdkca1.png" style="width: 136rpx;min-width: 136rpx;height: 50rpx;" mode=""></image>
							                <image v-if="Inv==2" src="/static/lecturer/wdkca2.png" style="width: 136rpx;min-width: 136rpx;height: 50rpx;" mode=""></image>
							</view>
						
					</view>
				</view>
				
			</view>
 
		</view>
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	export default {
		data() {
			return {
 
				Inv: 0,
                list:[],
                course:[],
                fail_live:[],
                live:[],
                lecturer_name:''
			}
		},
        onLoad() {
            this.getList()
        },
        watch:{
            Inv(val){
                if(val==0){
                    this.list = this.live
                } else if(val==1){
                    this.list = this.course
                } else if(val==2){
                    this.list = this.fail_live
                }
            }
        },
		methods: {
            // 课程列表
            getList(){
                this.$post({
                    data:{
                        do:'MyCourseList',
                        data:{
                            user_id:uni.getStorageSync('id')
                        }
                    }
                }).then(res=>{
                    console.log(res,'rrrrrrrrrrrrr')
                    this.course = res.data.course
                    this.fail_live = res.data.fail_live
                    this.live = res.data.live
                    this.lecturer_name = res.data.lecturer_name
                    if(this.Inv==0){
                        this.list = this.live
                    } else if(this.Inv==1){
                        this.list = this.course
                    } else if(this.Inv==2){
                        this.list = this.fail_live
                    }
                })
            },
						// 去直播
						toLive(item){
							uni.navigateTo({
								url:'/pages/lecturer/Live?chapter_id='+item.chapter_id
							})
						},
            // 上下架课程
            unshelfCourse(id){
               uni.showModal({
                   title:'提示',
                   content:this.Inv==2?'确定要上架该课程吗？':'确定要下架该课程吗？',
                   success: (res) => {
                       if(res.confirm){
                           console.log({
                                  do:'TakeDown',
                                  data:{
                                       user_id:uni.getStorageSync('id'),
                                       id,
                                       state:this.Inv==2?1:0
                                  }
                              })
                          this.$post({
                              data:{
                                  do:'TakeDown',
                                  data:{
                                       user_id:uni.getStorageSync('id'),
                                       id,
                                       state:this.Inv==2?1:0
                                  }
                              }
                          }).then(res=>{
                              uni.showToast({
                                  title:this.Inv==2?'上架成功':'下架成功',
                                  icon:'none',
                                  mask:true
                              })
                              setTimeout(()=>{
                                  this.getList()
                              },1500)
                              console.log(res)
                          }) 
                       }
                   }
               })
            }
		
		}


	}
</script>

<style lang="scss" scoped>
	  .toLive{
			height: 45rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #405375;
			padding: 10rpx 20rpx;
			border: 1rpx solid #405375;
			border-radius: 25rpx;
		}
	 
	 
</style>
