carCard.vue 1.5 KB
<template>
	<view class="carCard" @click="skip">
		<slot name="header"></slot>
		<slot name="center"></slot>
		<view class="rowLine"></view>
		<slot name="footer"></slot>
		<view class="tip" :style="{backgroundColor: bgColor, color: fontColor}">{{ carInfo?.status || tipContent }}</view>
	</view>
</template>

<script setup>
import { computed } from 'vue';
const props = defineProps({
	carInfo: {
		type: Object,
		require: true
	},
	tipContent: {
		type: String,
		default: ''
	}
})
const emit = defineEmits(['onSkip'])
const bgColor = computed(() => {
	let index = props.carInfo.status
	let objColor = {
		'进行中': '#D5E5FF',
		'已完成': '#dbf1e1',
		'已作废': '#FFD5D5'
	}
	return objColor[index] || '#D5E5FF'
})
const fontColor = computed(() => {
	let index = props.carInfo.status
	let objColor = {
		'进行中': '#3680FE',
		'已完成': '#19be6b',
		'已作废': '#C81515'
	}
	return objColor[index] || '#3680FE'
})

const skip = () => {
	emit('onSkip', props.carInfo.carId)
}
</script>

<style lang="scss" scoped>
.carCard{
	position: relative;
	padding: 20rpx 30rpx 34rpx;
	box-shadow: 0rpx 8rpx 40rpx 0rpx rgba(10,22,44,0.06);
	background: #fff;
	border-radius: 20rpx;
	.rowLine{
		width: 100%;
		height: 2rpx;
		background-color: #eee;
		margin: 20rpx 0;
	}
	.tip{
		position: absolute;
		top: 0;
		right: 0;
		width: 120rpx;
		height: 40rpx;
		text-align: center;
		font-size: 20rpx;
		line-height: 40rpx;
		border-radius: 0rpx 20rpx 0rpx 20rpx;
		color: #3680FE;
		background-color: #D5E5FF;
	}
}
</style>