<template>
	<view class="list-item-box">
		<img class="list-img" :src="data.cover||defaultImg">
		<view class="list-time-box" :class="{'time-red-box': type == 1}">
			<view class="time-data">{{ formatDate[1] }}</view>
			<view class="time-year">{{formatDate[0]}}</view>
		</view>
		<view class="list-right-box">
			<h1 class="list-name">{{ data.title }}</h1>
			<view class="list-line"></view>
			<view class="list-content" v-html="getStringByHtml3(data.content)">
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		computed
	} from "vue";
	import {
		getStringByHtml3,
		formatDateToYearMonthDay
	} from "@/utils/common.js"

	const props = defineProps({
		data: {
			type: Object
		},
		type: {
			type: Number
		}
	})

	const myData = reactive({
		default1: '', // 默认图
		default2: '' // 默认图2
	})

	const formatDate = computed(() => {
		return formatDateToYearMonthDay(props.data.createTime)
	})

	const defaultImg = computed(() => {
		return props.type == 1 ? myData.default1 : myData.default2
	})
</script>

<style>

</style>