From b0b0469983b3b6324ed1bb06afb1f498b88cda07 Mon Sep 17 00:00:00 2001 From: karlcarlo Date: Sun, 11 Oct 2026 15:49:52 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AD=95=E6=9C=9F=E6=A1=A3=E6=A1=88=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=94=B9=E7=94=A8=E9=9D=A2=E6=9D=BF=20sync:false=20+?= =?UTF-8?q?=20commit=20=E6=AD=A3=E5=BC=8F=E5=86=99=E6=B3=95=20v26101032?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: AI 助手 --- index.html | 4 ++-- js/app.js | 23 ++++++----------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index d090d61..ea02ffb 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ 兜爸心选 · 孕育陪伴 - + @@ -2039,7 +2039,7 @@ 不影响应用其余功能。 --> - + diff --git a/js/app.js b/js/app.js index 95b48da..5be20a1 100644 --- a/js/app.js +++ b/js/app.js @@ -3,7 +3,7 @@ (function () { 'use strict'; /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ - var VER = '26101031'; + var VER = '26101032'; const $ = (s, c) => (c || document).querySelector(s); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); @@ -1878,23 +1878,16 @@ 这里 avFile 排在 pfName 前面,所以 openModal 用的选择器只取 .modal-ta/input 可能命中 file input——用 :not([type=file]) 排除掉,见 openModal */ /* 2026-10-11 用户:点头像弹预设选项,也能从相册上传、用微信头像 → 走统一头像面板 avatarPicker - (/_bridge/avatar-picker.js:选完自己上传、派发 mmbox:avatar;共享资料改到保存时写)。 + (/_bridge/avatar-picker.js:sync:false 选完只回调;保存时 commit 写共享资料、派发 mmbox:avatar)。 选中的是正式 URL,记在 pickedAvatar,保存时一起 PUT 进首页档案;面板没加载上才退回系统选图。 */ function openAvatarPanel() { if (window.avatarPicker && window.avatarPicker.open) { window.avatarPicker.open({ current: avBig.classList.contains('has-img') ? avPreview.src : '', accent: '#F4593C', accentSoft: '#FDECE7', + /* 2026-10-11 用户:点「保存资料」后才让所有应用同步头像 → 面板只回调,保存时 commit */ + sync: false, onPick: function (url) { - /* 2026-10-11 用户:点「保存资料」后才让所有应用同步头像。面板 done() 里紧接着 onPick - 会同步调 syncShared → wxAuth.identity(),这里让那一次拿到空身份,面板就不写共享资料; - 真正的共享写入放到 #pfSave 里(syncSharedAvatar)。 */ - var wa = window.wxAuth; - if (wa && wa.identity) { - var _id = wa.identity, _back = function () { wa.identity = _id; }; - wa.identity = function () { _back(); return {}; }; - setTimeout(_back, 0); - } pickedAvatar = url; avFile.value = ''; avPreview.src = url; avBig.classList.add('has-img'); @@ -1969,13 +1962,9 @@ 上传失败则跳过头像字段(昵称/孕育照存)。断网/接口失败静默,本地已生效。 ---- */ var _oid = hashParam('openid'); var _wasEmpty = state.pregEmpty; /* 新用户完善资料后 → 重载拉真实孕周 */ - /* 保存时才把头像写进共享资料(auth/profile),其它应用读 user-center/info 就会跟着换 */ + /* 保存时才把头像写进共享资料:avatarPicker.commit 已授权才写 auth/profile,并派发 mmbox:avatar */ function syncSharedAvatar(url) { - var id = (window.wxAuth && wxAuth.identity && wxAuth.identity()) || {}; - if (!url || !id.openid) return; - var q = '?openid=' + encodeURIComponent(id.openid) + (id.unionid ? '&unionid=' + encodeURIComponent(id.unionid) : ''); - fetch('/api/mp/public/auth/profile' + q + '&avatar=' + encodeURIComponent(url), { method: 'POST' }).catch(function () {}); - try { window.dispatchEvent(new CustomEvent('mmbox:avatar', { detail: { url: url, source: 'save', for: 'mom' } })); } catch (e) {} + if (url && window.avatarPicker && window.avatarPicker.commit) window.avatarPicker.commit(url); } function _putProfile(avatarUrl) { if (!_oid) return;