<template>
	<view class="container">
		<!-- 禁用弹窗 -->
			 <restrictedTip ref="restrictedTip"/>
		<!-- #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";
	import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
	import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
	export default {
		components:{
			courseItem,
			restrictedTip,
		},
		data() {
			return {
				userId: uni.getStorageSync('cffp_userId'),
				userCourses:[],
				afterSalesFlag:3
			};
		},
		methods:{
			queryInfo() {
							api.queryInfo({userId:uni.getStorageSync('cffp_userId')}).then(res=>{
								// 保存用户得个人信息
								if (res['success']) {
									delete res.data.commonResult
									
									const cffp_userInfo = {
										...res.data
									}
									// 账号禁用用户
									if(res.data.userIsActive&&res.data.userIsActive==2){
										this.$refs.restrictedTip.open()
										uni.setStorageSync('userIsActive',String(res.data.userIsActive))
										return
									}
									if(res.data.userIsActive&&res.data.userIsActive!=2){
										this.$refs.restrictedTip.close()
										uni.removeStorageSync('userIsActive')
									}
									
									uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo));
									uni.setStorageSync('user_mobile', res.data.mobile)
									
								}
								
							})
						},
			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()
		},
		onShow() {
			if(uni.getStorageSync('loginType')=='codelogin'){
							this.queryInfo()
						}
			// #ifdef H5
						initJssdkShare(() => {
						  setWechatShare();
						}, window.location.href);
						// #endif
		},
	}
</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>
