修复合伙人端上传门头照片失败的问题

This commit is contained in:
2026-07-12 15:55:49 +08:00
parent 9fc955d81f
commit 2c04676555
8 changed files with 43 additions and 37 deletions
@@ -117,10 +117,16 @@ export default function OssUploadField({
setAuthorizing(true);
setError('');
try {
await authorizePartnerWechat();
const result = await authorizePartnerWechat();
if (result) {
const me = await fetchPartnerProfile();
setProfile(me);
onWechatReadyChange?.(!!me.hasWechat);
}
} catch (e) {
const text = e instanceof Error ? e.message : '微信授权失败';
showUploadError(text);
} finally {
setAuthorizing(false);
}
}
@@ -139,9 +145,11 @@ export default function OssUploadField({
count: 1,
sourceType: ['album', 'camera'],
});
if (!files?.[0]) {
throw new Error('未能获取图片,请重试');
if (!files) {
openNativeFilePicker();
return;
}
if (!files[0]) return;
await uploadSelectedFile(files[0]);
});
} finally {
@@ -50,6 +50,7 @@ function accountFromProfile(profile: PartnerSessionProfile): PartnerAccount {
staffRole: profile.staffRole,
permissions: profile.permissions,
primaryAccountId: profile.primaryAccountId,
hasWechat: profile.hasWechat,
};
}
+5 -1
View File
@@ -22,7 +22,10 @@ const AUTH_RECOVERY_EXEMPT_PATHS = [
'/partner/auth/login/wechat',
];
export type PartnerSessionProfile = Pick<PartnerMe, 'id' | 'name' | 'phone' | 'companyName' | 'isPrimary' | 'permissions' | 'primaryAccountId'> & {
export type PartnerSessionProfile = Pick<
PartnerMe,
'id' | 'name' | 'phone' | 'companyName' | 'isPrimary' | 'permissions' | 'primaryAccountId' | 'hasWechat'
> & {
staffRole?: PartnerStaffRole;
};
@@ -106,6 +109,7 @@ function profileFromMe(me: PartnerMe): PartnerSessionProfile {
staffRole: me.staffRole ?? undefined,
permissions: me.permissions,
primaryAccountId: me.primaryAccountId,
hasWechat: me.hasWechat,
};
}
+1
View File
@@ -48,6 +48,7 @@ export function sessionFromWechatLogin(result: WechatLoginResult): PartnerSessio
phone: String(partner.phone ?? ''),
companyName: partner.companyName ? String(partner.companyName) : undefined,
isPrimary: partner.isPrimary !== false,
hasWechat: true,
}
: undefined,
};
@@ -135,17 +135,11 @@ export default function StoreCreatePage() {
useEffect(() => {
if (step !== 2 || !isWechatEnv()) return;
void refresh();
void weixinSdk.init().catch(() => {
/* OssUploadField 点击时会再次初始化 */
});
}, [step, refresh]);