<template>
	<view class="action">
		<view class="icon">
			<image src="/static/image/cart/1.png" mode=""></image>
			<view class="num">
				{{ cartCheckboxValue.length }}
			</view>
		</view>
		<view class="price">
			<view class="count">
				合计
				<view class="">
					￥<text>{{ totalPrice }}</text>
				</view>
			</view>
			<view class="text">
				共{{ cartCheckboxValue.length }}件，已享受更低优惠
			</view>
		</view>
		<view class="btn">
			去结算
		</view>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
			}
		},
		computed: {
			totalPrice() {
				if (!this.cartCheckboxValue.length) {
					return 0
				}
				let price = 0
				this.cartList.forEach(n => {
					if (this.cartCheckboxValue.includes(n.id)) {
						price += n.price * n.num
					}
				})
				return price
			},
			...mapState(['cartList', 'cartCheckboxValue']),
		},
		methods: {

		}
	}
</script>

<style scoped lang="scss">
	.action {
		width: 700rpx;
		position: fixed;
		bottom: 220rpx;
		left: 25rpx;
		background-color: #fff;
		height: 100rpx;
		border-radius: 50rpx;
		box-shadow: 0 0 6rpx 6rpx #00000010;
		display: flex;
		justify-content: center;
		align-items: center;
		overflow: hidden;

		.icon {
			position: relative;
			width: 80rpx;
			height: 80rpx;
			margin: 0 20rpx;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			.num {
				position: absolute;
				right: 10rpx;
				top: 0rpx;
				background-color: $uni-color;
				color: #fff;
				font-size: 18rpx;
				border-radius: 50%;
				height: 30rpx;
				width: 30rpx;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}

		.price {
			.count {
				display: flex;
				font-size: 26rpx;
				align-items: center;

				view {
					color: $uni-color;
					margin-left: 10rpx;

					text {
						font-size: 32rpx;
						font-weight: 900;
					}
				}
			}

			.text {
				font-size: 20rpx;
				color: #717171;
			}
		}

		.btn {
			margin-left: auto;
			background-color: $uni-color;
			height: 100%;
			padding: 0 50rpx;
			color: #fff;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
</style>