广场帖子、专题页评论改为先交后台审核:审核中只自己可见并挂状态,通过后所有人可见,未通过显示原因(v26110242)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -414,6 +414,10 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
.ci-n .lk{margin-left:auto}
|
||||
.ci-t{margin:3px 0 0;font-size:14.5px;line-height:1.65;color:#2F2624;word-break:break-word}
|
||||
.ci-s{margin-top:3px;font-size:11.5px;color:#B8A49E}
|
||||
/* 11-03 用户评论要后台审核:自己的评论挂状态 */
|
||||
.ci-st{display:inline-block;margin-top:5px;padding:0 7px;border-radius:4px;font-size:11px;line-height:18px;font-weight:600}
|
||||
.ci-st.pending{background:#FFF4E5;color:#E08A00}.ci-st.rejected{background:#F2F3F5;color:#86909C}.ci-st.local{background:#F2F3F5;color:#A0A6AE}
|
||||
.ci.mine.rejected .ci-t{color:#A0A6AE}
|
||||
.rp{margin-top:8px;padding:8px 10px;border-radius:10px;background:#F8F3EF;font-size:13px;line-height:1.65;color:#3A302C}
|
||||
.rp p{margin:0 0 4px}
|
||||
.rp p:last-child{margin-bottom:0}
|
||||
@@ -571,10 +575,10 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
<div id="sheet" role="dialog" aria-modal="true"><i class="sg"></i><div class="sbd" id="sbd"></div></div>
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script src="topics.js?v=26110241"></script>
|
||||
<script src="data.js?v=26110241"></script>
|
||||
<script src="feed.js?v=26110241"></script>
|
||||
<script src="ceshi/meta.js?v=26110241"></script>
|
||||
<script src="topics.js?v=26110242"></script>
|
||||
<script src="data.js?v=26110242"></script>
|
||||
<script src="feed.js?v=26110242"></script>
|
||||
<script src="ceshi/meta.js?v=26110242"></script>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
@@ -640,7 +644,7 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
var CMD = null, CMERR = false;
|
||||
/* 头像编码:数字 = av/NNNN.webp(旧代码头像);'av:c012' = av/c012.webp(卡通/可爱卡通);'/…' = 站内绝对路径(内置头像库 /_bridge/avatars/);其余 = assets/img/mom/xxx.jpg */
|
||||
var avP = function (a) { return typeof a === 'number' ? 'av/' + ('000' + a).slice(-4) + '.webp' : a.indexOf('av:') === 0 ? 'av/' + a.slice(3) + '.webp' : a.charAt(0) === '/' ? a : '../assets/img/mom/' + a + '.jpg'; };
|
||||
fetch('cm.json?v=26110241').then(function (r) { return r.json(); }).then(function (j) {
|
||||
fetch('cm.json?v=26110242').then(function (r) { return r.json(); }).then(function (j) {
|
||||
CMD = j; if (openId && NBY[openId]) { renderComments(NBY[openId]); syncBar(NBY[openId]); }
|
||||
}).catch(function () { CMERR = true; if (openId && NBY[openId]) renderComments(NBY[openId]); });
|
||||
function commentsOf(n) {
|
||||
@@ -663,8 +667,24 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
var liked = function (id) { return !!ME.like[id]; };
|
||||
var likeN = function (n) { return n.likes + (liked(n.id) ? 1 : 0); };
|
||||
var favN = function (n) { return Math.round(n.likes * .38) + 3 + (ME.fav[n.id] ? 1 : 0); };
|
||||
var myCm = function (id) { return ME.cm[id] || []; };
|
||||
var cmN = function (n) { return commentsOf(n).length + myCm(n.id).length; };
|
||||
/* 11-03 用户:评论要后台审核通过才对外公开。服务器 /plaza/comments:list = 别人已通过的;mine = 我在这篇下发的(含审核中 / 未通过)。
|
||||
ME.cm 里没有 id 的是 11-03 以前只存本机的旧评论,从没公开过,照旧只给自己看(标「仅自己可见」)。 */
|
||||
var RC = {};
|
||||
var myCm = function (id) {
|
||||
var old = (ME.cm[id] || []).filter(function (c) { return !c.id; }).map(function (c) { return { t: c.t, ts: c.ts, s: c.s, st: 'local' }; });
|
||||
var srv = RC[id] ? RC[id].mine.map(function (c) { return { id: c.id, t: c.text, ts: c.at, s: c.stage, st: c.status, why: c.reason }; }) : [];
|
||||
return old.concat(srv.reverse());
|
||||
};
|
||||
var realCm = function (id) { return RC[id] ? RC[id].list : []; };
|
||||
var cmN = function (n) { return commentsOf(n).length + realCm(n.id).length + myCm(n.id).filter(function (c) { return c.st !== 'rejected'; }).length; };
|
||||
function loadRC(n) {
|
||||
var u = '/api/mp/public/mama-box/plaza/comments?kind=post&target=' + encodeURIComponent(n.id) + (OPENID ? '&openid=' + encodeURIComponent(OPENID) : '');
|
||||
fetch(u).then(function (r) { return r.json(); }).then(function (j) {
|
||||
if (!j || j.code !== 200) return;
|
||||
RC[n.id] = j.result;
|
||||
if (openId === n.id) { renderComments(n); syncBar(n); }
|
||||
}).catch(function () {});
|
||||
}
|
||||
|
||||
function toast(msg) {
|
||||
var t = $('#toast'); t.textContent = msg; t.classList.add('show');
|
||||
@@ -1121,8 +1141,9 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
function commentHTML(c, mine) {
|
||||
if (mine) {
|
||||
var st = c.s || myStage();
|
||||
return '<div class="ci mine"><span class="me">我</span><div class="ci-b"><div class="ci-n"><b>' + esc(MYNAME) + '</b><span class="mt">我</span></div>' +
|
||||
'<p class="ci-t">' + esc(c.t) + '</p>' + (st ? '<div class="ci-s">' + esc(st) + '</div>' : '') + '</div></div>'; /* 11-02 自己的评论也不显示时间 */
|
||||
var tag = c.st === 'pending' ? '<span class="ci-st pending">审核中 · 通过后大家才能看到</span>' : c.st === 'rejected' ? '<span class="ci-st rejected">未通过' + (c.why ? ':' + esc(c.why) : '') + '</span>' : c.st === 'local' ? '<span class="ci-st local">仅自己可见</span>' : '';
|
||||
return '<div class="ci mine' + (c.st === 'rejected' ? ' rejected' : '') + '"><span class="me">我</span><div class="ci-b"><div class="ci-n"><b>' + esc(MYNAME) + '</b><span class="mt">我</span></div>' +
|
||||
'<p class="ci-t">' + esc(c.t) + '</p>' + (st ? '<div class="ci-s">' + esc(st) + '</div>' : '') + tag + '</div></div>'; /* 11-02 自己的评论也不显示时间 */
|
||||
}
|
||||
var on = !!ME.cl[c.key], n = c.likes + (on ? 1 : 0);
|
||||
var rp = c.r.length ? '<div class="rp">' + c.r.map(function (x) { return '<p><b>' + esc(x.n) + '</b>' + (x.au ? '<span class="au">作者</span>' : '') + ':' + esc(x.t) + '</p>'; }).join('') + '</div>' : '';
|
||||
@@ -1141,7 +1162,9 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
var mine = myCm(n.id).slice().reverse(), cs = commentsOf(n);
|
||||
$('#cmh').innerHTML = '评论 <small>共 ' + cmN(n) + ' 条</small>';
|
||||
if (!CMD && !n.real && !CMERR) { $('#cml').innerHTML = mine.map(function (c) { return commentHTML(c, true); }).join('') + '<div class="cm-ld">评论加载中…</div>'; return; }
|
||||
$('#cml').innerHTML = mine.map(function (c) { return commentHTML(c, true); }).join('') + cs.map(function (c) { return commentHTML(c); }).join('');
|
||||
/* 别人发的、已审核通过的真实评论排在模拟评论前面 */
|
||||
var rl = realCm(n.id).map(function (c) { return { key: 'r:' + c.id, n: c.nickname || '孕妈', av: c.avatar || '', s: c.stage, t: c.text, likes: 0, r: [] }; });
|
||||
$('#cml').innerHTML = mine.map(function (c) { return commentHTML(c, true); }).join('') + rl.concat(cs).map(function (c) { return commentHTML(c); }).join('');
|
||||
}
|
||||
function syncBar(n, popK) {
|
||||
var lv = $('#blk'), fv = $('#bfv'), on = liked(n.id), fo = !!ME.fav[n.id];
|
||||
@@ -1170,7 +1193,7 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
'<div class="cm" id="cmw"><div class="cm-h" id="cmh"></div>' +
|
||||
'<div class="cm-in"><span class="me">我</span><button type="button" id="cmgo">留下你的温柔一句…</button></div>' +
|
||||
'<div id="cml"></div><div class="cm-end">— 没有更多评论了 —</div></div>';
|
||||
renderComments(n); syncBar(n);
|
||||
renderComments(n); syncBar(n); loadRC(n);
|
||||
$('#cin').value = ''; $('#bar').classList.remove('typing'); $('#csend').disabled = true;
|
||||
$('#dsc').scrollTop = 0; $('#dnav').classList.remove('on');
|
||||
var dt = $('#dt'); dt.classList.add('show'); dt.setAttribute('aria-hidden', 'false');
|
||||
@@ -1239,13 +1262,22 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
|
||||
$('#csend').addEventListener('click', send);
|
||||
function send() {
|
||||
var n = NBY[openId], v = cin.value.trim();
|
||||
if (!n || !v) return;
|
||||
(ME.cm[n.id] = myCm(n.id)).push({ t: v.slice(0, 200), ts: Date.now(), s: myStage() });
|
||||
save(); haptic();
|
||||
cin.value = ''; $('#csend').disabled = true; cin.blur(); $('#bar').classList.remove('typing');
|
||||
renderComments(n); syncBar(n);
|
||||
var w = $('#cmw'); if (w) $('#dsc').scrollTo({ top: w.offsetTop - 50, behavior: 'smooth' });
|
||||
toast('评论已发出');
|
||||
if (!n || !v || send.busy) return;
|
||||
if (!OPENID) { toast('请在小程序里打开后再评论'); return; }
|
||||
/* 11-03:评论先交后台审核,通过后才公开;审核中只有自己看得到 */
|
||||
send.busy = true; $('#csend').disabled = true;
|
||||
fetch(API + '/comment?' + idq(), { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ kind: 'post', target: n.id, title: n.title, text: v.slice(0, 200), stage: myStage() }) })
|
||||
.then(function (r) { return r.json(); }).then(function (j) {
|
||||
send.busy = false;
|
||||
if (!j || j.code !== 200) { $('#csend').disabled = !cin.value.trim(); toast((j && j.message) || '没发出去,稍后再试'); return; }
|
||||
var rc = RC[n.id] || (RC[n.id] = { list: [], mine: [] }); rc.mine.unshift(j.result);
|
||||
haptic();
|
||||
cin.value = ''; $('#csend').disabled = true; cin.blur(); $('#bar').classList.remove('typing');
|
||||
if (openId === n.id) { renderComments(n); syncBar(n); }
|
||||
var w = $('#cmw'); if (w) $('#dsc').scrollTo({ top: w.offsetTop - 50, behavior: 'smooth' });
|
||||
toast('已提交,审核通过后大家就能看到');
|
||||
}).catch(function () { send.busy = false; $('#csend').disabled = !cin.value.trim(); toast('网络不太好,稍后再试'); });
|
||||
}
|
||||
|
||||
/* ================= 投稿(2026-11-01) =================
|
||||
|
||||
Reference in New Issue
Block a user