Compare commits
2 Commits
51828a097c
...
91f29e05c9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91f29e05c9 | ||
|
|
53652c481c |
@@ -1007,7 +1007,7 @@ html.night .gtg button.on{background:#F2725B;border-color:#F2725B;color:#fff}
|
||||
return m ? decodeURIComponent(m[1]).split('?')[0] : '';
|
||||
} catch (e) { return ''; }
|
||||
}
|
||||
var OPENID = (window.mbGate && window.mbGate.out) ? '' : param('openid'); /* 11-07 退出登录后按访客(不拉「我的评论」、不认头像) */
|
||||
var OPENID = (window.mbGate && window.mbGate.out) ? '' : (param('openid') || (function(){try{var c=JSON.parse(sessionStorage.getItem('mmbox.identity')||'null');return c&&c.openid&&(!c.at||Date.now()-c.at<432e5)?c.openid:'';}catch(e){return '';}})()); /* 11-07 URL 没带身份时用首页存的同源缓存(同 wx-auth.js identity) */ /* 11-07 退出登录后按访客(不拉「我的评论」、不认头像) */
|
||||
var MYNAME = param('nickname') || '孕妈'; /* 授权回填的昵称在 hash 里;没有就叫「孕妈」,后面另挂「我」标 */
|
||||
|
||||
/* ---------- 头像:沿用首页 assets/img/mom/ 写实头像 ---------- */
|
||||
@@ -1053,7 +1053,7 @@ html.night .gtg button.on{background:#F2725B;border-color:#F2725B;color:#fff}
|
||||
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=26110631').then(function (r) { return r.json(); }).then(function (j) {
|
||||
fetch('cm.json?v=26110633').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) {
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
<title>兜爸心选 · 孕育陪伴</title>
|
||||
<!-- 11-04 UGC 总开关(孕妈广场 + 测一测,后台 /box_bm/plaza 顶部切换),见 js/ugc.js -->
|
||||
<script src="js/ugc.js?v=26110487"></script>
|
||||
<!-- V:26110631 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<!-- V:26110633 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<link rel="stylesheet" href="mama-box.css">
|
||||
<link rel="stylesheet" href="night.css?v=26110608">
|
||||
<link rel="stylesheet" href="js/wh-cm.css?v=26110631">
|
||||
<link rel="stylesheet" href="js/wh-cm.css?v=26110633">
|
||||
<!-- 11-04 用户:「顶部图片上的倒计时先删除掉」→ 不加载 hero-cd.css / hero-cd.js(文件留着,加回这两行即恢复),头图回到原样式 -->
|
||||
<!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) -->
|
||||
<script>try{if(localStorage.getItem('mmbox.night.v1')==='1'){document.documentElement.classList.add('night');document.querySelector('meta[name=theme-color]').content='#2A2340'}}catch(e){}</script>
|
||||
@@ -2680,7 +2680,7 @@ html.night .rs-pan .rp-card{background:rgba(255,255,255,.06);border-color:rgba(2
|
||||
<script src="guangchang/topics.js?v=26110487"></script>
|
||||
<script src="js/ava-pool.js?v=26110487"></script> <!-- 11-05 装饰头像分配表(各模块互不重复) -->
|
||||
<script src="js/wh-themes.js?v=26110609"></script>
|
||||
<script src="js/wh-cm.js?v=26110631" defer></script>
|
||||
<script src="js/wh-cm.js?v=26110633" defer></script>
|
||||
<script src="js/app.js"></script>
|
||||
<script src="js/kit.js?v=26110605"></script>
|
||||
<!-- 11-05 用户:孕期百问加上跟趣味小测试一样的底部 Tab(孕期百问 / 记一下 / 返回首页)。挂在 #detailQA 里,面板关着时跟着滑出屏外;
|
||||
|
||||
23
js/app.js
23
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110631';
|
||||
var VER = '26110633';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -202,6 +202,8 @@
|
||||
/* 预览页(/mama-box-preview/)是直接发链接给人看的,不在小程序里冷启动 —— 不恢复上次应用,
|
||||
否则一打开就被送去上次进过的应用(2026-10-01 用户反馈:打开预览链接直接跳到孕检日历)。 */
|
||||
if (location.pathname.indexOf('/mama-box-preview/') === 0) return;
|
||||
/* 11-07:转发来的悄悄话卡片(?wh=1 / ?wc=<留言id>)是要直接看星空页的,不能被「恢复上次应用」跳走 */
|
||||
if (/[?&](wh|wc)=/.test(location.search)) { sessionStorage.setItem(RESUME_DONE_KEY, '1'); return; }
|
||||
const oid = hashParam('openid');
|
||||
if (!oid) return; // 无身份不跳(宿主拿不到 openid 时也不会加载本页)
|
||||
/* 先置闸门再请求/再判 norestore:
|
||||
@@ -4838,7 +4840,21 @@
|
||||
drawer(false);
|
||||
launch(g.dataset.next ? nextStar() : +g.dataset.go);
|
||||
});
|
||||
/* 11-07 用户:小程序里转发「本周话题」,对方点进来要直接到星空页 —— 宿主转发好友用的是 web-view 当前真实地址
|
||||
(onShareAppMessage 的 webViewUrl),不看上报的 href,所以星空页开着时地址里要一直带 ?wh=1,关掉再去掉。 */
|
||||
function whQs(on) {
|
||||
try {
|
||||
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);
|
||||
const th = window.MB_WH_THEME ? window.MB_WH_THEME() : null;
|
||||
if (window.wxAuth && wxAuth.reportLocation) wxAuth.reportLocation(on ? { title: th ? '本周话题:' + th.name : '孕妈悄悄话' } : {});
|
||||
} catch (e) {}
|
||||
}
|
||||
function openPage() {
|
||||
whQs(true);
|
||||
stopAll();
|
||||
cur = 0;
|
||||
card.classList.remove('show');
|
||||
@@ -4854,6 +4870,7 @@
|
||||
stopAll();
|
||||
drawer(false);
|
||||
if (fromPlaza) { fromPlaza = false; history.back(); return; } /* 从广场置顶笔记来的:回广场 */
|
||||
whQs(false);
|
||||
page.classList.remove('show');
|
||||
page.setAttribute('aria-hidden', 'true');
|
||||
}
|
||||
@@ -4896,10 +4913,6 @@
|
||||
let autoOpen = /[?&]wh=1(?:&|$)/.test(location.search), fromPlaza = false;
|
||||
if (autoOpen) {
|
||||
fromPlaza = /\/guangchang\//.test(document.referrer || '') && history.length > 1;
|
||||
if (history.replaceState) {
|
||||
const q = new URLSearchParams(location.search); q.delete('wh');
|
||||
history.replaceState(history.state, '', location.pathname + (q.toString() ? '?' + q : '') + location.hash);
|
||||
}
|
||||
page.classList.add('show');
|
||||
page.setAttribute('aria-hidden', 'false');
|
||||
let gw = 0;
|
||||
|
||||
24
js/wh-cm.js
24
js/wh-cm.js
@@ -18,7 +18,15 @@
|
||||
if (!page || !bar || !window.MB_WH_THEME) return;
|
||||
var TH = MB_WH_THEME(), PID = 'wh-' + TH.from.replace(/-/g, '');
|
||||
var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); };
|
||||
var m = ((location.hash || '') + '&').match(/[#&]openid=([^&]*)/), OID = m ? decodeURIComponent(m[1]) : '';
|
||||
/* 11-07 修:原来只读 hash 里的 openid —— 小程序里身份常在 query 或同源缓存里(应用间跳回、转发卡片落地),
|
||||
首页显示已登录、这里却提示「登录后就能留言」。改成和首页 hashParam 同一套:hash + query → wxAuth 同源缓存,退出登录算访客;每次用时现读。 */
|
||||
function oid() {
|
||||
if (window.mbGate && window.mbGate.out) return '';
|
||||
var h = (location.hash.slice(1) || '') + '&' + (location.search.slice(1) || ''), m = h.match(/(?:^|[&#])openid=([^&#]*)/);
|
||||
var v = m ? decodeURIComponent(m[1]).split('?')[0] : '';
|
||||
if (!v) try { var id = window.wxAuth && wxAuth.identity ? wxAuth.identity() : null; v = id && id.openid || ''; } catch (e) {}
|
||||
return v;
|
||||
}
|
||||
var HEART = '<svg viewBox="0 0 24 24"><path d="M12 20.5s-7.5-4.6-7.5-10.2A4.3 4.3 0 0112 7.6a4.3 4.3 0 017.5 2.7c0 5.6-7.5 10.2-7.5 10.2z"/></svg>';
|
||||
|
||||
var WC = (location.search.match(/[?&]wc=([A-Za-z0-9]{1,40})/) || [])[1] || ''; /* 别人转发来请我点赞的那条 */
|
||||
@@ -61,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=26110631').then(function (r) { return r.json(); }).then(function (j) {
|
||||
fetch('guangchang/cm.json?v=26110633').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]];
|
||||
@@ -73,7 +81,7 @@
|
||||
fetchReal();
|
||||
}
|
||||
function fetchReal() {
|
||||
return fetch('/api/mp/public/mama-box/plaza/comments?kind=post&target=' + encodeURIComponent(PID) + (OID ? '&openid=' + encodeURIComponent(OID) : ''))
|
||||
return fetch('/api/mp/public/mama-box/plaza/comments?kind=post&target=' + encodeURIComponent(PID) + (oid() ? '&openid=' + encodeURIComponent(oid()) : ''))
|
||||
.then(function (r) { return r.json(); }).then(function (j) {
|
||||
var R = j && j.code === 200 && j.result || {};
|
||||
if (R.starLikes) STAR_N = R.starLikes;
|
||||
@@ -124,6 +132,8 @@
|
||||
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;
|
||||
/* 宿主转发好友取 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 });
|
||||
var g = document.createElement('div');
|
||||
g.className = 'wsh-g';
|
||||
@@ -245,11 +255,11 @@
|
||||
return;
|
||||
}
|
||||
/* 真实留言:服务端计数,赞了就不能取消(同星星的抱抱) */
|
||||
if (!OID) { toast('登录后就能点赞啦'); return; }
|
||||
if (!oid()) { toast('登录后就能点赞啦'); return; }
|
||||
if (c.liked) { toast('你已经赞过啦'); return; }
|
||||
c.liked = true; c.likes++; paintLk(b, c); b.classList.add('pop'); setTimeout(function () { b.classList.remove('pop'); }, 500);
|
||||
if (navigator.vibrate) navigator.vibrate(8);
|
||||
fetch('/api/mp/public/mama-box/plaza/comment/like?openid=' + encodeURIComponent(OID) + '&id=' + encodeURIComponent(c.id), { method: 'POST' })
|
||||
fetch('/api/mp/public/mama-box/plaza/comment/like?openid=' + encodeURIComponent(oid()) + '&id=' + encodeURIComponent(c.id), { method: 'POST' })
|
||||
.then(function (x) { return x.json(); }).then(function (j) {
|
||||
if (!j || j.code !== 200) throw j;
|
||||
c.likes = j.result.likes; var was = c.star; c.star = !!j.result.star; paintLk(b, c);
|
||||
@@ -264,10 +274,10 @@
|
||||
});
|
||||
|
||||
function post(text, week, reply) {
|
||||
if (!OID) return Promise.resolve('登录后就能留言啦');
|
||||
if (!oid()) return Promise.resolve('登录后就能留言啦');
|
||||
var body = { kind: 'post', target: PID, title: '孕妈悄悄话 · ' + TH.name, text: text, stage: week ? '孕 ' + week + ' 周' : '' };
|
||||
if (reply) { body.parent = reply.key; body.parentName = reply.n; }
|
||||
return fetch('/api/mp/public/mama-box/plaza/comment?openid=' + encodeURIComponent(OID), {
|
||||
return fetch('/api/mp/public/mama-box/plaza/comment?openid=' + encodeURIComponent(oid()), {
|
||||
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) || '没发出去,再试一次';
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
if (SLUG) (function () { var s = document.createElement('script'); s.src = '../../js/share-card.js?v=26110464'; s.onload = function () { window.mbShare('../../assets/share/t/' + SLUG + '.jpg'); }; document.head.appendChild(s); })();
|
||||
/* 11-07 退出登录后只看不写(js/login-gate.js):点赞、评论、发图都弹「登录后才能使用」 */
|
||||
if (!window.mbGate) (function () { var s = document.createElement('script'); s.src = '../../js/login-gate.js?v=26110610'; document.head.appendChild(s); })();
|
||||
var SK = 'mmbox.tp.v1', UK = (function () { var m = ((location.hash || '') + '&' + (location.search || '')).match(/[#?&]openid=([^&]*)/); return m ? decodeURIComponent(m[1]) : '_guest'; })();
|
||||
var SK = 'mmbox.tp.v1', UK = (function () { var m = ((location.hash || '') + '&' + (location.search || '')).match(/[#?&]openid=([^&]*)/); return m ? decodeURIComponent(m[1]).split('?')[0] : ((function(){try{var c=JSON.parse(sessionStorage.getItem('mmbox.identity')||'null');return c&&c.openid&&(!c.at||Date.now()-c.at<432e5)?c.openid:'';}catch(e){return '';}})() || '_guest'); })(); /* 11-07 URL 没带身份时用首页存的同源缓存 */
|
||||
function loadMe() { try { var a = JSON.parse(localStorage.getItem(SK) || '{}') || {}; var m = a[UK] || {}; m.cm = m.cm || {}; m.lk = m.lk || {}; return { a: a, m: m }; } catch (e) { return { a: {}, m: { cm: {}, lk: {} } }; } }
|
||||
function saveMe(st) { try { st.a[UK] = st.m; localStorage.setItem(SK, JSON.stringify(st.a)); } catch (e) {} }
|
||||
/* 11-02 用户:自己发的评论带上孕周(首页写进 mmbox.gcwk.v1) */
|
||||
|
||||
Reference in New Issue
Block a user