<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 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 style="width: 100%; height: 100%;" :src="item.good_data.img" mode="aspectFill"></image>
						</view>
						<view class="fsxto" style="width: 100%;margin-left: 24rpx;">
							<view class="cphrry"><text>{{item.good_data.title}}</text></view>
							<view class="cptxtyra"><text>课程讲师</text></view>
							<view class="flztoa">
								 <text class="cpkkry">数量: {{item.people.length}}</text>
								 <text class="cpkkrya">总价￥{{item.reality_price}}</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="hdtyyr">
							<text>下单时间：{{item.time1}}</text>
						</view>
						<view class="hdtyyra" v-show="Inv==0">
							<text>进行中</text>
						</view>
                        <view class="fyctoc" v-show="Inv==1" @click="toRefund(item.id,item.reality_price)">
                        	<view class="hdtyyra">
                        		<text>去请假</text>
                        	</view>
                        	<view class="hdtyyra">
                        		<text>去退出</text>
                        	</view>
                        </view>
                        <view class="hdtyyra" v-show="Inv==2">
                        	<text>已结束</text>
                        </view>
					</view>
				</view>
			</view>		 
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	export default {
		data() {
			return {
				Inv: 0,
                page:1,
                num:20,
                type:2,
                total:0,
                list:[]
			}
		},
        onLoad() {
          this.getList()  
        },
        watch:{
            Inv(val){
                switch(val/1){
                    case 0:
                        this.type = 3
                    break;
                    case 1:
                        this.type = 2
                    break;
                    case 2:
                        this.type = 4
                    break;
                }
                this.page = 1
                this.getList()
            }
        },
        onReachBottom() {
          if(this.list.length<this.total){
              this.page++
              this.getList()
          }  
        },
		methods: {
            // 获取参加列表
            getList(){
                this.$post({
                    data:{
                        do:'MyGoodOrder',
                        data:{
                            page:this.page,
                            num:this.num,
                            type:this.type,   // 类型:2=未开始3=进行中4=结束
                            // type:1,   // 类型:2=未开始3=进行中4=结束
                            user_id:uni.getStorageSync('id'),
                            pw:375,
                        }
                    }
                }).then(res=>{
                    this.total = res.data.total
                    if(res.data.list.length){
                        this.list = this.page==1?res.data.list:[...this.list,...res.data.list]
                    }else{
                        this.list = []
                    }
                }).catch(()=>{
                    this.list = []
                })
            },
            // 退出 退款
            toRefund(order_id,price){
                // 订单id  僵尸id  金额
                uni.navigateTo({
                    url:'/pages/user/wdhd-tc?order_id=' + order_id +'&price=' + price
                })
            }
		}
	}
</script>

<style lang="scss" scoped>
 
	 
</style>
