feat(admin): HQ手机号编辑、合伙人子账号日志与子账号H5体验
支持 HQ 账户改手机号(格式校验)、合伙人日志包含子账号且子账号不显示主账号信息;改手机号时清除微信绑定。合伙人 H5 子账号页签与我的页、录入门店底部按钮及上传失败提示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '../lib/wechat-auth';
|
||||
import { formatChooseImageFailMessage } from '@dukang/weixin-sdk';
|
||||
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
||||
import { toastError } from '../lib/toast';
|
||||
import type { ClientRuntimeConfig } from '@dukang/shared-types';
|
||||
|
||||
type OssUploadFieldProps = {
|
||||
@@ -61,6 +62,11 @@ export default function OssUploadField({
|
||||
const [profile, setProfile] = useState<PartnerProfile | null>(null);
|
||||
const [clientConfig, setClientConfig] = useState<ClientRuntimeConfig | null>(null);
|
||||
|
||||
function showUploadError(text: string) {
|
||||
setError(text);
|
||||
toastError(text);
|
||||
}
|
||||
|
||||
const resolvedAccept =
|
||||
accept ?? (mediaType === 'VIDEO' ? 'video/*' : mediaType === 'FILE' ? 'image/*,.pdf' : 'image/*');
|
||||
const inWechat = isWechatEnv();
|
||||
@@ -91,7 +97,7 @@ export default function OssUploadField({
|
||||
async function uploadSelectedFile(file: File) {
|
||||
if (file.size > DEFAULT_MAX_MB * 1024 * 1024) {
|
||||
const text = `文件不能超过 ${DEFAULT_MAX_MB}MB`;
|
||||
setError(text);
|
||||
showUploadError(text);
|
||||
return;
|
||||
}
|
||||
setUploading(true);
|
||||
@@ -100,7 +106,7 @@ export default function OssUploadField({
|
||||
const result = await enqueueUpload(() => uploadFileToOss(file, { bizType, mediaType }));
|
||||
onChange?.(result.url);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : '上传失败');
|
||||
showUploadError(e instanceof Error ? e.message : '上传失败');
|
||||
} finally {
|
||||
setUploading(false);
|
||||
if (inputRef.current) inputRef.current.value = '';
|
||||
@@ -114,7 +120,7 @@ export default function OssUploadField({
|
||||
await authorizePartnerWechat();
|
||||
} catch (e) {
|
||||
const text = e instanceof Error ? e.message : '微信授权失败';
|
||||
setError(text);
|
||||
showUploadError(text);
|
||||
setAuthorizing(false);
|
||||
}
|
||||
}
|
||||
@@ -149,7 +155,7 @@ export default function OssUploadField({
|
||||
|
||||
if (useWechatPicker && needsAuth) {
|
||||
const text = '请先完成微信授权后再上传照片';
|
||||
setError(text);
|
||||
showUploadError(text);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -159,7 +165,7 @@ export default function OssUploadField({
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : '无法打开相册';
|
||||
if (/cancel/i.test(msg)) return;
|
||||
setError(formatWechatUploadError(e));
|
||||
showUploadError(formatWechatUploadError(e));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user