修复合伙人端上传门头照片失败的问题
This commit is contained in:
@@ -117,10 +117,16 @@ export default function OssUploadField({
|
|||||||
setAuthorizing(true);
|
setAuthorizing(true);
|
||||||
setError('');
|
setError('');
|
||||||
try {
|
try {
|
||||||
await authorizePartnerWechat();
|
const result = await authorizePartnerWechat();
|
||||||
|
if (result) {
|
||||||
|
const me = await fetchPartnerProfile();
|
||||||
|
setProfile(me);
|
||||||
|
onWechatReadyChange?.(!!me.hasWechat);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const text = e instanceof Error ? e.message : '微信授权失败';
|
const text = e instanceof Error ? e.message : '微信授权失败';
|
||||||
showUploadError(text);
|
showUploadError(text);
|
||||||
|
} finally {
|
||||||
setAuthorizing(false);
|
setAuthorizing(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,9 +145,11 @@ export default function OssUploadField({
|
|||||||
count: 1,
|
count: 1,
|
||||||
sourceType: ['album', 'camera'],
|
sourceType: ['album', 'camera'],
|
||||||
});
|
});
|
||||||
if (!files?.[0]) {
|
if (!files) {
|
||||||
throw new Error('未能获取图片,请重试');
|
openNativeFilePicker();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (!files[0]) return;
|
||||||
await uploadSelectedFile(files[0]);
|
await uploadSelectedFile(files[0]);
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ function accountFromProfile(profile: PartnerSessionProfile): PartnerAccount {
|
|||||||
staffRole: profile.staffRole,
|
staffRole: profile.staffRole,
|
||||||
permissions: profile.permissions,
|
permissions: profile.permissions,
|
||||||
primaryAccountId: profile.primaryAccountId,
|
primaryAccountId: profile.primaryAccountId,
|
||||||
|
hasWechat: profile.hasWechat,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ const AUTH_RECOVERY_EXEMPT_PATHS = [
|
|||||||
'/partner/auth/login/wechat',
|
'/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;
|
staffRole?: PartnerStaffRole;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,6 +109,7 @@ function profileFromMe(me: PartnerMe): PartnerSessionProfile {
|
|||||||
staffRole: me.staffRole ?? undefined,
|
staffRole: me.staffRole ?? undefined,
|
||||||
permissions: me.permissions,
|
permissions: me.permissions,
|
||||||
primaryAccountId: me.primaryAccountId,
|
primaryAccountId: me.primaryAccountId,
|
||||||
|
hasWechat: me.hasWechat,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export function sessionFromWechatLogin(result: WechatLoginResult): PartnerSessio
|
|||||||
phone: String(partner.phone ?? ''),
|
phone: String(partner.phone ?? ''),
|
||||||
companyName: partner.companyName ? String(partner.companyName) : undefined,
|
companyName: partner.companyName ? String(partner.companyName) : undefined,
|
||||||
isPrimary: partner.isPrimary !== false,
|
isPrimary: partner.isPrimary !== false,
|
||||||
|
hasWechat: true,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -135,17 +135,11 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
if (step !== 2 || !isWechatEnv()) return;
|
if (step !== 2 || !isWechatEnv()) return;
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
void weixinSdk.init().catch(() => {
|
void weixinSdk.init().catch(() => {
|
||||||
|
|
||||||
/* OssUploadField 点击时会再次初始化 */
|
/* OssUploadField 点击时会再次初始化 */
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}, [step, refresh]);
|
}, [step, refresh]);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,17 +9,13 @@ let scriptPromise: Promise<void> | null = null;
|
|||||||
let configured = false;
|
let configured = false;
|
||||||
let configuredUrl: string | null = null;
|
let configuredUrl: string | null = null;
|
||||||
|
|
||||||
/** 参与 JSSDK 签名的页面 URL(去掉 hash、OAuth 回跳参数) */
|
/** 参与 JSSDK 签名的页面 URL(去掉 hash、query;SPA 步骤参数不参与签名) */
|
||||||
export function normalizeJssdkPageUrl(rawUrl: string): string {
|
export function normalizeJssdkPageUrl(rawUrl: string): string {
|
||||||
try {
|
try {
|
||||||
const url = new URL(rawUrl);
|
const url = new URL(rawUrl);
|
||||||
url.hash = '';
|
return `${url.origin}${url.pathname}`;
|
||||||
url.searchParams.delete('code');
|
|
||||||
url.searchParams.delete('state');
|
|
||||||
const query = url.searchParams.toString();
|
|
||||||
return `${url.origin}${url.pathname}${query ? `?${query}` : ''}`;
|
|
||||||
} catch {
|
} catch {
|
||||||
return rawUrl.split('#')[0];
|
return rawUrl.split('#')[0].split('?')[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,18 +24,24 @@ type LogOssUploadInput = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function logOssUpload(prisma: PrismaService, input: LogOssUploadInput) {
|
export async function logOssUpload(prisma: PrismaService, input: LogOssUploadInput) {
|
||||||
const row = await prisma.logThirdParty.create({
|
try {
|
||||||
data: {
|
const row = await prisma.logThirdParty.create({
|
||||||
provider: 'ALIYUN_OSS',
|
data: {
|
||||||
scene: input.scene,
|
provider: 'ALIYUN_OSS',
|
||||||
refType: input.actorRef?.refType,
|
scene: input.scene,
|
||||||
refId: input.actorRef?.refId,
|
refType: input.actorRef?.refType,
|
||||||
requestBody: input.requestBody as never,
|
refId: input.actorRef?.refId,
|
||||||
responseBody: input.responseBody as never,
|
requestBody: input.requestBody as never,
|
||||||
externalNo: input.externalNo?.slice(0, 128),
|
responseBody: input.responseBody as never,
|
||||||
status: input.status,
|
externalNo: input.externalNo?.slice(0, 128),
|
||||||
errorMessage: input.errorMessage?.slice(0, 512),
|
status: input.status,
|
||||||
},
|
errorMessage: input.errorMessage?.slice(0, 512),
|
||||||
});
|
},
|
||||||
return row.id;
|
});
|
||||||
|
return row.id;
|
||||||
|
} catch (err) {
|
||||||
|
// 日志表/枚举未就绪时不阻断上传主流程
|
||||||
|
console.error('[oss-upload-log] write failed:', err instanceof Error ? err.message : err);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,13 +86,9 @@ export class WechatController {
|
|||||||
private normalizeJssdkUrl(rawUrl: string): string {
|
private normalizeJssdkUrl(rawUrl: string): string {
|
||||||
try {
|
try {
|
||||||
const parsed = new URL(rawUrl);
|
const parsed = new URL(rawUrl);
|
||||||
parsed.hash = '';
|
return `${parsed.origin}${parsed.pathname}`;
|
||||||
parsed.searchParams.delete('code');
|
|
||||||
parsed.searchParams.delete('state');
|
|
||||||
const query = parsed.searchParams.toString();
|
|
||||||
return `${parsed.origin}${parsed.pathname}${query ? `?${query}` : ''}`;
|
|
||||||
} catch {
|
} catch {
|
||||||
return rawUrl;
|
return rawUrl.split('#')[0].split('?')[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user