<template>
	<view class="content">
		<view class="inner">
			<view class="goods-list">
				<view v-if="order!=null&&order.isPackage!=1" class="item" v-for="(item,index) in items" :key="index">
					<image class="goods-img" :src="JSON.parse(item.jsonInfo).image" mode="aspectFit"></image>
					<view class="info">
						<view class="top">
							<view class="title ellipsis2">{{ JSON.parse(item.jsonInfo).productName}}</view>
							<view class="spec">{{JSON.parse(item.jsonInfo).sku}}</view>
						</view>
						<view class="price-num">
							<view class="price-box">
								<text class="unit">¥</text>
								<text class="price">{{JSON.parse(item.jsonInfo).price.toFixed(2)}}</text>
							</view>
							<view class="num">x{{JSON.parse(item.jsonInfo).num}}</view>
						</view>
					</view>
				</view>
				<view v-if="order!=null&&order.isPackage==1&&order.packageJson!=null" class="item">
					<image class="goods-img" :src="JSON.parse(order.packageJson).imgUrl" mode="aspectFit"></image>
				</view>
			</view>

		</view>
		<!-- 底部按钮 -->
		<view class="btn-box">
			<view class="text">提交申请后，客服会与您电话沟通，请保持手机通畅</view>
			<view class="btns">
				<view class="left"></view>
				<view class="right">
					<view class="btn cancel" v-if="order.status==2 || order.status==2" @click="submit(0)">仅退款</view>
					<view class="btn cancel" v-if="order.status==3||order.status==4" @click="submit(1)">退款退货</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getStoreOrderItems, //获取订单项列表
	} from '@/api/order.js'
	export default {

		data() {
			return {
				order: {},
				items: [],

			}
		},
		onLoad(option) {
			this.orderId = option.orderId;
			this.getStoreOrder()
		},
		methods: {
			checkChange(item) {
				item.checked = !item.checked;
			},
			submit(type) {
				uni.redirectTo({
					url: '/pages_shopping/live/refundOrder?orderId=' + this.order.orderId + "&type=" + type + "&orderCode=" +
						this.order.orderCode
				})
			},
			getStoreOrder() {
				var data = {
					orderId: this.orderId
				};
				getStoreOrderItems(data).then(res => {
					if (res.code == 200) {
						console.log("获取订单项列表>>>", res)
						this.order = res.order;
						this.items = res.items;

					} else {
						uni.showToast({
							icon: 'none',
							title: "请求失败",
						});

					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.content {
		margin-bottom: 170rpx;

		.inner {
			padding: 20rpx;

			.goods-list {
				.item {
					box-sizing: border-box;
					height: 221rpx;
					background: #FFFFFF;
					padding: 30rpx;
					display: flex;
					align-items: center;

					&:last-child {
						margin-bottom: 0;
					}

					.goods-img {
						width: 160rpx;
						height: 160rpx;
						background: #FFFFFF;
						margin-right: 30rpx;
						flex-shrink: 0;
					}

					.info {
						width: calc(100% - 160rpx);
						height: 160rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.top {
							.title {
								font-size: 28rpx;
								font-family: PingFang SC;
								font-weight: 500;
								color: #111111;
								line-height: 1.4;

								.tag {
									display: inline-block;
									padding: 0 6rpx;
									height: 30rpx;
									background: linear-gradient(90deg, #66b2ef 0%, #0bb3f2 100%);
									border-radius: 4rpx;
									margin-right: 10rpx;
									font-size: 22rpx;
									font-family: PingFang SC;
									font-weight: bold;
									color: #FFFFFF;
									line-height: 30rpx;
									float: left;
									margin-top: 7rpx;
								}
							}

							.spec {
								font-size: 24rpx;
								font-family: PingFang SC;
								font-weight: 500;
								color: #999999;
								line-height: 1;
								margin-top: 14rpx;
							}
						}

						.price-num {
							display: flex;
							align-items: center;
							justify-content: space-between;

							.price-box {
								display: flex;
								align-items: flex-end;

								.unit {
									font-size: 24rpx;
									font-family: PingFang SC;
									font-weight: 500;
									color: #111111;
									line-height: 1.2;
									margin-right: 5rpx;
								}

								.price {
									font-size: 32rpx;
									font-family: PingFang SC;
									font-weight: 500;
									color: #111111;
									line-height: 1;
								}
							}

							.num {
								font-size: 24rpx;
								font-family: PingFang SC;
								font-weight: bold;
								color: #666666;
							}
						}
					}
				}
			}

		}

		.btn-box {
			width: 100%;
			height: 160rpx;
			position: fixed;
			bottom: 0;
			background: #FFFFFF;

			.text {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				line-height: 1;
				padding: 28rpx 0;
				text-align: center;
			}

			.btns {
				padding: 0rpx 30rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;

				.left {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}

				.right {
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					align-items: center;

					.btn {
						width: 155rpx;
						height: 64rpx;
						line-height: 64rpx;
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						text-align: center;
						border-radius: 32rpx;
						margin-left: 15rpx;

						&.cancel {
							border: 1px solid #DDDDDD;
							color: #666666;
						}
					}
				}

			}

		}
	}
</style>