<template>
	<view :class="[AppTheme]" class="content" v-if="orderList">
		<view class="detail-c">
			<view class="mb20">
				<text class="mr10">订单状态 :{{ orderList.status==0?'已取消':orderList.status==1?'待付款':orderList.status==2?'待发货':orderList.status==3?'待收货':orderList.status==4?'退货中':
				orderList.status==9?'未成团':orderList.status==6?'已关闭':orderList.status==10?'退款中':orderList.status==7?'退货完成':orderList.status==5?'交易完成':orderList.status==8?'满七天订单':''}}</text>
				<text>{{ orderList.name }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">实付总额 :</text>
				<text>{{ orderList.payprice }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">订单编号 :</text>
				<text>{{ orderList.oid || 0 }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">创建时间 :</text>
				<text> {{ $u.timeFormat(orderList.ctime,fmt = 'yyyy.mm.dd hh:MM:ss') || 0 }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">收件人 :</text>
				<text>{{ orderList.vipname || 0 }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">联系方式 :</text>
				<text>{{ orderList.vipmobile || 0 }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">收货地址 :</text>
				<text>{{ orderList.vipaddress || 0 }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">邮费 :</text>
				<text>{{ orderList.yf || 0 }}</text>
			</view>
			<view class="mb20">
				<text class="mr10">代金券 :</text>
				<text>{{ orderList.djqmoney || 0 }}</text> 
			</view>
			<view class="mb20">
				<text class="mr10">备注 :{{ orderList.msg || '' }}</text>
				<text></text>
			</view>
			<view class="mb20" v-for="(item,index) in log" :key="index"><text class="mr10">订单进度: {{  $u.timeFormat(item.ctime,fmt = 'yyyy/mm/dd hh:MM:ss')  || 0 }} {{ item.msg }}</text></view>
		</view>

		<view class="order-item">
			<view class="i-top b-b">
				<text class="time">订单编号:{{ orderList.oid }}</text>
			</view>

			<scroll-view v-if="orderList.items&&orderList.items.length > 1" class="goods-box" scroll-x>
				<view v-for="(goodsItem, goodsIndex) in orderList.items" :key="goodsIndex" class="goods-item">
					<image class="goods-img" :src=" goodsItem.pic" mode="aspectFill"></image>
				</view>
			</scroll-view>
			<view v-if="orderList.items.length === 1" class="goods-box-single" v-for="(goodsItem, goodsIndex) in orderList.items" :key="goodsIndex">
				<image class="goods-img" :src=" goodsItem.pic" mode="aspectFill"></image>
				<view class="right">
					<text class="title clamp">{{ goodsItem.name }}</text>
					<text class="attr-box">x {{ goodsItem.num }}</text>
					<text class="price text-neutral">{{ goodsItem.price }}</text>
				</view>
			</view>
			<view class="price-box">
				共
				<text class="num">{{ orderList.totalnum }}</text>
				件商品 
				运费<text class="num price text-neutral">{{ orderList.yf }}</text>
				实付款
				<text class="price text-neutral">{{ Number(orderList.payprice) }}</text>
			</view>
		</view>
	</view>
</template>

<script>
import order from '@/api/order/index.js';
export default {
	data() {
		return {
			primary:this.$theme.primary,
			info: {},
			settingFile:getApp().globalData.siteinfo,
			tabCurrentIndex: 0,
			orderList: {},
			log:[],
		};
	},

	onLoad(options) {
		this.getOrderDetail(options.sid, options.id);
	},
	methods: {
		getOrderDetail(sid, id) {
			order
				.orderDetail({
					sid: sid,
					orderid: id
				})
				.then(res => {
					if (res.status == 200) {
						this.orderList = res.data.cache;
						this.log =  res.data.log;
					}
				});
		}
	}
};
</script>

<style lang="scss">
page,
.content {
	background: $page-color-base;
	height: 100%;
}

.swiper-box {
	height: calc(100% - 40px);
}
.list-scroll-content {
	height: 100%;
}

.uni-swiper-item {
	height: auto;	
}
.f-tui{
	width: 100%;
	min-height: 270rpx;
	background: #fff;
	margin-top: 16rpx;
	padding-left: 30rpx;
	padding-bottom:  30rpx;
}
.tui-btn{
    position: relative;
    left: 520rpx;
    width: 151rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 7rpx;	
    border: 1px solid $tab-color-2;
	margin-top: 20rpx;
	background: $tab-color;
	box-shadow: 1px 2px 5px $tab-color-2;
	color: #fff;
}
.detail-c {
	margin: 0 auto;
	background-color: #ffffff;
	padding: 27rpx;
	font-size: 28rpx;
	color: #999;
	.mb20 {
		line-height: 40rpx;
		margin-bottom: 20rpx;
		.mr10 {
			margin-right: 20rpx;
		}
		.ml10 {
			margin-left: 20rpx;
		}
	}
	.flex {
		display: flex;
		justify-content: space-between;
	}
}

.i-top {
		display: flex;
		align-items: center;
		height: 80upx;
		padding-right: 30upx;
		font-size: $font-base;
		color: $font-color-dark;
		position: relative;
		.time {
			flex: 1;
			flex-grow: 1;
		}
		.state {
			color: $base-color;
		}
		.del-btn {
			padding: 10upx 0 10upx 36upx;
			font-size: $font-lg;
			color: $font-color-light;
			position: relative;
			&:after {
				content: '';
				width: 0;
				height: 30upx;
				border-left: 1px solid $border-color-dark;
				position: absolute;
				left: 20upx;
				top: 50%;
				transform: translateY(-50%);
			}
		}
	}
.order-item {
	display: flex;
	flex-direction: column;
	padding-left: 30upx;
	background: #fff;
	margin-top: 16upx;
	/* 多条商品 */
	.goods-box {
		height: 160upx;
		padding: 20upx 0;
		white-space: nowrap;
		.goods-item {
			width: 120upx;
			height: 120upx;
			display: inline-block;
			margin-right: 24upx;
		}
		.goods-img {
			display: block;
			width: 100%;
			height: 100%;
		}
	}
	/* 单条商品 */
	.goods-box-single {
		display: flex;
		padding: 20upx 0;
		.goods-img {
			display: block;
			width: 120upx;
			height: 120upx;
		}
		.right {
			flex: 1;
			display: flex;
			flex-direction: column;
			padding: 0 30upx 0 24upx;
			overflow: hidden;
			.title {
				font-size: $font-base + 2upx;
				color: $font-color-dark;
				line-height: 40rpx;
				height: 40rpx;
			}
			.attr-box {
				font-size: $font-sm + 2upx;
				color: $font-color-light;
				padding: 10upx 12upx;
			}
			.price {
				font-size: $font-base + 2upx;
				&:before {
					content: '￥';
					font-size: $font-sm;
					margin: 0 2upx 0 8upx;
				}
			}
		}
	}

	.price-box {
		display: flex;
		justify-content: flex-end;
		align-items: baseline;
		padding: 20upx 30upx;
		font-size: $font-sm + 2upx;
		color: $font-color-light;
		.num {
			margin: 0 8upx;
		}
		.price {
			font-size: $font-lg;
			&:before {
				content: '￥';
				font-size: $font-sm;
				margin: 0 2upx 0 8upx;
			}
		}
	}
	.action-box {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		height: 100upx;
		position: relative;
		padding-right: 30upx;
	}
	.action-btn {
		width: 160upx;
		height: 60upx;
		margin: 0;
		margin-left: 24upx;
		padding: 0;
		text-align: center;
		line-height: 60upx;
		font-size: $font-sm + 2upx;
		color: $font-color-dark;
		background: #fff;
		border-radius: 100px;
		&:after {
			border-radius: 100px;
		}
		&.recom {
			background: #fff9f9;
			color: $base-color;
			&:after {
				border-color: #f7bcc8;
			}
		}
	}
}

/* load-more */
.uni-load-more {
	display: flex;
	flex-direction: row;
	height: 80upx;
	align-items: center;
	justify-content: center;
}

.uni-load-more__text {
	font-size: 28upx;
	color: #999;
}

.uni-load-more__img {
	height: 24px;
	width: 24px;
	margin-right: 10px;
}

.uni-load-more__img > view {
	position: absolute;
}

.uni-load-more__img > view view {
	width: 6px;
	height: 2px;
	border-top-left-radius: 1px;
	border-bottom-left-radius: 1px;
	background: #999;
	position: absolute;
	opacity: 0.2;
	transform-origin: 50%;
	animation: load 1.56s ease infinite;
}

.uni-load-more__img > view view:nth-child(1) {
	transform: rotate(90deg);
	top: 2px;
	left: 9px;
}

.uni-load-more__img > view view:nth-child(2) {
	transform: rotate(180deg);
	top: 11px;
	right: 0;
}

.uni-load-more__img > view view:nth-child(3) {
	transform: rotate(270deg);
	bottom: 2px;
	left: 9px;
}

.uni-load-more__img > view view:nth-child(4) {
	top: 11px;
	left: 0;
}

.load1,
.load2,
.load3 {
	height: 24px;
	width: 24px;
}

.load2 {
	transform: rotate(30deg);
}

.load3 {
	transform: rotate(60deg);
}

.load1 view:nth-child(1) {
	animation-delay: 0s;
}

.load2 view:nth-child(1) {
	animation-delay: 0.13s;
}

.load3 view:nth-child(1) {
	animation-delay: 0.26s;
}

.load1 view:nth-child(2) {
	animation-delay: 0.39s;
}

.load2 view:nth-child(2) {
	animation-delay: 0.52s;
}

.load3 view:nth-child(2) {
	animation-delay: 0.65s;
}

.load1 view:nth-child(3) {
	animation-delay: 0.78s;
}

.load2 view:nth-child(3) {
	animation-delay: 0.91s;
}

.load3 view:nth-child(3) {
	animation-delay: 1.04s;
}

.load1 view:nth-child(4) {
	animation-delay: 1.17s;
}

.load2 view:nth-child(4) {
	animation-delay: 1.3s;
}

.load3 view:nth-child(4) {
	animation-delay: 1.43s;
}

@-webkit-keyframes load {
	0% {
		opacity: 1;
	}

	100% {
		opacity: 0.2;
	}
}
</style>
