「我的」头像与其他应用统一 (v26102501):商城默认头像当空值,退到头像库 avatarPicker.defaultFor(openid)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-10-25 01:14:50 +00:00
parent 71a20ad033
commit 9125db295f
2 changed files with 10 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
(function () {
'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26102202';
var VER = '26102501';
const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
@@ -3567,9 +3567,14 @@
state.authorized = _authorized;
/* 方案A:显示看 authorized 而不是 userName —— 后端退出只置 authorized=false,昵称/头像仍在库里 */
var _n = $('#meName'); if (_n) _n.textContent = (_authorized && p.userName) || '未登录';
if (p.avatar && _authorized) {
/* 2026-10-25:和其他应用同一套取值(见 /yunyu/ js/app.js 头像取值注释)——
商城默认头像(shop.douba.top/uploads/system/…)当空值,退到头像库 avatarPicker.defaultFor(openid),
否则「我的」显示商城灰头像、别的应用显示头像库图,同一个人两处不一样 */
var _av = (p.avatar && p.avatar.indexOf('/uploads/system/') < 0) ? p.avatar : '';
if (!_av) { try { if (window.avatarPicker && window.avatarPicker.defaultFor) _av = window.avatarPicker.defaultFor(openid); } catch (e) { /* 落到线稿小人 */ } }
if (_av && _authorized) {
var _ai = $('#meAvatarImg'), _aw = $('#meAvatar');
if (_ai) _ai.src = p.avatar;
if (_ai) _ai.src = _av;
if (_aw) _aw.classList.add('has-img');
}
/* 授权入口:未授权时显示(引导先授权);退出按钮:已授权时显示 */