72 lines
2.8 KiB
PHP
72 lines
2.8 KiB
PHP
<?php
|
||||
|
|
/**
|
|||
|
|
* 旅程列表(v12,TripLog activities/index 迁来,但按家书的统一事件原语重写)。
|
|||
|
|
*
|
|||
|
|
* 与观影列表同一个骨架:页头 + 搜索 + 卡片列表。
|
|||
|
|
* ⚠️ 卡片上的人是「我叫他什么」(person_chip),不是姓名(用户第 3 条)。
|
|||
|
|
*/
|
|||
|
|
$canWrite = \App\Auth::canWrite();
|
|||
|
|
?>
|
|||
|
|
<div class="page-head">
|
|||
|
|
<h1>旅程</h1>
|
|||
|
|
<span class="sub">共 <?= (int)$total ?> 趟</span>
|
|||
|
|
<div class="actions">
|
|||
|
|
<?php if ($canWrite): ?>
|
|||
|
|
<a class="btn" href="<?= e(url('trips/new')) ?>">记一趟旅程</a>
|
|||
|
|
<?php else: ?>
|
|||
|
|
<span class="link-quiet">只读账号</span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<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">
|
|||
|
|
<span><?= e(\App\Trip::formatSpan($t['starts_at'] ?? null, $t['ends_at'] ?? null)) ?></span>
|
|||
|
|
<?php if (!empty($t['location'])): ?>
|
|||
|
|
<span>📍 <?= e((string)$t['location']) ?></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; ?>
|