<template>
	<view class="order-item">
		<view class="order-title">
			<view class="store-info">
				<image :src="order.store_avatar"></image>
				<view class="store-name">{{ order.store_name }}</view>
			</view>
			<view class="order-status">{{ state }}</view>
		</view>
		<view class="goods-info">
			<view class="goods-item">
				<image :src="order.goods_image"></image>
				<view class="goods-text">
					<view class="goods-name u-line-2">{{ order.goods_name }}</view>
					<!-- <view class="goods-sku u-line-1" v-if="order.order_state !== 20 && order.order_state !== 40 && goods.goods_spec">
						<text v-for="(spec, index) in goods.goods_spec" :key="index">{{ spec + ';' }}</text>
					</view> -->
					<!-- <view class="goods-time u-line-1" v-if="order.order_state == 10 || order.order_state == 10">结束时间：{{ order.add_time * 1000 | date('yyyy-mm-dd hh:MM') }}</view> -->
				</view>
			</view>
		</view>
		<view class="order-btn" v-if="order.goods_try_order_status == 20">
			<view class="logistics" @click="confirmOrder">确认完成</view>
		</view>
	</view>
</template>
<script>
import common from '@/static/js/common.js';
export default {
	data() {
		return {
			state: '', 
		}
	},
	props: {
		order: Object
	},
	created() {
		this.viewState();
	},
	filters: {},
	methods: {
		// "goods_try_order_status": 0,    试穿订单状态 0:待处理订单 20:同意 40:拒绝此订单 50:完成
		viewState() {
			let state;
			switch (this.order.goods_try_order_status) {
				case 0: 
					state = '等待商家回复';
					break;
				case 20: 
					state = '商家已接单';
					break;
				case 40:
					state = '商家已拒绝';
					break;
				case 50:
					state = '订单已结束';
					break;
				default:
					break;
			}
			this.state = state;
		},
		confirmOrder() {
			this.$u.api.goodsTryConfirm({
				id: this.order.goods_try_id,
			}).then(res => {
				if(res.errCode == 0) {
					this.$emit("refreshOrderList");
				}
				this.$u.toast(res.message);
			})
		},
		toOtherPage(url) {
			this.$u.route('/pageE/order/' + url, {
				oid: this.order.order_id,
			});
		},
	},
};
</script>
<style lang="scss" scoped>
.order-item {
	width: 690rpx;
	background: rgba(255,255,255,1);
	border-radius: 20rpx;
	padding: 30rpx;
	.order-title {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 20rpx;
		.store-info {
			display: flex;
			align-items: center;
			> image {
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				margin-right: 15rpx;
				background-color: aquamarine;
			}
			.store-name {
				font-size: 26rpx;
				color: rgba(51,51,51,1);
			}
		}
		.order-status {
			font-size: 28rpx;
			color: rgba(255,120,15,1);
		}
	}
	.goods-info {
		.goods-item {
			display: flex;
			margin-bottom: 28rpx;
			> image {
				flex-shrink: 0;
				width: 180rpx;
				height: 160rpx;
				border-radius: 10rpx;
				margin-right: 30rpx;
			}
			.goods-text {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.goods-name {
					font-size: 28rpx;
					color: rgba(51,51,51,1);
					line-height: 38rpx;
				}
				.goods-sku {
					max-width: 230rpx;
					background: rgba(236,236,236,1);
					border-radius: 6rpx;
					padding: 10rpx 15rpx;
					font-size: 24rpx;
					color: rgba(153,153,153,1);
				}
				.goods-time {
					font-size: 24rpx;
					color: rgba(255,49,49,1);
				}
				.goods-price {
					font-size: 24rpx;
					color: rgba(253,211,96,1);
				}
				.goods-date {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					color: rgba(153,153,153,1);
					> image {
						width: 24rpx;
						height: 24rpx;
						margin-right: 21rpx;
					}
				}
			}
		}
	}
	.order-btn {
		display: flex;
		justify-content: flex-end;
		@mixin btn-class($width, $color) {
			width: $width;
			height: 60rpx;
			border: 2rpx solid $color;
			color: $color;
			border-radius: 30rpx;
			padding: 15rpx 23rpx;
			font-size: 28rpx;
			&:not(:last-child) {
				margin-right: 30rpx;
			}
		}
		.logistics, .comment, .payment {
			@include btn-class($width: 160rpx, $color: rgba(255,119,15,1));
		}
		.calcel {
			@include btn-class($width: 160rpx, $color: rgba(155,153,153,1));
		}
		.service {
			@include btn-class($width: 216rpx, $color: rgba(155,153,153,1));
		}
		.submit {
			@include btn-class($width: 216rpx, $color: rgba(255,119,15,1));
		}
	}
}
</style>