<template>
	<view>
		<!-- 商品信息 -->
		<self-line/>
		<view class="bg-white padding-tb-sm">
			<skeleton :loading="skeletonLoading" :row="2" :showAvatar="false" :showTitle="true">

				<view class="flex justify-between align-start padding-top-sm padding-lr">
					<image :src="orderDetails.order.goods.cover" mode="aspectFill" style="width: 150rpx; height: 150rpx;"></image>
					<view class="flex-sub padding-left-sm">
						<view class="bref-box margin-top-xs">
							{{orderDetails.order.goods.name}}
						</view>
						<text class="block margin-top-sm text-gray text-sm">数量 <text class="margin-left text-gray">x {{orderDetails.order.number}}</text></text>
						
						<view class="flex justify-between margin-top-sm">
							<view class="text-red text-price text-lg">
								{{orderDetails.order.selling_price}}
							</view>
							<view>
								<button class="cu-btn line-gray bg-white border round margin-left-sm text-sm">等待审核</button>
							</view>
						</view>
					</view>
				</view>

			</skeleton>
		</view>
		<self-line/>
		<skeleton :loading="skeletonLoading" :row="3" :showAvatar="false" :showTitle="true">
			<view class="bg-white">
				<view class="cu-bar padding-lr solid-bottom flex justify-between align-center text-center">
					<text class="text-gray">订单金额</text>
					<view class="text-price">
						{{orderDetails.order.amount}}
					</view>
				</view>
				<view class="cu-bar padding-lr solid-bottom flex justify-between align-center text-center">
					<text class="text-gray">扣费率</text>
					<view>
						<text>{{orderDetails.refund_rate}}%</text>
					</view>
				</view>
				<view class="cu-bar padding-lr solid-bottom flex justify-between align-center text-center">
					<text class="text-gray">扣费金额</text>
					<view class="text-price">
						{{orderDetails.refund_rate_amount}}
					</view>
				</view>
			</view>
		</skeleton>
		<self-line/>
		<!-- 表单 -->
		<skeleton :loading="skeletonLoading" :row="2" :showAvatar="false" :showTitle="true">
			<view class="bg-white">
				<view class="cu-bar padding-lr solid-bottom flex justify-between align-center text-center">
					<text class="text-gray">可退金额</text>
					<view class="text-price">
						{{orderDetails.refund_amount}}
					</view>
				</view>
				<view class="cu-bar padding-lr solid-bottom flex justify-between align-center text-center">
					<text class="text-gray">订单编号</text>
					<view>
						<text class="margin-right">{{orderDetails.order_sn}}</text>
						<text class="text-orange text-sm"  @tap="copy(orderDetails.order_sn)">复制</text>
					</view>
				</view>
			</view>
		</skeleton>
		<self-line/>
		
		<skeleton :loading="skeletonLoading" :row="6" :showAvatar="false" :showTitle="true">
			<view class="padding-top padding-lr bg-white">
				<view class="cu-self menu">
					<view class="text-gray">
						{{checkArea}}
					</view>
				</view>
			</view>
			<view class="padding bg-white">
				<view class="cu-self menu">
					<view class="text-df text-bold">退款说明</view>
				</view>
				<view class="cu-self menu margin-top">
					<view class="text-gray">{{orderDetails.comment}}</view>
				</view>
			</view>
			<view class="cu-form-group solid-bottom">
				<view class="grid col-4 grid-square flex-sub">
					<view class="bg-img" v-for="(item,index) of images" :key="index">
						<image :src="item.path" @tap="showImg" mode="aspectFill"></image>
					</view>
				</view>
			</view>
		</skeleton>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				skeletonLoading: true,
				loading: false,
				// 选择的本地图片路径
				hostImg: '',
				// 已上传服务器的图片名称
				serverImg:'',
				orderId:1,
				orderDetails: {},
				checkArea: '',
				images: []
			}
		},
		computed: {
			
		},
		onLoad(e) {
			this.orderId = e.orderid
			if(this.orderId) {
				this.getOrderDetails()
			}
		},
		methods: {
			getOrderDetails() {
				this.$http(this.API.API_APPLYPAGE_DETAILS, {order_id: this.orderId}).then(res => {
					if(res.code == 0) {
						this.orderDetails = res.data.refund
						this.checkArea = res.data.agreement.tips
						this.images = res.data.refund.images
						this.skeletonLoading = false
					}
					
				}).catch(err => {
					
				});
			},
			// 预览图片
			showImg() {
				uni.previewImage({
					urls: ['../../static/tu.png']
				});
			},
			// 点击复制
			copy(text) {
				uni.setClipboardData({
					data: text
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bref-box {
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
</style>
