<!--
 * @Author: ch
 * @Date: 2022-03-31 14:26:09
 * @LastEditors: ch
 * @LastEditTime: 2022-04-24 11:06:05
 * @Description: file content
-->
<template>
	<view>
		<!-- 头部状态信息 -->
		<StatusTips :data="orderInfo"/>

		<!-- 等待商家通过审核时显示 -->
		<AwaitExamine :data="orderInfo" v-if="orderInfo.refundStatus == 1" @reload="getOrderInfo" />

		<!-- 商家通过，但需要填写物流信息时显示 -->
		<SubmitLogistics :data="orderInfo" v-if="orderInfo.refundStatus == 3" :company="logisticsCompany" @reload="getOrderInfo" />
		
		<!-- 退款完成时显示 -->
		<LogisticsInfo :data="orderInfo.refundLogistics" v-if="[4,5,6].includes(orderInfo.refundStatus) && orderInfo.refundLogistics"/>

		<!-- 退款订单信息 -->
		<GoodsInfo :data="orderInfo"/>
	</view>
</template>
<script>
import {ApiGetSaleAfterOrderDetail, ApiGetLogisticsCompanylist} from '@/common/api/order'
import UiPageHeader from '@/components/UiPageHeader.vue'
import UiGoodsInfo from '@/components/UiGoodsInfo.vue'
import UiWhiteBox from '@/components/UiWhiteBox.vue'
import UiButton from '@/components/UiButton.vue'
import StatusTips from './components/StatusTips.vue'
import UiCell from '@/components/UiCell.vue'
import GoodsInfo from './components/GoodsInfo.vue'
import AwaitExamine from './components/AwaitExamine.vue'
import SubmitLogistics from './components/SubmitLogistics.vue'
import LogisticsInfo from './components/LogisticsInfo.vue'
export default {
	components: { UiPageHeader, UiGoodsInfo, UiWhiteBox, UiButton, StatusTips, UiCell, GoodsInfo, AwaitExamine, SubmitLogistics, LogisticsInfo },
	data(){
		return {
			orderInfo : {
				refundProduct:{}
				
			},
			logisticsCompany : []
		}
	},
	onLoad(){
		this.getOrderInfo();
	},
	methods : {
		/**
		 * 获取订单最新信息
		 */
		async getOrderInfo(){
			const refundId = this.$Route.query.id;
			const orderProductId = this.$Route.query.orderProductId;
			const {error, result} = await ApiGetSaleAfterOrderDetail({refundId,orderProductId});
			if(error){
				uni.$u.toast(error.message);
				return false;
			}
			if(result.refundLogistics){
				result.refundLogistics.completeReturnRemark = result.completeReturnRemark;
			}
			this.orderInfo = {...result};

			// 需要填写物流信息是查询物流公司列表
			if(result.refundStatus == 3){
				this.getLogisticsCompanyList()
			}
		},
		async getLogisticsCompanyList(){
			const {error, result} = await ApiGetLogisticsCompanylist();
			if(error){
				uni.$u.toast(error.message);
				return false;
			}
			this.logisticsCompany = [result]
		}
		
	}
	
}
</script>
<style lang="scss" scoped>

page{
	background: $color-grey1;
	padding-bottom: 120rpx;
}
</style>