priceCard.vue 1.4 KB
<template>
	<view class="priceCard" :style="{backgroundColor: active ? '#FFE6B4' : '#fff'}" @click="toggle">
		<text class="card_name">{{ info.name }}</text>
		<text class="price">¥<text style="font-size: 72rpx; line-height: 96rpx;">{{ info.price }}</text></text>
		<text class="old_price">¥{{ info.oldPrice }}</text>
		<view class="avg_price" :style="{backgroundColor: active ? '#FFC675' : '#FFFAF1', color: active ? '#722F06' : '#DEB468'}">{{ info.avgText }}</view>
	</view>
</template>

<script>
	export default {
		props: {
			active: {
				type: Number,
				default: false
			},
			info: {
				type: Object,
				require: true
			}
		},
		methods: {
			toggle(){
				this.$emit('toggle')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.priceCard{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		padding-top: 8rpx;
		width: 330rpx;
		height: 240rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		overflow: hidden;
		border: 2rpx solid #EEEEEE;
		box-sizing: border-box;
		color: #722F06;
		.card_name, .price{
			font-size: 32rpx;
			line-height: 42rpx;
			font-weight: 500;
		}
		.old_price{
			color: #BF9363;
			font-size: 28rpx;
			line-height: 38rpx;
			text-decoration: line-through;
		}
		.avg_price{
			height: 48rpx;
			line-height: 48rpx;
			color: #DEB468;
			font-size: 28rpx;
			width: 100%;
			text-align: center;
		}
	}
</style>