<template>
	<view class="container">
		<view class="top">
			<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()"></text>
			<text style="font-size: 30rpx;">我的售后</text>
		</view>
		<h4 class="noListTip" v-if="userCourses.length <=0 ">暂无售后</h4>
		<view class="ulBox" v-if="userCourses.length > 0">
			<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>
</template>

<script>
	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){
				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{
		height: 100%;
		.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{
			margin-top: 20rpx;
			.liBox{
				background-color: #fff;
				margin-bottom: 20rpx;
				padding: 36rpx 30rpx;
				.statusBox{
					display: flex;
					justify-content: space-between;
					text{
						color: #333;
						font-size: 32rpx;
						&:last-child{
							color: #666;
							font-size: 28rpx;
						}
					}
				}
			}
		}
	}
</style>
