<template>
	<view class="container">
		<view class="center-box">
			<view class="top-t">
				<view class="t-l">
					<view class="t-b"> </view>
					<view class="t-name">商品详情</view>
				</view>
			</view>

			<u-line margin="20rpx 0"></u-line>

			<view class="item-center" :key="index" v-for="(item, index) of init_list.goodsInfo">
				<view class="center-left">
					<image src="@/static/QR57a.jpg" class="img"></image>
				</view>
				<view class="center-right">
					<view class="r-l">
						<view class="right-name"> {{ item.goodsName }} </view>
						<view class="right-descript"> 测试商品描述111 </view>
						<view class="l-box">
							<view class="right-price"> ￥{{ item.goodsPrice }} </view>
							<view class="right-numb"> ×{{ item.goodsQuantity }} </view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="top-box">
			<view class="top-t">
				<view class="t-l">
					<view class="t-b"> </view>
					<view class="t-name">订单信息</view>
				</view>
			</view>

			<u-line margin="20rpx 0"></u-line>

			<view class="top-t2">
				<view class="t2-item">
					<p>订单号</p>
					<p>{{ init_list.orderSn }}</p>
				</view>
				<view class="t2-item">
					<p>下单时间</p>
					<p>2024-2-25</p>
				</view>
				<view class="t2-item">
					<p>支付方式</p>
					<p>在线支付</p>
				</view>
				<view class="t2-item">
					<p>商品总额</p>
					<p>￥{{ allPrice }}</p>
				</view>
				<view class="t2-item">
					<p>优惠券</p>
					<p>-￥3.90</p>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				init_list: {},
			};
		},
		onLoad(option) {
			this.init_list = option.orderList;
		},
		computed: {
			allPrice() {
				let price = 0;
				this.init_list.goodsInfo.map(rs => {
					price += rs.goodsPrice;
				});
				return price.toFixed(2);
			},
		},
	};
</script>

<style lang="scss" scoped>
	.container {
		padding: 20rpx;

		.top-box,
		.center-box {
			padding: 20rpx;
			background-color: #fff;
			border-radius: 20rpx;
			box-shadow: 5rpx 5rpx 5rpx 5rpx rgba(0, 0, 0, 0.2);

			.top-t {
				display: flex;
				justify-content: space-between;

				.t-l {
					display: flex;

					.t-b {
						width: 12rpx;
						border-radius: 10rpx;
						background-color: #f98e23;
					}

					.t-name {
						margin-left: 10rpx;
						font-weight: bold;
						font-size: 28rpx;
					}
				}
			}

			.top-bottom-text {
				margin: 10rpx 0;
			}

			.top-t2 {
				.t2-item {
					display: flex;
					justify-content: space-between;
					margin-bottom: 20rpx;
				}
			}
		}

		.center-box {
			margin-bottom: 20rpx;
		}

		.item-center {
			display: flex;
			align-items: center;
			margin: 10rpx 0;

			.center-left {
				height: 160rpx;

				.img {
					width: 160rpx;
					height: 160rpx;
				}
			}

			.center-right {
				width: 100%;
				height: 160rpx;
				display: flex;
				justify-content: space-between;
				margin-left: 20rpx;

				.r-l {
					display: flex;
					flex-direction: column;
					justify-content: space-around;

					.right-name {
						color: #4d5671;
						font-size: 32rpx;
						font-weight: bold;
					}

					.right-descript {
						font-size: 28rpx;
						color: #858797;
					}

					.l-box {
						display: flex;
						font-size: 24rpx;
						align-items: center;
						font-style: italic;

						.right-price {
							margin-right: 20rpx;
							font-weight: bold;
							font-size: 28rpx;
							color: #f57f32;
						}

						.right-numb {
							font-size: 24rpx;
							color: #858797;
						}
					}
				}
			}
		}
	}
</style>