<template>
	<view class="footer-bar safe-area-inset-bottom">
		<view class="icons-area">
			<view class="icon-item">
				<image src="/pages-sell/static/goods/icon-home.png" class="bar-icon" mode="widthFix" style="width: 36rpx;"></image>
				<text>首页</text>
			</view>
			<view class="icon-item">
				<image src="/pages-sell/static/goods/icon-star.png" class="bar-icon" mode="aspectFit"></image>
				<text>收藏</text>
			</view>
			<view class="icon-item">
				<image src="/pages-sell/static/goods/icon-car.png" class="bar-icon" mode="aspectFit"></image>
				<text>购物车</text>
			</view>
		</view>

		<view class="action-btn-area">
			<view v-if="hasStock" class="action-btn in-stock" @click="onAddCart">
				<text>加入购物车</text>
			</view>
			<view v-else class="action-btn no-stock" @click="onNotify">
				<text>到货通知</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'FooterBar',
	props: {
		hasStock: {
			type: Boolean,
			default: true
		}
	},
	methods: {
		onAddCart() {
			this.$emit('addCart');
		},
		onNotify() {
			this.$emit('notify');
		}
	}
}
</script>

<style lang="scss" scoped>
.footer-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 200rpx;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20rpx;
	box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
	z-index: 3;
	padding-bottom: env(safe-area-inset-bottom);

	.icons-area {
		display: flex;
		margin-right: 20rpx;

		.icon-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			width: 80rpx;
			margin-right: 10rpx;

			.bar-icon {
				width: 40rpx;
				height: 40rpx;
				margin-bottom: 6rpx;
			}

			text {
				font-size: 20rpx;
				color: #666;
				text-align: center;
			}
		}
	}

	.action-btn-area {
		flex: 1;
		display: flex;
		height: 80rpx;
		max-width: 360rpx;

		.action-btn {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;
			border-radius: 40rpx;
			font-size: 30rpx;
			color: #fff;
			font-weight: bold;
			background: linear-gradient(0deg, #38C248 0%, #5FEA6F 100%);
		}
	}
}
</style>