<template>
	<view class="container">
		<!-- #ifdef APP -->
			<view class="top">
				<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()"></text>
				<text style="font-size: 30rpx;">我的售后</text>
			</view>
		<!-- #endif -->
		<h4 class="noListTip" v-if="userCourses.length <=0 ">暂无售后</h4>
		<view class="ulBox" v-if="userCourses.length > 0">
		<view class="conent">
			<view class="liBox" v-for="item in userCourses" :key="item.orderId">
				<course-item :thumbnailPath="item.displayImage" :title="item.fileTitle" :summaryBox="item.fileSynopsis" :dataList="{coursePrice:item.coursePrice,salesNumber:item.salesNumber}" :fileLecturerId="item.fileLecturerId"></course-item>
				<view class="statusBox">
					<text>{{item.orderStatusName}}</text>
					<text @click="goDetail(item)">查看详情</text>
				</view>
			</view>
		</view>
			
		</view>
	</view>
</template>

<script>
	import dataHandling from "@/util/dataHandling";
	import api from "@/api/api";
	import courseItem from "@/components/courseItem/courseItem.vue";
	export default {
		components:{
			courseItem
		},
		data() {
			return {
				userId: uni.getStorageSync('cffp_userId'),
				userCourses:[],
				afterSalesFlag:3
			};
		},
		methods:{
			goBack(){
				uni.navigateBack({  
					delta: 1  
				})
			},
			goDetail(item){
				dataHandling.pocessTracking(
				  '查看退款订单',
				  `点击订单详情，查看退款订单详情`,
				  '点击',
				  2,
				  '我的售后',
				  'pages/afterSales/afterSales'
				)
				uni.navigateTo({
					url:`/pages/afterSaleDetail/afterSaleDetail?orderNo=${item.orderNo}&afterSalesFlag=${this.afterSalesFlag}`
				})
			},
			userAfterSales(){
				const param = {
					userId:this.userId,
					afterSalesFlag:this.afterSalesFlag
				}
				api.userAfterSales(param).then(res=>{
					if(res['success']){
						this.userCourses = res['data']['userCourses']
					}
				})
			}
		},
		onLoad() {
			this.userAfterSales()
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		.noListTip{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			margin-top: 0%;
			padding-top: 20%;
		}
		.top{
			display: flex;
			height: 80rpx;
			justify-content: space-between;
			align-items: center;
			position: relative;
			width: 100%;
			margin: 0 auto;
			background: #fff;
			text:nth-child(2){
				width: 100%;
				text-align: center;
				position: absolute;
			}
		}
		.ulBox{
			box-sizing: border-box;
			padding: 20rpx 20rpx 5rpx 20rpx;
			.conent{
				border-radius: 10rpx;
			}
			.liBox{
				background-color: #fff;
				margin-bottom: 20rpx;
				padding: 36rpx 30rpx;
				border-radius: 10rpx;
				.statusBox{
					display: flex;
					justify-content: space-between;
					align-items: center;
					text{
						color: #333;
						font-size: 32rpx;
						&:last-child{
							background-color: #2A36AD;
							padding: 10rpx 20rpx;
							border-radius: 40rpx;
							color: #fff;
							font-size: 28rpx;
						}
					}
				}
			}
		}
	}
</style>
