<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">
					<!-- <label style="margin-right: 30upx;">
						<checkbox :value="item.checked"  :checked="item.checked" @click="checkChange(item)" />
					</label> -->
					<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 class="info">
						<view class="top">
							<view class="title ellipsis2">
								<view class="tag">套餐</view>{{JSON.parse(order.packageJson).title}}
							</view>
							<view class="spec">{{JSON.parse(order.packageJson).descs}}</view>
						</view>
					</view>
					 
				</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==1 || 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 {getMyStoreOrderItemByOrderId,applyAfterSales} from '@/api/storeAfterSales'
	export default {
		 
		data() {
			return {
				order:null,
				items:[],
				 
			}
		},
		onLoad(option) {
			this.orderId=option.orderId;
			this.getMyStoreOrderItemByOrderId()
		},
		methods: {
			checkChange(item){
				item.checked=!item.checked;
			},
			submit(type){
				// // var refundItems=this.items.filter(item => item.checked==true )
				// // if(refundItems.length==0){
				// // 	uni.showToast({
				// // 		icon:'none',
				// // 		title: '请选择退款商品'
				// // 	});
				// // 	return;
				// // }
				// uni.navigateTo({
				// 	url: '/pages_user/user/refundOrder?items='+JSON.stringify(refundItems)+"&type="+type+"&orderCode="+this.order.orderCode
				// })
				uni.redirectTo({
					url: '/pages_user/user/refundOrder?orderId='+this.order.id+"&type="+type+"&orderCode="+this.order.orderCode
				})
			},
			getMyStoreOrderItemByOrderId(){
				var data={orderId:this.orderId};
				getMyStoreOrderItemByOrderId(data).then(res => {
					if(res.code==200){
						this.order=res.order;
						this.items=res.items;
						 
					}else{
						uni.showToast({
							icon:'none',
							title: "请求失败",
						});
						 
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.content{
		margin-bottom: 170upx;
		.inner{
			padding: 20upx;
			.goods-list{
				.item{
					box-sizing: border-box;
					height: 221upx;
					background: #FFFFFF;
					padding: 30upx;
					display: flex;
					align-items: center;
					&:last-child{
						margin-bottom: 0;
					}
					.goods-img{
						width: 160upx;
						height: 160upx;
						background: #FFFFFF;
						margin-right: 30upx;
						flex-shrink: 0;
					}
					.info{
						width: calc(100% - 160upx);
						height: 160upx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						.top{
							.title{
								font-size: 28upx;
								font-family: PingFang SC;
								font-weight: 500;
								color: #111111;
								line-height: 1.4;
								.tag{
									display: inline-block;
									padding: 0 6upx;
									height: 30upx;
									background: linear-gradient(90deg, #2BC7B9 0%, #2BC7A4 100%);
									border-radius: 4upx;
									margin-right: 10upx;
									font-size: 22upx;
									font-family: PingFang SC;
									font-weight: bold;
									color: #FFFFFF;
									line-height: 30upx;
									float: left;
									margin-top: 7upx;
								}
							}
							.spec{
								font-size: 24upx;
								font-family: PingFang SC;
								font-weight: 500;
								color: #999999;
								line-height: 1;
								margin-top: 14upx;
							}
						}
						.price-num{
							display: flex;
							align-items: center;
							justify-content: space-between;
							.price-box{
								display: flex;
								align-items: flex-end;
								.unit{
									font-size: 24upx;
									font-family: PingFang SC;
									font-weight: 500;
									color: #111111;
									line-height: 1.2;
									margin-right: 5upx;
								}
								.price{
									font-size: 32upx;
									font-family: PingFang SC;
									font-weight: 500;
									color: #111111;
									line-height: 1;
								}
							}
							.num{
								font-size: 24upx;
								font-family: PingFang SC;
								font-weight: bold;
								color: #666666;
							}
						}
					}
				}
			}
			 
		}
		.btn-box{
			width: 100%;
			height: 160upx;
			position: fixed;
			bottom: 0;
			background: #FFFFFF;
			.text{
				font-size: 24upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				line-height: 1;
				padding: 28upx 0;
				text-align: center;
			}
			.btns{
				padding: 0upx 30upx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				.left{
					font-size: 24upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				.right{
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					align-items: center;
					.btn{
						width: 155upx;
						height: 64upx;
						line-height: 64upx;
						font-size: 26upx;
						font-family: PingFang SC;
						font-weight: 500;
						text-align: center;
						border-radius: 32upx;
						margin-left: 15upx;
						&.cancel{
							border: 1px solid #DDDDDD;
							color: #666666;
						}
					}
				}
				
			}
			
		}
	}
</style>
