v10: 修影院编辑回填布尔化 bug;评分改 10 星制;观影人改弹窗+拼音首字母联想;豆瓣自动补充迁移(movie_details.douban_meta,schema v10)
This commit is contained in:
@@ -5,8 +5,13 @@
|
||||
* 颜色用「取色器 + 50 色预设板」两路输入(内联小段 JS 只是取色联动,
|
||||
* 不依赖 JS 也能手填 hex 或直接用取色器)。删除是 POST 小表单 + confirm;
|
||||
* 删掉的影院只把关联观影记录的 cinema_id 置空,记录本身不动。
|
||||
*
|
||||
* ⚠️ $editing 是路由传进来的「被编辑影院的记录数组」(或 null)。
|
||||
* 曾经这里写成 `$editing = !empty($editing);` —— 数组被原地变成布尔值,
|
||||
* 表面看标题还会显示「编辑影院」,但 hidden id 变 0、四个字段全部回填为空,
|
||||
* 点「编辑」就像没带入一样(v9 线上实测)。布尔化结果必须存进**另一个**变量。
|
||||
*/
|
||||
$editing = !empty($editing);
|
||||
$isEditing = !empty($editing);
|
||||
$canWrite = \App\Auth::canWrite();
|
||||
?>
|
||||
<div class="page-head">
|
||||
@@ -21,10 +26,10 @@ $canWrite = \App\Auth::canWrite();
|
||||
<div class="card card-pad empty"><b>只读账号</b>访客只能查看影院列表。</div>
|
||||
<?php else: ?>
|
||||
<div class="card card-pad cinema-form-card">
|
||||
<h2 class="cinema-h2"><?= $editing ? '编辑影院' : '添加影院' ?></h2>
|
||||
<h2 class="cinema-h2"><?= $isEditing ? '编辑影院' : '添加影院' ?></h2>
|
||||
<form method="post" action="<?= e(url('movies/cinemas_save')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<?php if ($editing): ?>
|
||||
<?php if ($isEditing): ?>
|
||||
<input type="hidden" name="id" value="<?= (int)$editing['id'] ?>">
|
||||
<?php endif; ?>
|
||||
<div class="form-grid">
|
||||
@@ -58,8 +63,8 @@ $canWrite = \App\Auth::canWrite();
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-row">
|
||||
<button type="submit" class="btn"><?= $editing ? '保存' : '添加影院' ?></button>
|
||||
<?php if ($editing): ?>
|
||||
<button type="submit" class="btn"><?= $isEditing ? '保存' : '添加影院' ?></button>
|
||||
<?php if ($isEditing): ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('movies/cinemas')) ?>">取消编辑</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
+298
-7
@@ -44,7 +44,22 @@ $selAttendees = array_map('intval', (array)old('attendees', $curAttendees));
|
||||
<div class="form-grid">
|
||||
<div class="field full">
|
||||
<label for="title">片名 *</label>
|
||||
<input class="input" id="title" name="title" value="<?= e(old('title', $m['title'] ?? '')) ?>" required>
|
||||
<div class="db-title-row">
|
||||
<input class="input" id="title" name="title" value="<?= e(old('title', $m['title'] ?? '')) ?>"
|
||||
required autocomplete="off">
|
||||
<button type="button" class="btn btn-ghost btn-sm" id="dbFetch"
|
||||
title="按片名从豆瓣抓取片名、简介、海报等">📡 自动获取</button>
|
||||
</div>
|
||||
<?php /* v10 豆瓣自动补充:输入片名出下拉候选,点「自动获取」直接抓。
|
||||
抓到的元数据整体进隐藏 douban_meta(JSON),海报走服务端落盘的 poster_key。 */ ?>
|
||||
<div class="db-suggest" id="dbSuggest" hidden></div>
|
||||
<input type="hidden" name="douban_meta" id="dbMeta" value="">
|
||||
<input type="hidden" name="poster_key" id="dbPosterKey" value="">
|
||||
<div class="db-poster-preview" id="dbPosterWrap" hidden>
|
||||
<img id="dbPosterImg" alt="海报预览">
|
||||
<span class="tip">海报已从豆瓣取回,保存后生效。</span>
|
||||
</div>
|
||||
<span class="tip">片名可从豆瓣自动补充:输入后从下拉里选,或点「自动获取」。</span>
|
||||
<?php if (!empty($errors['title'])): ?><span class="err"><?= e($errors['title']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -80,16 +95,42 @@ $selAttendees = array_map('intval', (array)old('attendees', $curAttendees));
|
||||
|
||||
<div class="field full">
|
||||
<label>同行的人</label>
|
||||
<?php /* v10:名册人多时 checkbox 网格会拉得很长 —— 改为「chips + 弹窗选择」。
|
||||
attendees[] 的 checkbox 仍保留(在弹窗列表里,选中即提交),无 JS 时
|
||||
借 noscript 样式把弹窗平铺成普通勾选列表,提交语义完全不变。 */ ?>
|
||||
<?php if ($people): ?>
|
||||
<div class="feel-grid">
|
||||
<div class="att-chips" id="attChips">
|
||||
<?php foreach ($people as $p): ?>
|
||||
<label class="feel-item">
|
||||
<input type="checkbox" name="attendees[]" value="<?= (int)$p['id'] ?>"
|
||||
<?= in_array((int)$p['id'], $selAttendees, true) ? 'checked' : '' ?>>
|
||||
<span><?= e($p['shown'] ?? $p['name']) ?></span>
|
||||
</label>
|
||||
<?php if (in_array((int)$p['id'], $selAttendees, true)): ?>
|
||||
<span class="att-chip" data-id="<?= (int)$p['id'] ?>"><?= e($p['shown'] ?? $p['name']) ?><button type="button" class="att-x" data-id="<?= (int)$p['id'] ?>" title="移除">×</button></span>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<button type="button" class="btn btn-ghost btn-sm att-open-btn" id="attOpen">+ 添加观影人</button>
|
||||
<div class="att-modal" id="attModal" hidden>
|
||||
<div class="att-modal-box">
|
||||
<div class="att-modal-head">
|
||||
<b>选择观影人</b>
|
||||
<button type="button" class="att-close" id="attClose" title="关闭">×</button>
|
||||
</div>
|
||||
<input class="input" id="attSearch" type="text"
|
||||
placeholder="输入名字或拼音首字母,如 zy 找「张三」" autocomplete="off">
|
||||
<div class="att-list" id="attList">
|
||||
<?php foreach ($people as $p): ?>
|
||||
<label class="att-item"
|
||||
data-name="<?= e((string)$p['name']) ?>"
|
||||
data-shown="<?= e((string)($p['shown'] ?? '')) ?>">
|
||||
<input type="checkbox" name="attendees[]" value="<?= (int)$p['id'] ?>"
|
||||
<?= in_array((int)$p['id'], $selAttendees, true) ? 'checked' : '' ?>>
|
||||
<span><?= e($p['shown'] ?? $p['name']) ?></span>
|
||||
<span class="att-initials" hidden></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
<div class="att-empty" hidden>没有匹配的人。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<noscript><style>.att-open-btn { display: none; } .att-modal { position: static; display: block; background: none; padding: 0; } .att-modal-box { box-shadow: none; border: 1px solid var(--line); max-height: none; }</style></noscript>
|
||||
<?php else: ?>
|
||||
<span class="tip">名册里还没有人,先把家人加进名册再来记。</span>
|
||||
<?php endif; ?>
|
||||
@@ -138,3 +179,253 @@ $selAttendees = array_map('intval', (array)old('attendees', $curAttendees));
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php if ($people): ?>
|
||||
<!-- 观影人选择弹窗:chips 同步 + 拼音首字母联想(Intl pinyin 排序 + 23 锚字二分,零依赖) -->
|
||||
<script>
|
||||
(function () {
|
||||
var modal = document.getElementById('attModal');
|
||||
if (!modal) return;
|
||||
var openBtn = document.getElementById('attOpen');
|
||||
var closeBtn = document.getElementById('attClose');
|
||||
var search = document.getElementById('attSearch');
|
||||
var list = document.getElementById('attList');
|
||||
var chips = document.getElementById('attChips');
|
||||
var emptyTip = list.querySelector('.att-empty');
|
||||
|
||||
/* ---- 汉字 → 拼音首字母:锚字表 a..z(23 个,无 i/u/v 开头字),
|
||||
用拼音 collation 做二分定位;不支持的浏览器返回 null(只按名字搜) ---- */
|
||||
var initialsOf = (function () {
|
||||
var anchors = '阿八擦搭娥发嘎哈击喀垃妈拿哦啪期然撒塌挖昔压匝';
|
||||
var letters = 'abcdefghjklmnopqrstwxyz';
|
||||
var coll;
|
||||
try { coll = new Intl.Collator('zh-Hans-CN-u-co-pinyin'); } catch (e) { return null; }
|
||||
if (!coll || coll.compare('阿', '匝') >= 0) return null; // collation 没生效
|
||||
return function (s) {
|
||||
var out = '';
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
var ch = s[i];
|
||||
if (/[a-zA-Z]/.test(ch)) { out += ch.toUpperCase(); continue; }
|
||||
if (ch.charCodeAt(0) < 0x2E80) continue; // 非 CJK:不产字母
|
||||
var lo = 0, hi = anchors.length - 1, best = -1;
|
||||
while (lo <= hi) {
|
||||
var mid = (lo + hi) >> 1;
|
||||
if (coll.compare(ch, anchors[mid]) >= 0) { best = mid; lo = mid + 1; }
|
||||
else { hi = mid - 1; }
|
||||
}
|
||||
if (best >= 0) out += letters[best];
|
||||
}
|
||||
return out;
|
||||
};
|
||||
})();
|
||||
|
||||
/* 预计算每个人的首字母串,挂在 data-initials 上 */
|
||||
Array.prototype.forEach.call(list.querySelectorAll('.att-item'), function (el) {
|
||||
var s = (el.getAttribute('data-name') || '') + (el.getAttribute('data-shown') || '');
|
||||
var ini = initialsOf ? initialsOf(s) : '';
|
||||
el.setAttribute('data-initials', ini.toLowerCase());
|
||||
var badge = el.querySelector('.att-initials');
|
||||
if (badge && ini) { badge.textContent = ini; badge.hidden = false; }
|
||||
});
|
||||
|
||||
function syncChips() {
|
||||
if (!chips) return;
|
||||
chips.innerHTML = '';
|
||||
Array.prototype.forEach.call(list.querySelectorAll('.att-item input:checked'), function (box) {
|
||||
var item = box.closest('.att-item');
|
||||
var label = item.querySelector('span').textContent;
|
||||
var id = box.value;
|
||||
var chip = document.createElement('span');
|
||||
chip.className = 'att-chip';
|
||||
chip.setAttribute('data-id', id);
|
||||
chip.textContent = label;
|
||||
var x = document.createElement('button');
|
||||
x.type = 'button'; x.className = 'att-x'; x.textContent = '×';
|
||||
x.title = '移除'; x.setAttribute('data-id', id);
|
||||
chip.appendChild(x);
|
||||
chips.appendChild(chip);
|
||||
});
|
||||
}
|
||||
|
||||
chips.addEventListener('click', function (e) {
|
||||
var x = e.target.closest ? e.target.closest('.att-x') : null;
|
||||
if (!x) return;
|
||||
var id = x.getAttribute('data-id');
|
||||
Array.prototype.forEach.call(list.querySelectorAll('.att-item input'), function (box) {
|
||||
if (box.value === id) box.checked = false;
|
||||
});
|
||||
syncChips();
|
||||
});
|
||||
|
||||
function applyFilter() {
|
||||
var q = (search.value || '').trim().toLowerCase();
|
||||
var shown = 0;
|
||||
Array.prototype.forEach.call(list.querySelectorAll('.att-item'), function (el) {
|
||||
var hit = !q ||
|
||||
(el.getAttribute('data-name') || '').toLowerCase().indexOf(q) >= 0 ||
|
||||
(el.getAttribute('data-shown') || '').toLowerCase().indexOf(q) >= 0 ||
|
||||
(el.getAttribute('data-initials') || '').indexOf(q) >= 0;
|
||||
el.hidden = !hit;
|
||||
if (hit) shown++;
|
||||
});
|
||||
emptyTip.hidden = shown > 0;
|
||||
}
|
||||
|
||||
function openModal() { modal.hidden = false; search.value = ''; applyFilter(); syncChips(); search.focus(); }
|
||||
function closeModal() { modal.hidden = true; }
|
||||
openBtn.addEventListener('click', openModal);
|
||||
closeBtn.addEventListener('click', closeModal);
|
||||
modal.addEventListener('click', function (e) { if (e.target === modal) closeModal(); });
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape' && !modal.hidden) closeModal();
|
||||
});
|
||||
search.addEventListener('input', applyFilter);
|
||||
|
||||
/* 选一个 = 勾上 + 出 chips + 关弹窗(再添加就再点一次「+ 添加观影人」);
|
||||
在弹窗里取消勾选只同步 chips,不关弹窗 */
|
||||
list.addEventListener('change', function (e) {
|
||||
if (!e.target || e.target.tagName !== 'INPUT') return;
|
||||
syncChips();
|
||||
if (e.target.checked) closeModal();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- 豆瓣自动补充:下拉联想(320ms 防抖 + 中文输入法组字期不请求)+ 一键抓取 -->
|
||||
<script>
|
||||
(function () {
|
||||
var DB_URL = <?= json_encode(url('movies/douban')) ?>;
|
||||
var titleEl = document.getElementById('title');
|
||||
var box = document.getElementById('dbSuggest');
|
||||
var fetchBtn = document.getElementById('dbFetch');
|
||||
var metaEl = document.getElementById('dbMeta');
|
||||
var posterKeyEl = document.getElementById('dbPosterKey');
|
||||
var posterWrap = document.getElementById('dbPosterWrap');
|
||||
var posterImg = document.getElementById('dbPosterImg');
|
||||
var infoEl = document.getElementById('info');
|
||||
if (!titleEl || !box || !fetchBtn || !metaEl) return;
|
||||
|
||||
var lastPosterKey = ''; // 本次会话里最近一次抓到的海报键(下次抓取时回传清理)
|
||||
var timer = null;
|
||||
var composing = false;
|
||||
var seq = 0; // 丢弃过期响应
|
||||
|
||||
titleEl.addEventListener('compositionstart', function () { composing = true; });
|
||||
titleEl.addEventListener('compositionend', function () { composing = false; schedule(); });
|
||||
titleEl.addEventListener('input', function () {
|
||||
if (composing) return; // 组字期间的拼音串没有意义,也不劫持回车
|
||||
schedule();
|
||||
});
|
||||
document.addEventListener('click', function (e) {
|
||||
if (!box.hidden && !box.contains(e.target) && e.target !== titleEl) hideBox();
|
||||
});
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape') hideBox();
|
||||
});
|
||||
|
||||
function schedule() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(suggest, 320);
|
||||
}
|
||||
function hideBox() { box.hidden = true; box.innerHTML = ''; }
|
||||
|
||||
function suggest() {
|
||||
var q = titleEl.value.trim();
|
||||
if (q === '') { hideBox(); return; }
|
||||
var my = ++seq;
|
||||
getJson(DB_URL + '&action=suggest&q=' + encodeURIComponent(q), function (data, err) {
|
||||
if (my !== seq) return; // 过期响应丢弃
|
||||
if (err) return; // 联想失败静默(正片抓取会给出明确报错)
|
||||
renderItems(data && data.items ? data.items : []);
|
||||
});
|
||||
}
|
||||
|
||||
function renderItems(items) {
|
||||
box.innerHTML = '';
|
||||
if (!items.length) { hideBox(); return; }
|
||||
items.forEach(function (it) {
|
||||
var btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'db-item';
|
||||
if (it.thumb) {
|
||||
var im = document.createElement('img');
|
||||
im.src = it.thumb; im.alt = ''; im.loading = 'lazy';
|
||||
btn.appendChild(im);
|
||||
}
|
||||
var tx = document.createElement('span');
|
||||
tx.className = 'db-item-tx';
|
||||
var b = document.createElement('b');
|
||||
// 候选文本来自豆瓣 —— 一律 textContent 插入,绝不拼 innerHTML(豆瓣侧内容可注入脚本)
|
||||
b.textContent = it.title || '(无片名)';
|
||||
tx.appendChild(b);
|
||||
var bits = [];
|
||||
if (it.sub_title && it.sub_title !== it.title) bits.push(it.sub_title);
|
||||
if (it.year) bits.push(it.year);
|
||||
if (it.kind) bits.push(it.kind);
|
||||
if (bits.length) {
|
||||
var sm = document.createElement('small');
|
||||
sm.textContent = bits.join(' · ');
|
||||
tx.appendChild(sm);
|
||||
}
|
||||
btn.appendChild(tx);
|
||||
btn.addEventListener('click', function () { hideBox(); fetchById(it.id); });
|
||||
box.appendChild(btn);
|
||||
});
|
||||
box.hidden = false;
|
||||
}
|
||||
|
||||
function fetchById(id) {
|
||||
doFetch(DB_URL + '&id=' + encodeURIComponent(id));
|
||||
}
|
||||
fetchBtn.addEventListener('click', function () {
|
||||
var q = titleEl.value.trim();
|
||||
if (q === '') { titleEl.focus(); return; }
|
||||
doFetch(DB_URL + '&q=' + encodeURIComponent(q));
|
||||
});
|
||||
|
||||
function doFetch(urlWithQ) {
|
||||
if (lastPosterKey) urlWithQ += '&old_poster=' + encodeURIComponent(lastPosterKey);
|
||||
fetchBtn.disabled = true;
|
||||
var my = ++seq;
|
||||
getJson(urlWithQ, function (data, err) {
|
||||
fetchBtn.disabled = false;
|
||||
if (my !== seq) return;
|
||||
if (err || !data) { alert(err || '抓取失败,请稍后再试'); return; }
|
||||
if (data.error) { alert(data.error); return; }
|
||||
apply(data);
|
||||
});
|
||||
}
|
||||
|
||||
function apply(data) {
|
||||
if (data.title) titleEl.value = data.title;
|
||||
if (data.meta) {
|
||||
metaEl.value = JSON.stringify(data.meta);
|
||||
// 剧情简介填进「简介」,但只填空白的 —— 用户已经写了就不覆盖
|
||||
if (infoEl && data.meta.plot && infoEl.value.trim() === '') infoEl.value = data.meta.plot;
|
||||
}
|
||||
if (data.poster_key) {
|
||||
lastPosterKey = data.poster_key;
|
||||
posterKeyEl.value = data.poster_key;
|
||||
if (data.poster) {
|
||||
posterImg.src = data.poster;
|
||||
posterWrap.hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getJson(u, cb) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', u, true);
|
||||
xhr.onload = function () {
|
||||
var data = null, err = '';
|
||||
try { data = JSON.parse(xhr.responseText); }
|
||||
catch (e) { err = '返回内容异常'; }
|
||||
if (xhr.status >= 400) err = (data && data.error) ? data.error : ('请求失败(' + xhr.status + ')');
|
||||
cb(data, err);
|
||||
};
|
||||
xhr.onerror = function () { cb(null, '网络异常'); };
|
||||
xhr.send();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
$canWrite = \App\Auth::canWrite();
|
||||
$hasPoster = !empty($m['poster_key']);
|
||||
$hasTicket = !empty($m['ticket_key']);
|
||||
// 豆瓣元数据(v10):整体 JSON 存 douban_meta,随用随解;解不开就当没有
|
||||
$doubanMeta = [];
|
||||
if (!empty($m['douban_meta'])) {
|
||||
$decoded = json_decode((string)$m['douban_meta'], true);
|
||||
if (is_array($decoded)) {
|
||||
$doubanMeta = $decoded;
|
||||
}
|
||||
}
|
||||
$watchTxt = \App\Movie::formatWatch($m['starts_at'], $m['ends_at'] ?? null);
|
||||
$fmtNum = static function ($v): string {
|
||||
if ($v === null) {
|
||||
@@ -57,6 +65,16 @@ $feelTags = static function (array $keys) use ($feelCat) {
|
||||
<?php return ob_get_clean();
|
||||
};
|
||||
|
||||
/** 静态 10 星展示(v10):左 n 颗实心金黄,其余空心灰;n 越界按 0/10 兜底 */
|
||||
$starsHtml = static function (int $n): string {
|
||||
$n = max(0, min(10, $n));
|
||||
$out = '<span class="stars-disp" aria-hidden="true">';
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$out .= '<span class="' . ($i <= $n ? 'd-on' : 'd-off') . '">' . ($i <= $n ? '★' : '☆') . '</span>';
|
||||
}
|
||||
return $out . '</span>';
|
||||
};
|
||||
|
||||
/** 我的评价表单(打分 + 正文 + 感受),details 按需展开;写评价与修改共用这一份 */
|
||||
$rvForm = static function (string $summary, bool $open) use ($m, $myReview, $feelPick, $rvError) {
|
||||
ob_start(); ?>
|
||||
@@ -67,12 +85,14 @@ $rvForm = static function (string $summary, bool $open) use ($m, $myReview, $fee
|
||||
<input type="hidden" name="id" value="<?= (int)$m['id'] ?>">
|
||||
<div class="rv-rating-row">
|
||||
<span class="rv-rating-label">我的评分</span>
|
||||
<span class="rv-scale" role="radiogroup" aria-label="评分,1 分到 10 分">
|
||||
<?php /* v10:10 星制。DOM 倒序(10..1)+ CSS row-reverse,视觉 1..10 从左到右;
|
||||
点亮由 JS 加 .lit(含悬停预览), radios 保持 name="rating" 原语义。 */ ?>
|
||||
<span class="rv-scale rv-stars no-js" role="radiogroup" aria-label="评分,1 分到 10 分">
|
||||
<?php $myRating = (int)($myReview['rating'] ?? 0); ?>
|
||||
<?php for ($i = 1; $i <= 10; $i++): ?>
|
||||
<label class="rv-num" title="<?= $i ?> 分">
|
||||
<?php for ($i = 10; $i >= 1; $i--): ?>
|
||||
<label class="rv-star" data-v="<?= $i ?>" title="<?= $i ?> 分 · <?= e(\App\MovieReview::ratingWord($i)) ?>">
|
||||
<input type="radio" name="rating" value="<?= $i ?>"<?= $myRating === $i ? ' checked' : '' ?>>
|
||||
<span><?= $i ?></span>
|
||||
<span class="st-glyph st-off" aria-hidden="true">☆</span><span class="st-glyph st-on" aria-hidden="true">★</span>
|
||||
</label>
|
||||
<?php endfor; ?>
|
||||
</span>
|
||||
@@ -157,6 +177,30 @@ $commentBox = static function (int $reviewId, int $parentId, string $summary) us
|
||||
<?php endif; ?>
|
||||
<span>👥 观影人 <?= count($m['attendees']) ?> 人</span>
|
||||
</div>
|
||||
<?php if ($doubanMeta): ?>
|
||||
<div class="db-meta">
|
||||
<?php if (!empty($doubanMeta['rating'])): ?>
|
||||
<span class="db-rating" title="豆瓣评分">豆瓣 <b><?= e((string)$doubanMeta['rating']) ?></b></span>
|
||||
<?php endif; ?>
|
||||
<?php foreach ([
|
||||
'年份' => (string)($doubanMeta['year'] ?? ''),
|
||||
'类型' => (string)($doubanMeta['genre'] ?? ''),
|
||||
'片长' => (string)($doubanMeta['runtime'] ?? ''),
|
||||
'导演' => (string)($doubanMeta['director'] ?? ''),
|
||||
'主演' => (string)($doubanMeta['actors'] ?? ''),
|
||||
'制片国家/地区' => (string)($doubanMeta['country'] ?? ''),
|
||||
'又名' => (string)($doubanMeta['alias'] ?? ''),
|
||||
] as $dbLbl => $dbVal): ?>
|
||||
<?php if ($dbVal !== ''): ?>
|
||||
<span class="db-line"><span class="db-label"><?= $dbLbl ?></span><?= e($dbVal) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!empty($doubanMeta['douban_url'])): ?>
|
||||
<a class="db-link" href="<?= e((string)$doubanMeta['douban_url']) ?>"
|
||||
target="_blank" rel="noopener noreferrer">在豆瓣查看 ↗</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($m['info'])): ?>
|
||||
<div class="info-text"><?= nl2br(e($m['info'])) ?></div>
|
||||
<?php endif; ?>
|
||||
@@ -277,7 +321,7 @@ $commentBox = static function (int $reviewId, int $parentId, string $summary) us
|
||||
<?php if ($rvMine): ?><span class="rv-mine">我</span><?php endif; ?>
|
||||
<span class="rv-time"><?= e(substr((string)$rv['created_at'], 0, 16)) ?></span>
|
||||
</span>
|
||||
<span class="rv-score" title="<?= e(\App\MovieReview::ratingWord($rvRate)) ?>"><?= $rvRate ?><span class="rv-score-max">/10</span></span>
|
||||
<span class="rv-score" title="<?= e(\App\MovieReview::ratingWord($rvRate)) ?>"><?= $starsHtml($rvRate) ?><span class="rv-score-max"><?= $rvRate ?>/10</span></span>
|
||||
<?php if ($rvMine && $canWrite): ?>
|
||||
<form method="post" action="<?= e(url('movies/review_del')) ?>" class="rv-del"
|
||||
onsubmit="return confirm('删除我的这条评价?下面的评论也会一起删除,不可恢复。')">
|
||||
@@ -466,23 +510,42 @@ $commentBox = static function (int $reviewId, int $parentId, string $summary) us
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canWrite): ?>
|
||||
<!-- 打分实时提示「几分 · 怎么样」;纯增强,radio 没 JS 也能选 -->
|
||||
<!-- 打分:星星点亮 + 悬停预览 + 实时提示「几分 · 怎么样」;radio 没 JS 也能选(:has 兜底点亮) -->
|
||||
<script>
|
||||
(function () {
|
||||
var form = document.getElementById('reviewForm');
|
||||
var word = document.getElementById('rvWord');
|
||||
if (!form || !word) return;
|
||||
var scale = form.querySelector('.rv-stars');
|
||||
if (scale) scale.classList.remove('no-js');
|
||||
var WORDS = <?= json_encode(\App\MovieReview::ratingWords(), JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) ?>;
|
||||
function sync() {
|
||||
function pickedV() {
|
||||
var picked = form.querySelector('input[name="rating"]:checked');
|
||||
if (!picked) { word.textContent = '未评分'; word.classList.remove('is-set'); return; }
|
||||
var v = parseInt(picked.value, 10);
|
||||
return picked ? parseInt(picked.value, 10) : 0;
|
||||
}
|
||||
function paint(v) {
|
||||
if (!scale) return;
|
||||
Array.prototype.forEach.call(scale.querySelectorAll('.rv-star'), function (el) {
|
||||
el.classList.toggle('lit', parseInt(el.getAttribute('data-v'), 10) <= v);
|
||||
});
|
||||
}
|
||||
function sync() {
|
||||
var v = pickedV();
|
||||
if (!v) { word.textContent = '未评分'; word.classList.remove('is-set'); paint(0); return; }
|
||||
word.textContent = v + ' 分 · ' + (WORDS[v - 1] || '');
|
||||
word.classList.add('is-set');
|
||||
paint(v);
|
||||
}
|
||||
Array.prototype.forEach.call(form.querySelectorAll('input[name="rating"]'), function (el) {
|
||||
el.addEventListener('change', sync);
|
||||
});
|
||||
if (scale) {
|
||||
scale.addEventListener('mouseover', function (e) {
|
||||
var lab = e.target.closest ? e.target.closest('.rv-star') : null;
|
||||
if (lab) paint(parseInt(lab.getAttribute('data-v'), 10));
|
||||
});
|
||||
scale.addEventListener('mouseleave', function () { paint(pickedV()); });
|
||||
}
|
||||
sync();
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user