<template>
	<view>
		<view class="p-3 rounded-lg bg-white mt-2 position-relative" v-for="(item,index) in resdata" :key="index" @click="toShow(item)">
			<text class="font32 line15">{{item.title}}</text>
			<view class="font24 mt-2 text-ellipsis-2">
				{{item.content}}
			</view>
			<view class="flex align-center justify-between mt-2">
				<view class="flex align-center">
					<uni-icons type="calendar" size="16" color="#cccccc"></uni-icons>
					<text class="font24 text-muted">{{item.create_at}}</text>
				</view>
			</view>
			<view v-if="item.status == 0" class="badge-dot"></view>
		</view>
	</view>
</template>

<script>
import { TaPost } from '../../common/ajax';

	export default {
		name:"i-message-list",
		props:{
			resdata:{
				type:Array,
				default() {
				  return [];
				},
			}
		},
		data() {
			return {
				
			}
		},
		created() {
			console.log(this.resdata)
		},
		methods:{
			toShow(item){
				TaPost("/custom/api.auth.message/read", {id: item.id}).then((result) => {
					item.status = 1;
				})
				switch (item.type) {
					case "USER_SHARE":
						uni.navigateTo({
							url: '/pages/user-share/detail?id='+item.oid
						})
						break;
				}
			}
		}
	}
</script>

<style scoped>
.badge-dot {
	position: absolute;
	top: 16rpx;
	right: 16rpx;
	width: 16rpx;
	height: 16rpx;
	background-color: red;
	border-radius: 16rpx;
}
</style>
