悄悄话第 2 步:星空页留言区 最热/最新/同孕周、真实留言服务端点赞、赞够自动挂星标记;「说一句」改发进留言区(先审后发)(v26110616)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
19
js/app.js
19
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110614';
|
||||
var VER = '26110616';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -4775,7 +4775,9 @@
|
||||
paintSky(l);
|
||||
paintList(l);
|
||||
if (cur && list()[cur - 1]) $$('.wsk-st[data-go="' + cur + '"]', page).forEach(x => x.classList.add('cur'));
|
||||
$('#whpLeft').textContent = !data ? '' : !oid() || !data.canPost ? '填好预产期,就能说一句' : data.left ? '今天还能说 ' + data.left + ' 句' : '今天的 3 句说完啦,明天再来';
|
||||
$('#whpLeft').textContent = !data ? '' : !oid() || !data.canPost ? '填好预产期,就能说一句' :
|
||||
window.MBWhCm ? '说的话先审核再公开,攒够 ' + MBWhCm.starLikes() + ' 个赞就挂上星星' : /* 11-07 悄悄话第 2 步:说一句 = 发进下面的留言区 */
|
||||
data.left ? '今天还能说 ' + data.left + ' 句' : '今天的 3 句说完啦,明天再来';
|
||||
}
|
||||
function drawer(on) {
|
||||
$('#whDrawer').classList.toggle('show', on);
|
||||
@@ -4829,6 +4831,7 @@
|
||||
const r = j && j.code === 200 && j.result;
|
||||
if (!r || !r.show || !(r.list || []).length) { data = null; show(false); autoFail(); return; }
|
||||
data = r;
|
||||
window.MB_WH_WEEK = r.week; /* 留言区「同孕周」用(js/wh-cm.js) */
|
||||
const ns = r.list.map(x => x.id + ':' + x.hugs + (x.hugged ? 'h' : '')).join('|');
|
||||
if (ns !== sig) {
|
||||
sig = ns;
|
||||
@@ -4914,7 +4917,7 @@
|
||||
$('#whSay').addEventListener('click', () => {
|
||||
if (!data) return;
|
||||
if (!oid() || !data.canPost) { toast('填好预产期,就能和同孕周妈妈说悄悄话啦'); return; }
|
||||
if (!data.left) { toast('今天已经说了 3 句啦,明天再来'); return; }
|
||||
if (!data.left && !window.MBWhCm) { toast('今天已经说了 3 句啦,明天再来'); return; }
|
||||
ta.value = '';
|
||||
ta.maxLength = data.maxLen || 40;
|
||||
cnt();
|
||||
@@ -4924,7 +4927,8 @@
|
||||
$('#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 + ' 句';
|
||||
$('#whLeft').textContent = window.MBWhCm ? '' : '今天还能说 ' + data.left + ' 句';
|
||||
if (window.MBWhCm) { $('#whMLead').textContent = '发出后先审核,通过了会出现在星空下面的留言区;攒够 ' + MBWhCm.starLikes() + ' 个赞,就会挂到星空上,同孕期的妈妈都能点到。'; }
|
||||
openModal('modalWhisper');
|
||||
});
|
||||
$('#whPresets').addEventListener('click', e => {
|
||||
@@ -4942,6 +4946,13 @@
|
||||
const btn = $('#whSend');
|
||||
btn.disabled = true;
|
||||
btn.textContent = '正在发出…';
|
||||
/* 11-07 悄悄话第 2 步(用户定):星空页「说一句」并入留言区 —— 发成置顶笔记下的留言(先审后发),赞够门槛自动挂星 */
|
||||
if (window.MBWhCm) {
|
||||
MBWhCm.post(t, data.week)
|
||||
.then(m => { if (m) { toast(m); return; } closeModal(); toast('发出去啦,审核通过后会出现在留言区'); })
|
||||
.then(() => { busy = false; btn.disabled = false; btn.textContent = '悄悄发出'; });
|
||||
return;
|
||||
}
|
||||
fetch(API + '?openid=' + encodeURIComponent(oid()), {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: t })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user