<template>
	<view class="gift_list">
		<view v-if="giftList.length > 0">
			<view class="gift_item" v-for="item in giftList" :key="item.id" v-show="item.num > 0">
				<image :src="item.img" class="gift_img"></image>
				<view class="right">
					<view class="fixed">赠品名称:</view>
					<view class="bottom">
						<view class="name">{{ item.name }}</view>
						<view class="num">数量：{{ item.num }}</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else class="noTip">该订单没有赠品</view>
	</view>
</template>

<script>
	
	import { _API_GetOrderGift } from '../../apis/order.js'
	
	export default {
		data() {
			return {
				giftList: []
			}
		},
		onLoad({ order_no }) {
			if(order_no) {
				this.getGiftList(order_no)
			}
		},
		methods: {
			getGiftList(order_no) {
				uni.showLoading({
					title:'加载中'
				})
				_API_GetOrderGift({
					order_num: order_no
				}).then(res => {
					uni.hideLoading()
					if(res.code === 200) {
						this.giftList = res.data.list
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.noTip {
		width: 100%;
		padding: 20px 0;
		text-align: center;
		color: #181818;
	}
	.gift_list {
		min-height: 100%;
		background: $app-base-bg;
		.gift_item {
			padding: 28rpx 30rpx;
			margin-bottom: 1px;
			background-color: #FFFFFF;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.gift_img {
				display: block;
				width: 140rpx;
				height: 140rpx;
			}
			.right {
				width: calc(100% - 140rpx);
				height: 140rpx;
				padding: 0 50rpx 0 30rpx;
				display: flex;
				justify-content: space-between;
				flex-direction: column;
				.fixed {
					color: #181818;
					font-size: 32rpx;
				}
				.bottom {
					display: flex;
					justify-content: space-between;
					align-items: center;
					.name {
						color: #F76454;
						font-size: 32rpx;
					}
					.num {
						color: #181818;
						font-size: 28rpx;
					}
				}
			}
		}
	}
</style>
