新用户空态补全: 信件空响应清内置样例(不再回退演示信); renderLetterDetail 空守卫; 首次完善资料后重载拉真实数据 (v26090711)
This commit is contained in:
10
index.html
10
index.html
@@ -6,8 +6,8 @@
|
||||
<meta name="theme-color" content="#F4593C">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>妈妈盒子 · 孕育陪伴</title>
|
||||
<!-- V:26090710 缓存版本标记:改 css/js 时同步 bump 该值,并给下方资源引用加 ?v= 以强制 webview 刷新子资源 -->
|
||||
<link rel="stylesheet" href="mama-box.css?v=26090710">
|
||||
<!-- V:26090711 缓存版本标记:改 css/js 时同步 bump 该值,并给下方资源引用加 ?v= 以强制 webview 刷新子资源 -->
|
||||
<link rel="stylesheet" href="mama-box.css?v=26090711">
|
||||
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -1758,8 +1758,8 @@
|
||||
加载失败/离线时 window.wx 为 undefined,goMall() 会降级为 toast 提示,
|
||||
不影响应用其余功能。 -->
|
||||
|
||||
<script src="js/app.js?v=26090710"></script>
|
||||
<!-- 页面版本号(排查 webview 缓存):底部会显示 v26090710 -->
|
||||
<div id="ver" style="position:fixed;left:0;right:0;bottom:10px;text-align:center;z-index:9999;pointer-events:none;color:#B3A69C;font-size:10px;letter-spacing:.5px">v26090710</div>
|
||||
<script src="js/app.js?v=26090711"></script>
|
||||
<!-- 页面版本号(排查 webview 缓存):底部会显示 v26090711 -->
|
||||
<div id="ver" style="position:fixed;left:0;right:0;bottom:10px;text-align:center;z-index:9999;pointer-events:none;color:#B3A69C;font-size:10px;letter-spacing:.5px">v26090711</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
18
js/app.js
18
js/app.js
@@ -1306,6 +1306,7 @@
|
||||
}
|
||||
|
||||
function renderLetterDetail(L) {
|
||||
if (!L) return; /* 新用户空态:没有任何信件可渲染 */
|
||||
$('#dlWeek').textContent = L.weekTxt;
|
||||
$('#dlTitle').textContent = L.title;
|
||||
$('#dlDate').textContent = L.dateFull;
|
||||
@@ -1989,6 +1990,7 @@
|
||||
若弹窗里新选了头像(avFile 有文件),先 POST /upload 换正式 URL 再一起提交;
|
||||
上传失败则跳过头像字段(昵称/孕育照存)。断网/接口失败静默,本地已生效。 ---- */
|
||||
var _oid = hashParam('openid');
|
||||
var _wasEmpty = state.pregEmpty; /* 新用户完善资料后 → 重载拉真实孕周+播种信 */
|
||||
function _putProfile(avatarUrl) {
|
||||
if (!_oid) return;
|
||||
var body = {
|
||||
@@ -2005,6 +2007,9 @@
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body)
|
||||
}).then(function () {
|
||||
/* 新用户首次完善资料:重载页面 → pregnancy 出真实孕周、样例信播种 */
|
||||
if (_wasEmpty) setTimeout(function () { location.replace(location.href.split('#')[0] + '?t=' + Date.now()); }, 700);
|
||||
}).catch(function () { /* 保持本地值 */ });
|
||||
}
|
||||
var newAvatarFile = (avFile.files && avFile.files[0]) || null;
|
||||
@@ -4165,7 +4170,18 @@
|
||||
var base = '/api/mp/public/mama-box/';
|
||||
var j = function (u) { return fetch(u).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; }); };
|
||||
j(base + 'letters?openid=' + encodeURIComponent(openid)).then(function (lj) {
|
||||
if (!lj || lj.code !== 200 || !lj.result || !lj.result.items || !lj.result.items.length) return;
|
||||
if (!lj || lj.code !== 200 || !lj.result || !lj.result.items) return;
|
||||
/* 新用户空态:后端成功返回空列表 → 清掉内置样例信,展示「这里还没有内容」。
|
||||
⚠️ 不能直接 return —— 那会把 LETTERS 留在内置样例上,新用户看到演示信。 */
|
||||
if (!lj.result.items.length) {
|
||||
LETTERS.splice(0, LETTERS.length);
|
||||
state.curLetter = '';
|
||||
state.homeLetter = '';
|
||||
renderLetters();
|
||||
syncLetterCounts();
|
||||
pushLatestToHome();
|
||||
return;
|
||||
}
|
||||
Promise.all(lj.result.items.map(function (it) {
|
||||
return j(base + 'letters/' + encodeURIComponent(it.key) + '?openid=' + encodeURIComponent(openid));
|
||||
})).then(function (dets) {
|
||||
|
||||
Reference in New Issue
Block a user