<template>
	<view class="lost-container">
		<!-- 自定义导航栏 -->
		<view class="custom-navbar">
			<view class="nav-left">
				<view class="back-btn" @click="goBack">‹</view>
				<view class="title-box">
					<view class="main-title">丢了东西</view>
					<view class="sub-title">快速发布失物信息</view>
				</view>
			</view>
			<view class="nav-right">
				<!-- <image :src="globalImages + 'images/my/shiwu.png'" class="nav-icon" mode="aspectFit" /> -->
			</view>
		</view>

		<view class="section-title">我丢失的物品</view>
		<!-- 卡片列表 -->
		<view class="card-list" style="padding: 0rpx 30rpx;">
			<view class="card" v-for="(item, index) in lostItems" :key="index" @click="goToDetail(item)">
				<image :src="item.image" class="item-img" mode="aspectFill" />
				<view class="item-info">
					<view class="flex" style="justify-content: space-between;">
						<view class="item-title">{{ item.name }}</view>
						<view class="status-tag" :class="'status-' + item.statusType">{{ item.statusText }}</view>
					</view>
					<view style="border-top: 1rpx solid #e4e7ed; margin-top: 10rpx;margin-bottom: 20rpx;"></view>
					<view class="item-subtitle" style="margin-bottom: 10rpx;">{{ item.loss === 1 ? '丢失于' : ''}}：{{ item.carNum }}</view>
					<view class="item-time">{{ item.createTime }}</view>
				</view>
			</view>
		</view>

		<!-- 悬浮按钮 -->
		<view class="float-button" @click="goNav('/my/setting/LostandFoundadd')">
			<text class="plus">+</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				globalImages: getApp().globalData.globalImages || '', // 图片前缀路径
				lostItems: []
			};
		},
		onLoad() {
			this.$Request.getT('/app/lostFound/select?type=2&loss=1').then(res => {
				if (res.code === 0) {
					this.lostItems = res.data;
				}
			});
		},
		methods: {
			goNav(url) {
				uni.navigateTo({
					url
				});
			},
			goBack() {
				uni.navigateBack();
			},
			goToDetail(item) {
				// 建议用 JSON.stringify 序列化数据传参
				const encoded = encodeURIComponent(JSON.stringify(item));
				uni.navigateTo({
					url: `/my/setting/LostandFoundtext?data=${encoded}`
				});
			}
		}
	};
</script>

<style scoped>
	.lost-container {
		/* padding: 30rpx; */
		background: #f8f8f8;
		min-height: 100vh;
		box-sizing: border-box;
	}

	.custom-navbar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: var(--status-bar-height, 30rpx) 30rpx 30rpx;
		background: linear-gradient(to right, #ff7e5f, #feb47b);
		/* 渐变背景 */
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
		/* color: #fff; */
		margin-bottom: 30rpx;
	}

	.nav-left {
		/* display: flex; */
		align-items: center;
	}

	.back-btn {
		font-size: 40rpx;
		margin-right: 20rpx;
		margin-top: 40rpx;
		padding-bottom: 40rpx;
	}

	.title-box {
		display: flex;
		flex-direction: column;
	}

	.main-title {
		font-size: 46rpx;
		font-weight: bold;
	}

	.sub-title {
		font-size: 34rpx;
		/* color: #f0f0f0; */
		margin-top: 6rpx;
	}

	.nav-icon {
		width: 80rpx;
		height: 80rpx;
	}


	/* 卡片列表 */
	
	.section-title {
		padding: 0 30rpx;
		margin-bottom: 20rpx;
	}
	.card-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.card {
		width: 47%;
		background: #fff;
		border-radius: 16rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
		margin-bottom: 30rpx;
		overflow: hidden;
	}

	.item-img {
		width: 100%;
		height: 280rpx;
		object-fit: cover;
	}

	.item-info {
		padding: 20rpx;
	}

	.item-title {
		font-size: 28rpx;
		font-weight: 500;
		margin-bottom: 8rpx;
	}

	.status-tag {
		display: inline-block;
		padding: 4rpx 12rpx;
		font-size: 20rpx;
		border-radius: 20rpx;
		margin-bottom: 12rpx;
	}

	.status-searching {
		background: #ffe5e5;
		color: #ff4b4b;
	}

	.status-found {
		background: #e1f8f0;
		color: #27c29b;
	}

	.status-pending {
		background: #fff1e0;
		color: #ffa03b;
	}

	.item-subtitle,
	.item-time {
		font-size: 24rpx;
		color: #999;
	}

	/* 悬浮按钮 */
	.float-button {
		position: fixed;
		bottom: 60rpx;
		right: 60rpx;
		width: 60rpx;
		height: 60rpx;
		background: #fe6b01;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		font-size: 50rpx;
		z-index: 99;
	}
</style>