<template>
	<view class="detail">
		<view v-for="item in orderDetail.goods" :key="item.id">
			<view class="title">
				<view class="title-left">
					<image class="header-img" :src="item.merchant.image" mode=""></image>
					<text>{{ item.merchant.merchant_name }}</text>
					<image class="right-325" src="../../../static/mine/325.png" mode=""></image>
				</view>
			</view>
			<view class="commodity-information">
				<view class="commodity-1">
					<image class="commodity-img" :src="item.sku_item.image" mode=""></image>
					<view class="" style="height: 180rpx;display: flex;flex-direction: column;justify-content: space-between;">
						<view class="">
							<view class="commodity-2">
								<view class="commodity-title">{{ item.goods_name }} </view>
								<view class="commodity-price">
									<text style="font-size: 20rpx">￥</text>
									<text>{{ item.discount_price.split(".")[0] }}</text>.
									<text style="font-size: 20rpx">{{
				        item.discount_price.split(".")[1]
				      }}</text>
								</view>
							</view>
							<view class="commodity-3">
								<view class="specifications"> {{ item.sku_item.item }} </view>
								<view style="font-size: 24rpx"> x{{ item.goods_num }} </view>
							</view>
						</view>
						<view v-if="orderDetail.simplify_status == 'finished'" class="" style="display: flex;justify-content: space-between;">
							<view class=""></view>
							<view @click="toping(item)" class="" style="border: #f83224 solid 2rpx;min-width: 80rpx;height: 40rpx;line-height: 40rpx;color: #f83224;border-radius: 20rpx;text-align: center;">  
								评价
							</view>
						</view>
					</view>
				</view>

				<view class="btn-list" v-if="
            orderDetail.simplify_status == 'paid' ||
            orderDetail.simplify_status == 'undelivered' ||
            orderDetail.simplify_status == 'unreview' ||
            orderDetail.simplify_status == 'merdelivered'
          ">
					<!-- status就是 状态 0未审核 1已通过 2未通过 3平台介入 -->
					<button @click="platformIntervene(item)" v-if="
              item.refund &&
              (item.refund.status == 2 ||
                item.refund.status == 0 ||
                item.refund.status == 3)
            ">
						平台介入
					</button>
					<button @click="toRefundDetail(item)" v-if="
              item.refund &&
              (item.refund.status == 0 ||
                item.refund.status == 1 ||
                item.refund.status == 2 ||
                item.refund.status == 3)
            ">
						退款详情
					</button>
					<button @click="application(item)" v-if="item.refund && item.refund.status == 2">
						继续申请
					</button>
					<button v-if="!item.refund" @click="application(item)">
						申请退款
					</button>
				</view>
			</view>
		</view>
		<view class="information">
			<text class="_label">商品总价</text>
			<view style="color: #222; font-weight: 600" v-if="orderDetail.freight">
				<text style="font-size: 20rpx">￥</text>
				<text>{{ orderDetail.goods_amount.split(".")[0] }}</text>.
				<text style="font-size: 20rpx">{{
          orderDetail.goods_amount.split(".")[1]
        }}</text>
			</view>
		</view>
		<view class="information">
			<text class="_label">商品总重量</text>
			<view class="_title-right"> {{ orderDetail.weight_total || 0 }}Kg </view>
		</view>
		<view class="information">
			<text class="_label">跨境物流</text>
			<view lass="_title-right">
				{{ orderDetail.container.transport_type.name_cn }} |
				{{ orderDetail.container.name_cn }}
			</view>
		</view>
		<view class="information last">
			<text class="_label">运费</text>
			<view style="color: #222; font-weight: 600" v-if="orderDetail.freight">
				<text style="font-size: 20rpx">￥</text>
				<text>{{ orderDetail.freight.split(".")[0] }}</text>.
				<text style="font-size: 20rpx">{{
          orderDetail.freight.split(".")[1]
        }}</text>
			</view>
		</view>
		<view class="_bottom">
			<text class="_label">应付款 </text>
			<view style="color: #f83224; margin-left: 10rpx; font-weight: 600" v-if="orderDetail.amount">
				<text style="font-size: 20rpx">￥</text>
				<text>{{ orderDetail.amount.split(".")[0] }}</text>.
				<text style="font-size: 20rpx">{{
          orderDetail.amount.split(".")[1]
        }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import textRight from "../../accountSecurity/component/textRight.vue";
	export default {
		components: {
			textRight,
		},
		props: {
			status: {
				typeof: Number,
				default: 0,
			},
			orderDetail: {
				typeof: Object,
				default: () => {
					return {};
				},
			},
		},
		data() {
			return {};
		},
		methods: {
			//评论
			toping(item){
				console.log(item);
				uni.navigateTo({
					url:'/pageD/evaluate/evaluate?goods='+JSON.stringify(item)
				})
			},
			//申请退款
			application(value) {
				uni.navigateTo({
					url: `/pageC/applicationRefund/applicationRefund?orderId=${value.id}`,
				});
			},

			//售后订单详情
			toRefundDetail(value) {
				uni.navigateTo({
					url: `/pageC/refundDetail/refundDetail?orderId=${value.refund.id}`,
				});
			},

			//申请平台介入
			platformIntervene(value) {
				if (value.refund.status != 3) {
					uni.$u.http
						.post(`/api/order_refund/platform_intervention`, {
							order_refund_id: value.refund.id,
						})
						.then((res) => {
							uni.showToast({
								title: "已申请平台介入",
								icon: "none",
							});
						});
				} else {
					uni.showToast({
						title: "平台已介入",
						icon: "none",
					});
				}
			},
		},
	};
</script>

<style scoped lang="scss">
	.detail {
		padding: 28rpx 20rpx;
		background-color: #fff;
		border-radius: 16rpx;
		margin-top: 28rpx;

		.title {
			display: flex;
			justify-content: space-between;
			margin-top: 20rpx;

			.title-left {
				display: flex;
				font-size: 32rpx;
				align-items: center;

				.header-img {
					width: 36rpx;
					height: 36rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.right-325 {
					width: 32rpx;
					height: 32rpx;
				}
			}

			.order-status {
				color: #f83224;
				font-size: 26rpx;
			}
		}

		.commodity-information {
			margin-top: 28rpx;

			.commodity-1 {
				display: flex;

				.commodity-img {
					width: 180rpx;
					height: 180rpx;
					margin-right: 20rpx;
					border-radius: 10rpx;
				}

				.commodity-2 {
					display: flex;
					justify-content: space-between;

					.commodity-title {
						width: 328rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						margin-right: 38rpx;
					}
				}

				.commodity-3 {
					display: flex;
					justify-content: space-between;
					margin-top: 20rpx;
					color: #777;

					.specifications {
						font-size: 28rpx;
						color: #777;
					}
				}
			}
		}

		.last {
			border-bottom: 2rpx solid rgba(151, 151, 151, 0.1);
			padding-bottom: 20rpx;
		}

		.btn-list {
			display: flex;
			justify-content: flex-end;

			button {
				width: 152rpx;
				height: 58rpx;
				border: 2rpx solid #979797;
				color: #444;
				margin: 0;
				padding: 0;
				font-size: 24rpx;
				background-color: #fff;
				border-radius: 34rpx;
				margin-top: 20rpx;
				margin-left: 20rpx;
			}
		}

		.information {
			display: flex;
			justify-content: space-between;
			font-size: 28rpx;
			align-items: flex-end;
			margin: 34rpx 0;

			._label {
				font-size: 28rpx;
				color: #333;
			}

			._title-right {
				font-size: 28rpx;
				color: #333;
			}
		}

		._bottom {
			display: flex;
			justify-content: flex-end;
			font-size: 28rpx;
			align-items: flex-end;
			margin-top: 34rpx;
		}
	}
</style>