v26110252 孕妈广场「返回兜爸」换成用户头像 + 渐变圈(无头像按 openid 给默认妈妈头像)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-03 06:13:00 +00:00
parent 17c88226d4
commit 5d8335a9d5
8 changed files with 49 additions and 30 deletions

View File

@@ -367,8 +367,8 @@ mark{background:linear-gradient(transparent 62%,var(--c20) 0);color:inherit;padd
</div>
<div class="toast" id="toast"></div>
<script src="meta.js?v=26110251"></script>
<script src="tests.js?v=26110251"></script>
<script src="meta.js?v=26110252"></script>
<script src="tests.js?v=26110252"></script>
<script>
(function () {
'use strict';

View File

@@ -537,14 +537,14 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
.tab-fab .t-txt{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
#tabHome .t-ico{margin-bottom:6px}
#tabHome .t-txt{font-size:11.5px;font-weight:600}
.tab-avimg{position:absolute;inset:-3px;width:calc(100% + 6px);height:calc(100% + 6px);border-radius:50%;object-fit:cover;display:none;box-shadow:0 3px 10px rgba(226,105,74,.38)}
.tab-avimg{position:absolute;inset:-3px;width:calc(100% + 6px);height:calc(100% + 6px);border-radius:50%;object-fit:cover;display:none;background:#fff;box-shadow:0 0 0 1.5px #fff,0 3px 10px rgba(226,105,74,.3)}
.tab-hm{position:absolute;right:-8px;bottom:-5px;width:15px;height:15px;z-index:1;border-radius:50%;display:none;background:linear-gradient(150deg,#E2694A,#C24E31);box-shadow:0 0 0 1.5px #FFF6F1}
.tab-hm svg{display:block;width:10px;height:10px;margin:2.5px}
.t-ico.has-av .tab-avimg,.t-ico.has-av .tab-hm{display:block}
.t-ico.has-av .t-svg{visibility:hidden}
.t-ico.has-av::before{content:"";position:absolute;inset:-6px;border-radius:50%;z-index:-1;pointer-events:none;
background:conic-gradient(from 0deg,rgba(226,105,74,0) 0deg,#F09A72 90deg,#E2694A 200deg,rgba(226,105,74,0) 300deg);
-webkit-mask:radial-gradient(circle,transparent 61%,#000 63%,#000 72%,transparent 74%);mask:radial-gradient(circle,transparent 61%,#000 63%,#000 72%,transparent 74%)}
.t-ico.has-av::before{content:"";position:absolute;inset:-7px;border-radius:50%;z-index:-1;pointer-events:none; /* 渐变圈:整圈 粉→橙→深橙,比数胎动那条半圈更明显(11-03 用户要「渐变圈的效果」) */
background:conic-gradient(from 200deg,#FFB38A,#F4593C,#E2694A,#FF8FA3,#FFB38A);
-webkit-mask:radial-gradient(circle closest-side,transparent 82%,#000 85%);mask:radial-gradient(circle closest-side,transparent 82%,#000 85%)}
/* 「记一下」弹层:标题一行 + 4 列工具宫格(同数胎动 / 首页) */
.rec-h{display:flex;align-items:baseline;gap:10px;padding:10px 2px 14px}
.rec-h b{font-size:19px;font-weight:800;color:#2A1E1E;flex:none}
@@ -648,10 +648,10 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
<div id="sheet" role="dialog" aria-modal="true"><i class="sg"></i><div class="sbd" id="sbd"></div></div>
<div class="toast" id="toast"></div>
<script src="topics.js?v=26110251"></script>
<script src="data.js?v=26110251"></script>
<script src="feed.js?v=26110251"></script>
<script src="ceshi/meta.js?v=26110251"></script>
<script src="topics.js?v=26110252"></script>
<script src="data.js?v=26110252"></script>
<script src="feed.js?v=26110252"></script>
<script src="ceshi/meta.js?v=26110252"></script>
<script>
(function () {
'use strict';
@@ -717,7 +717,7 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
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=26110251').then(function (r) { return r.json(); }).then(function (j) {
fetch('cm.json?v=26110252').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) {
@@ -1656,14 +1656,33 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
if (g) { haptic(); toast(g[1] + '孕 ' + g[0] + ' 周以后开放,你现在孕 ' + myWeek + ' 周,还用不到哦'); return; }
goApp(a.url);
});
/* 返回兜爸的头像:同数胎动 —— 跨应用 user-center/info 有真头像才换上(商城默认头像 /uploads/system/ 当没有),没有就留小房子 */
if (OPENID && window.fetch) fetch('/api/mp/public/user-center/info?openid=' + encodeURIComponent(OPENID)).then(function (r) { return r.ok ? r.json() : null; }).then(function (d) {
var av = d && d.result && d.result.data && d.result.data.avatar;
if (!av || /\/uploads\/system\//.test(av)) return;
var ico = $('#tabAv'), im = new Image(); im.className = 'tab-avimg'; im.alt = '';
im.onload = function () { ico.appendChild(im); ico.insertAdjacentHTML('beforeend', '<i class="tab-hm" aria-hidden="true"><svg viewBox="0 0 24 24" fill="#fff"><path d="M12 4 3.5 11H6v8.5h4.5v-5h3v5H18V11h2.5z"/></svg></i>'); ico.classList.add('has-av'); };
im.src = av;
}).catch(function () {});
/* 返回兜爸的头像(11-03 用户:「图标换成用户的头像,上面加渐变圈」)—— 同数胎动的取值顺序:
① 跨应用 user-center/info 的真头像(权威);② 授权回传在 hash 里的 avatar;③ 都没有 → 按 openid 固定给一个默认妈妈头像
(同 /_bridge/avatar-picker.js 的 defaultFor,同一人在每个应用看到的一样)。商城默认头像 /uploads/system/ 当没有。
小房子 SVG 不删:头像加载失败就露回来,这是回首页的入口,不能变空位。 */
var realAv = function (u) { return !!u && !/\/uploads\/system\//.test(u); };
function defAv(oid) { var h = 0, s = String(oid || ''); for (var i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) >>> 0; return 'https://mp.yizhezhe.com/_bridge/avatars/mom-' + ((h % 20) + 1 < 10 ? '0' : '') + ((h % 20) + 1) + '.png'; }
function paintTabAv(url) {
var ico = $('#tabAv'), im = ico.querySelector('.tab-avimg');
if (!url) return;
if (!im) {
im = document.createElement('img'); im.className = 'tab-avimg'; im.alt = ''; ico.appendChild(im);
ico.insertAdjacentHTML('beforeend', '<i class="tab-hm" aria-hidden="true"><svg viewBox="0 0 24 24" fill="#fff"><path d="M12 4 3.5 11H6v8.5h4.5v-5h3v5H18V11h2.5z"/></svg></i>');
}
im.onload = function () { ico.classList.add('has-av'); };
im.onerror = function () { if (im.getAttribute('src') !== defAv(OPENID)) im.src = defAv(OPENID); else ico.classList.remove('has-av'); };
if (im.getAttribute('src') !== url) im.src = url;
}
function loadTabAv() {
if (!OPENID || !window.fetch) return;
fetch('/api/mp/public/user-center/info?openid=' + encodeURIComponent(OPENID) + (param('unionid') ? '&unionid=' + encodeURIComponent(param('unionid')) : ''))
.then(function (r) { return r.ok ? r.json() : null; }).then(function (d) {
var av = d && d.result && d.result.found && d.result.data && d.result.data.avatar;
if (realAv(av)) paintTabAv(av);
}).catch(function () {});
}
if (OPENID) { paintTabAv(realAv(param('avatar')) ? param('avatar') : defAv(OPENID)); loadTabAv(); }
window.addEventListener('pageshow', function (e) { if (e.persisted) loadTabAv(); }); /* 从别的应用改完头像退回来,跟着换 */
/* ---------- 吸顶阴影 ---------- */
var sc = $('#sc');

View File

@@ -105,7 +105,7 @@ main{padding:6px 16px 0}
</div>
<div class="wb"><button type="button" id="write"><svg class="ic" viewBox="0 0 24 24"><path d="M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg>写新的故事</button></div>
<script src="../topics.js?v=26110251"></script>
<script src="../topics.js?v=26110252"></script>
<script>
(function () {
'use strict';