悄悄话每周话题:首页入口/全屏页/说一句弹窗展示本周话题「对宝宝说的话」 (v26100199)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
39
js/app.js
39
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26100198';
|
||||
var VER = '26100199';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -3340,6 +3340,26 @@
|
||||
const oid = () => hashParam('openid');
|
||||
const list = () => (data && data.list) || [];
|
||||
|
||||
/* ---------- 每周话题(2026-10-02 用户:「一周一个主题,要么大家也不知道说什么」)----------
|
||||
一条 = 从 from(北京时间那周的周一)起生效,直到下一条的 from;所以表里永远取「from ≤ 今天」的最后一条,
|
||||
没配新话题时沿用上一周的,不会空着。换话题 = 往表尾追加一条。
|
||||
后端将来若在 /whisper 返回 theme(同结构),以后端为准。
|
||||
presets 只是「不知道说什么?点一句」的示范句,发出去时不在服务端预设库里 → 照常走微信内容安全审核。 */
|
||||
const WH_THEMES = [
|
||||
{ from: '2026-09-28', name: '对宝宝说的话',
|
||||
tip: '把想对 TA 说的话,悄悄放进星空',
|
||||
say: '对宝宝说一句悄悄话', ph: '宝宝,妈妈想对你说……',
|
||||
presets: ['宝宝,妈妈每天都在数着日子等你', '你踢我的时候,是在跟妈妈打招呼吗', '不管你长什么样,妈妈都一样爱你',
|
||||
'慢慢长,不着急,妈妈在这儿等你', '等你出来,带你去看海', '爸爸天天对着肚子讲话,你听到了吗'] },
|
||||
];
|
||||
function theme() {
|
||||
if (data && data.theme && data.theme.name) return data.theme;
|
||||
const d = new Date(Date.now() + 8 * 3600e3).toISOString().slice(0, 10);
|
||||
let t = null;
|
||||
WH_THEMES.forEach(x => { if (x.from <= d) t = x; });
|
||||
return t;
|
||||
}
|
||||
|
||||
/* ---------- 首页入口:一句轮播 ---------- */
|
||||
function roll() {
|
||||
const l = list().filter(x => !x.mine);
|
||||
@@ -3354,10 +3374,13 @@
|
||||
/* 用户:「同孕周悄悄话改成 30 周孕妈悄悄话」—— 周数跟着她自己的孕周走 */
|
||||
const nm = data && data.week ? data.week + '周孕妈悄悄话' : '孕妈悄悄话';
|
||||
$('#weName').textContent = nm;
|
||||
entry.setAttribute('aria-label', '打开' + nm);
|
||||
const th = theme();
|
||||
$('#weTopic').textContent = th ? th.name : '';
|
||||
entry.classList.toggle('has-topic', !!th);
|
||||
entry.setAttribute('aria-label', '打开' + nm + (th ? ',本周话题:' + th.name : ''));
|
||||
$('#weRoll').textContent = l.length ? '“' + l[0].text + '”' : '';
|
||||
ri = 0;
|
||||
$('#weGo').innerHTML = '去看看<i aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M6 3.5L10.5 8 6 12.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></i>';
|
||||
$('#weGo').innerHTML = (th ? '去说一句' : '去看看') + '<i aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M6 3.5L10.5 8 6 12.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></i>';
|
||||
clearInterval(rollT);
|
||||
if (l.length > 1) rollT = setInterval(() => { if (!document.hidden && !page.classList.contains('show')) roll(); }, 4000);
|
||||
}
|
||||
@@ -3645,6 +3668,9 @@
|
||||
$('#whpTag').textContent = data ? '孕 ' + data.week + ' 周 · 前后一周的妈妈' : '';
|
||||
/* 2026-10-02 用户:「每个星星都是孕妈的一句话,类似这个感觉,替换掉今晚多少句悄悄话」→ 标题不再报条数 */
|
||||
$('#wskTitle').innerHTML = '<div class="wsk-t">每一颗星星,<br>都是<b>一位孕妈</b>的一句话</div><p>' + (night ? '今晚' : '今天') + ',她们和你一样在等宝宝来</p>';
|
||||
const th = theme();
|
||||
if (th) $('#wskTitle').insertAdjacentHTML('beforeend', '<div class="wsk-topic"><em>本周话题</em><b>' + esc(th.name) + '</b><span>' + esc(th.tip || '') + '</span></div>');
|
||||
$('#whSay').firstElementChild.textContent = th && th.say ? th.say : '说一句悄悄话';
|
||||
paintDeco();
|
||||
paintSky(l);
|
||||
paintList(l);
|
||||
@@ -3766,7 +3792,12 @@
|
||||
ta.value = '';
|
||||
ta.maxLength = data.maxLen || 40;
|
||||
cnt();
|
||||
$('#whPresets').innerHTML = (data.presets || []).map(t => '<button class="wh-pre" type="button">' + esc(t) + '</button>').join('');
|
||||
const th = theme();
|
||||
$('#whMTitle').textContent = th && th.say ? th.say : '说一句悄悄话';
|
||||
$('#whMTopic').textContent = th ? '本周话题:' + th.name : '';
|
||||
$('#whMTopic').style.display = th ? '' : 'none';
|
||||
ta.placeholder = th && th.ph ? th.ph : '今天想对谁说点什么?';
|
||||
$('#whPresets').innerHTML = ((th && th.presets && th.presets.length) ? th.presets : (data.presets || [])).map(t => '<button class="wh-pre" type="button">' + esc(t) + '</button>').join('');
|
||||
$('#whLeft').textContent = '今天还能说 ' + data.left + ' 句';
|
||||
openModal('modalWhisper');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user