62 lines
2.7 KiB
PHP
62 lines
2.7 KiB
PHP
<?php
|
||||
|
|
/**
|
|||
|
|
* 旅程列表**主体**(搜索框 + 列表/空态)。
|
|||
|
|
*
|
|||
|
|
* 🔴 v41(用户 2026-10-10):单独抽出来,是为了"新建成功后**只换这一块**"
|
|||
|
|
* (`#tripListHost` 的 innerHTML)—— 保留滚动位置、不整页闪白。
|
|||
|
|
* 所以要保证:这块里的内容**只依赖** $rows / $total / $keyword / $canWrite。
|
|||
|
|
*/
|
|||
|
|
?>
|
|||
|
|
<form class="search" method="get" action="index.php">
|
|||
|
|
<input type="hidden" name="r" value="trips">
|
|||
|
|
<input class="input" type="text" name="keyword" value="<?= e($keyword) ?>" placeholder="搜旅程名 / 去过的城市">
|
|||
|
|
<button class="btn" type="submit">搜索</button>
|
|||
|
|
<?php if ($keyword !== ''): ?>
|
|||
|
|
<a class="search-clear" href="<?= e(url('trips')) ?>">清除</a>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</form>
|
|||
|
|
|
|||
|
|
<?php if (!$rows): ?>
|
|||
|
|
<div class="card card-pad empty">
|
|||
|
|
<b><?= $keyword !== '' ? '没有匹配的旅程' : '还没有旅程' ?></b>
|
|||
|
|
<?= $keyword !== '' ? '换个关键词试试,或清除搜索看全部。'
|
|||
|
|
: ($canWrite ? '点右上角「新建旅程」,把一次出行记下来;进去之后再加一段段行程。'
|
|||
|
|
: '家人还没有记录旅程。') ?>
|
|||
|
|
</div>
|
|||
|
|
<?php else: ?>
|
|||
|
|
<div class="trip-list">
|
|||
|
|
<?php foreach ($rows as $t): ?>
|
|||
|
|
<a class="trip-card" href="<?= e(url('trips/show', ['id' => (int)$t['id']])) ?>">
|
|||
|
|
<div class="trip-cover">
|
|||
|
|
<?php if (!empty($t['cover_key'])): ?>
|
|||
|
|
<img src="<?= e(media_url((string)$t['cover_key'])) ?>" alt="">
|
|||
|
|
<?php else: ?>
|
|||
|
|
<span class="trip-cover-empty">🧳</span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</div>
|
|||
|
|
<div class="trip-main">
|
|||
|
|
<h2 class="trip-title"><?= e((string)$t['title']) ?></h2>
|
|||
|
|
<div class="trip-meta">
|
|||
|
|
<?php /* 时间是从各段旅程算的;一段都没有时如实说"还没有旅程" */ ?>
|
|||
|
|
<span><?= e(\App\Trip::activitySpan($t['starts_at'] ?? null, $t['ends_at'] ?? null)) ?></span>
|
|||
|
|
<?php if (!empty($t['city'])): ?>
|
|||
|
|
<span>📍 <?= e((string)$t['city']) ?></span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
<span><?= (int)($t['node_count'] ?? 0) ?> 段行程</span>
|
|||
|
|
</div>
|
|||
|
|
<?php if (!empty($t['summary'])): ?>
|
|||
|
|
<p class="trip-sum"><?= e(mb_substr((string)$t['summary'], 0, 80, 'UTF-8')) ?></p>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
<?php if (!empty($t['attendees'])): ?>
|
|||
|
|
<div class="trip-people">
|
|||
|
|
<?php foreach ($t['attendees'] as $a): ?>
|
|||
|
|
<?= person_chip($a) ?>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</div>
|
|||
|
|
</a>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
<?php endif; ?>
|