悄悄话:转发卡星空图、引导箭头指向右上角「···」、自己的留言审核中也显示(标审核中)、留言标题后加小头像 (v26110634)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110633';
|
||||
var VER = '26110634';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -4847,10 +4847,9 @@
|
||||
const q = new URLSearchParams(location.search);
|
||||
if (on) q.set('wh', '1'); else { q.delete('wh'); q.delete('wc'); }
|
||||
const u = location.pathname + (q.toString() ? '?' + q : '') + location.hash;
|
||||
if (u === location.pathname + location.search + location.hash) return;
|
||||
history.replaceState(history.state, '', u);
|
||||
if (u !== location.pathname + location.search + location.hash) history.replaceState(history.state, '', u);
|
||||
const th = window.MB_WH_THEME ? window.MB_WH_THEME() : null;
|
||||
if (window.wxAuth && wxAuth.reportLocation) wxAuth.reportLocation(on ? { title: th ? '本周话题:' + th.name : '孕妈悄悄话' } : {});
|
||||
if (window.wxAuth && wxAuth.reportLocation) wxAuth.reportLocation(on ? { title: th ? '本周话题:' + th.name : '孕妈悄悄话', imageUrl: new URL('assets/share/wh-star.jpg', document.baseURI).href } : {}); /* 转发卡 = 星空图 */
|
||||
} catch (e) {}
|
||||
}
|
||||
function openPage() {
|
||||
@@ -5008,7 +5007,7 @@
|
||||
/* 11-07 悄悄话第 2 步(用户定):星空页「说一句」并入留言区 —— 发成置顶笔记下的留言(先审后发),赞够门槛自动挂星 */
|
||||
if (window.MBWhCm) {
|
||||
MBWhCm.post(t, data.week)
|
||||
.then(m => { if (m) { toast(m); return; } closeModal(); toast('已提交,审核通过后才会显示'); })
|
||||
.then(m => { if (m) { toast(m); return; } closeModal(); toast('已发出,审核通过后大家就能看到'); })
|
||||
.then(() => { busy = false; btn.disabled = false; btn.textContent = '悄悄发出'; });
|
||||
return;
|
||||
}
|
||||
|
||||
16
js/wh-cm.css
16
js/wh-cm.css
@@ -93,9 +93,10 @@ p.wcm-mf{display:block;color:#FFC07A}
|
||||
/* 转发引导 */
|
||||
.wsh-g{position:absolute;inset:0;z-index:20;background:rgba(8,5,20,.72);animation:wshIn .25s ease}
|
||||
@keyframes wshIn{from{opacity:0}}
|
||||
.wsh-arrow{position:absolute;right:26px;top:calc(10px + env(safe-area-inset-top));width:60px;height:70px;
|
||||
background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 70' fill='none' stroke='%23FFD9A0' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M8 66C12 36 28 18 48 8' stroke-dasharray='6 6'/%3E%3Cpath d='M36 6l13 2-4 12'/%3E%3C/svg%3E") center/contain no-repeat;animation:wshA 1.2s ease-in-out infinite}
|
||||
@keyframes wshA{50%{transform:translate(4px,-4px)}}
|
||||
/* 11-07 用户:箭头要指到小程序右上角胶囊的「···」(胶囊在页面顶上、右边 7px 起宽 87px,「···」在它左半边)→ 箭头尖顶到页面最上沿、对准右边 ~70px */
|
||||
.wsh-arrow{position:absolute;right:48px;top:calc(2px + env(safe-area-inset-top));width:46px;height:84px;
|
||||
background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 46 84' fill='none' stroke='%23FFD9A0' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 80C6 52 18 24 33 6' stroke-dasharray='6 6'/%3E%3Cpath d='M22 10.5L33 4l-1 13'/%3E%3C/svg%3E") center/contain no-repeat;animation:wshA 1.2s ease-in-out infinite}
|
||||
@keyframes wshA{50%{transform:translateY(-6px)}}
|
||||
.wsh-c{position:absolute;left:28px;right:28px;top:120px;padding:22px 20px 18px;border-radius:22px;text-align:center;color:#F4ECFF;
|
||||
background:linear-gradient(#2E2350,#1F1738);box-shadow:inset 0 0 0 1px rgba(255,214,170,.25),0 20px 50px rgba(0,0,0,.5)}
|
||||
.wsh-c b{font-size:18px;color:#FFD9A0}
|
||||
@@ -158,3 +159,12 @@ p.wcm-mf{display:block;color:#FFC07A}
|
||||
.wh-page .wsk-topic{gap:10px;margin-top:12px;padding:6px 18px 6px 6px}
|
||||
.wh-page .wsk-topic em{padding:3px 11px;font-size:13px}
|
||||
.wh-page .wsk-topic b{font-size:18px;letter-spacing:1px}
|
||||
|
||||
/* 11-07:自己的留言/回复在审核中 → 名字后标「审核中」(只有自己看得到) */
|
||||
.wcm-pend{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:99px;font-style:normal;font-size:11px;font-weight:700;line-height:17px;vertical-align:1px;color:#FFD9A0;background:rgba(255,200,140,.14);border:1px solid rgba(255,210,160,.3)}
|
||||
/* 「妈妈们的留言」后面的小头像 */
|
||||
.wcm-nm .wcm-pend{margin-left:0}
|
||||
.wcs-avs{display:inline-flex;align-self:center;margin-left:-2px}
|
||||
.wcs-avs:empty{display:none}
|
||||
.wcs-avs img{width:20px;height:20px;border-radius:50%;object-fit:cover;border:1.5px solid #3A2C57;background:#4A3A6A}
|
||||
.wcs-avs img+img{margin-left:-7px}
|
||||
|
||||
25
js/wh-cm.js
25
js/wh-cm.js
@@ -35,7 +35,7 @@
|
||||
var sh = document.createElement('div');
|
||||
sh.className = 'wcs'; sh.id = 'wcs'; sh.setAttribute('aria-hidden', 'true');
|
||||
sh.innerHTML = '<div class="wcs-p" role="dialog" aria-label="妈妈们的留言">' +
|
||||
'<div class="wcs-hd"><i class="wcs-grab" aria-hidden="true"></i><div class="wcs-tt"><b>妈妈们的留言</b><span id="wcmN"></span><i class="wcs-up">上滑看看</i>' +
|
||||
'<div class="wcs-hd"><i class="wcs-grab" aria-hidden="true"></i><div class="wcs-tt"><b>妈妈们的留言</b><span class="wcs-avs" id="wcmAv" aria-hidden="true"></span><span id="wcmN"></span><i class="wcs-up">上滑看看</i>' +
|
||||
'<button type="button" class="wcs-x" aria-label="收起"><svg viewBox="0 0 24 24" width="14" height="14"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg></button></div>' +
|
||||
'<div class="wcs-rule"><svg viewBox="0 0 20 20"><path d="M10 .5C10.9 7.4 12.6 9.1 19.5 10 12.6 10.9 10.9 12.6 10 19.5 9.1 12.6 7.4 10.9.5 10 7.4 9.1 9.1 7.4 10 .5Z"/></svg><span>留言被赞 <b id="wcmRuleN">6</b> 次,就会变成一颗星星挂上去</span></div>' +
|
||||
'<div class="wcm-tb" role="tablist"><button type="button" class="on" data-wso="hot">最热</button><button type="button" data-wso="new">最新</button><button type="button" data-wso="wk">同孕周</button></div></div>' +
|
||||
@@ -69,7 +69,7 @@
|
||||
function repOf(c, me) { return { p: c.parent, n: me ? '我' : (c.nickname || '孕妈'), me: me, to: c.parentName, t: c.text, ts: c.at, st: me ? c.status : '' }; }
|
||||
function load() {
|
||||
if (loading || SIM) return; loading = true;
|
||||
fetch('guangchang/cm.json?v=26110633').then(function (r) { return r.json(); }).then(function (j) {
|
||||
fetch('guangchang/cm.json?v=26110634').then(function (r) { return r.json(); }).then(function (j) {
|
||||
var PP = j.p;
|
||||
SIM = (j.c[PID] || []).map(function (c, k) {
|
||||
var p = PP[c[0]];
|
||||
@@ -85,8 +85,8 @@
|
||||
.then(function (r) { return r.json(); }).then(function (j) {
|
||||
var R = j && j.code === 200 && j.result || {};
|
||||
if (R.starLikes) STAR_N = R.starLikes;
|
||||
/* 11-07 用户:留言、回复一定要审核通过才显示,自己也不显示「审核中」 */
|
||||
var mine = (R.mine || []).filter(function (c) { return c.status === 'approved'; });
|
||||
/* 11-07 用户改:别人的只出审核通过的;自己发的审核中也显示(标「审核中」,只有自己看得到),没通过的不出 */
|
||||
var mine = (R.mine || []).filter(function (c) { return c.status !== 'rejected'; });
|
||||
REAL = (R.list || []).filter(top).map(realOf).concat(mine.filter(top).map(function (c) { var o = realOf(c); o.n = '我'; o.me = 1; o.st = c.status; return o; }));
|
||||
RREP = (R.list || []).filter(function (c) { return !top(c); }).map(function (c) { return repOf(c, 0); })
|
||||
.concat(mine.filter(function (c) { return !top(c); }).map(function (c) { return repOf(c, 1); }));
|
||||
@@ -131,7 +131,7 @@
|
||||
var c = (REAL || []).filter(function (x) { return x.id === id; })[0]; if (!c) return;
|
||||
var href = location.origin + location.pathname + '?wh=1&wc=' + encodeURIComponent(id);
|
||||
var title = '帮我点个赞吧!被赞 ' + STAR_N + ' 次,我对宝宝说的话就能变成一颗星星';
|
||||
var img = new URL('assets/share/g/home.jpg', document.baseURI).href;
|
||||
var img = new URL('assets/share/wh-like.jpg', document.baseURI).href; /* 11-07 用户:转发卡用星空图 */
|
||||
/* 宿主转发好友取 web-view 当前真实地址,不看上报的 href —— 地址栏里也要带上这条留言 */
|
||||
try { var q = new URLSearchParams(location.search); q.set('wh', '1'); q.set('wc', id); history.replaceState(history.state, '', location.pathname + '?' + q + location.hash); } catch (e) {}
|
||||
if (window.wxAuth && wxAuth.reportLocation) wxAuth.reportLocation({ href: href, title: title, imageUrl: img });
|
||||
@@ -179,6 +179,10 @@
|
||||
function total() { return (REAL ? REAL.length : 0) + (SIM ? SIM.length : 0); }
|
||||
function paintGo() {
|
||||
document.getElementById('wcmN').textContent = total() ? total() + ' 条' : '';
|
||||
/* 11-07 用户:「妈妈们的留言」后面加小头像 —— 取最热的 3 位 */
|
||||
var av = document.getElementById('wcmAv');
|
||||
if (av && SIM && SIM.length && !av.firstChild) av.innerHTML = SIM.slice().sort(function (a, b) { return b.likes - a.likes; }).slice(0, 3)
|
||||
.map(function (c) { return '<img src="' + esc(c.av) + '" alt="" onerror="this.remove()">'; }).join('');
|
||||
document.getElementById('wcmRuleN').textContent = STAR_N;
|
||||
}
|
||||
function build() {
|
||||
@@ -200,11 +204,11 @@
|
||||
function item(c) {
|
||||
var on = likedOf(c), rp = repsOf(c);
|
||||
return '<div class="wcm-it" data-k="' + esc(c.key) + '"><img class="wcm-av" src="' + esc(c.av) + '" alt="" loading="lazy" onerror="this.style.visibility=\'hidden\'">' +
|
||||
'<div class="wcm-bd"><p class="wcm-nm"><b>' + esc(c.n) + '</b>' + (c.s ? '<span>' + esc(c.s) + '</span>' : '') + (c.ts ? '<span>' + ago(c.ts) + '</span>' : '') + '</p>' +
|
||||
'<div class="wcm-bd"><p class="wcm-nm"><b>' + esc(c.n) + '</b>' + (c.me && c.st && c.st !== 'approved' ? '<em class="wcm-pend">审核中</em>' : '') + (c.s ? '<span>' + esc(c.s) + '</span>' : '') + (c.ts ? '<span>' + ago(c.ts) + '</span>' : '') + '</p>' +
|
||||
'<p class="wcm-tx">' + esc(c.t) + '</p>' +
|
||||
(c.star ? '<p class="wcm-star"><svg viewBox="0 0 20 20"><path d="M10 .5C10.9 7.4 12.6 9.1 19.5 10 12.6 10.9 10.9 12.6 10 19.5 9.1 12.6 7.4 10.9.5 10 7.4 9.1 9.1 7.4 10 .5Z"/></svg>已经变成星星了</p>' : '') +
|
||||
(rp.length ? '<div class="wcm-rp">' + rp.map(function (x) {
|
||||
return '<p' + (x.me ? ' class="me"' : '') + '><b>' + esc(x.n) + '</b>' + (x.to && x.to !== c.n ? ' 回复 <b>' + esc(x.to) + '</b>' : '') + ':' + esc(x.t) + '</p>';
|
||||
return '<p' + (x.me ? ' class="me"' : '') + '><b>' + esc(x.n) + '</b>' + (x.to && x.to !== c.n ? ' 回复 <b>' + esc(x.to) + '</b>' : '') + ':' + esc(x.t) + (x.me && x.st && x.st !== 'approved' ? '<em class="wcm-pend">审核中</em>' : '') + '</p>';
|
||||
}).join('') + '</div>' : '') +
|
||||
(c.me ? mineFoot(c) : '<button type="button" class="wcm-re" data-wrp="' + esc(c.key) + '">回复</button>') + '</div>' +
|
||||
(c.me ? '<span class="wcm-lk me">' + HEART + '<span>' + fmt(likesOf(c)) + '</span></span></div>' :
|
||||
@@ -213,7 +217,7 @@
|
||||
/* 自己的留言底下:还差几个赞 + 找人帮我点赞(审核通过才能转) */
|
||||
function mineFoot(c) {
|
||||
if (c.star) return '';
|
||||
if (c.st !== 'approved') return '<p class="wcm-mf">审核通过后,就能转给朋友帮你点赞</p>';
|
||||
if (c.st !== 'approved') return '<p class="wcm-mf">正在审核,现在只有你自己看得到;通过后就公开,也能转给朋友帮你点赞</p>';
|
||||
var n = Math.min(c.likes, STAR_N);
|
||||
return '<div class="wcm-mf"><span class="wcm-pg"><i style="width:' + Math.round(n / STAR_N * 100) + '%"></i></span><span>' + n + '/' + STAR_N + ' 个赞,还差 ' + (STAR_N - n) + ' 个就变成星星</span>' +
|
||||
'<button type="button" class="wcm-share" data-wsh="' + esc(c.id) + '">找人帮我点赞</button></div>';
|
||||
@@ -281,12 +285,13 @@
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body)
|
||||
}).then(function (r) { return r.json(); }).then(function (j) {
|
||||
if (!j || j.code !== 200 || !j.result) return (j && j.message) || '没发出去,再试一次';
|
||||
if (j.result.status !== 'approved') return null; /* 审核中的不放进列表,通过后才显示 */
|
||||
if (j.result.status === 'rejected') return null; /* 审核中的也放进列表(标「审核中」,只有自己看得到) */
|
||||
if (reply) { RREP.push(repOf(j.result, 1)); rerender(reply); }
|
||||
else {
|
||||
var o = realOf(j.result); o.n = '我'; o.me = 1; o.st = j.result.status;
|
||||
REAL = [o].concat(REAL || []);
|
||||
if (SIM) { build(); lsBox.scrollTop = 0; }
|
||||
if (state === 'closed') setTimeout(function () { snap('half'); }, 300); /* 发完拉开留言区,让她看到自己那条(审核中) */
|
||||
paintGo();
|
||||
}
|
||||
return null;
|
||||
@@ -302,7 +307,7 @@
|
||||
busy = false; sendB.disabled = false;
|
||||
if (msg) { toast(msg); return; }
|
||||
inp.value = ''; inp.blur(); setReply(null);
|
||||
toast(REPLY0 ? '回复已提交,审核通过后才会显示' : '已提交,审核通过后才会显示');
|
||||
toast(REPLY0 ? '回复已发出,审核通过后大家就能看到' : '已发出,审核通过后大家就能看到');
|
||||
});
|
||||
}
|
||||
sendB.addEventListener('click', send);
|
||||
|
||||
Reference in New Issue
Block a user