完成开户方式的修改

This commit is contained in:
Lrd
2026-06-26 14:52:13 +08:00
parent 157e7e5bba
commit 7e2a44c0a1
9 changed files with 260 additions and 213 deletions
File diff suppressed because one or more lines are too long
+36 -36
View File
@@ -1,37 +1,37 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<title>后台管理</title>
<script>
(function() {
var cached = localStorage.getItem('siteInfo');
if (cached) {
try {
var info = JSON.parse(cached);
if (info.siteName) {
document.title = info.siteName + ' - 管理后台';
}
if (info.siteLogo) {
var link = document.querySelector('link[rel="icon"]');
if (link) {
link.href = info.siteLogo;
link.type = 'image/png';
}
}
} catch (e) {}
}
})();
</script>
<script type="module" crossorigin src="/assets/index-BLuHlLoF.js"></script>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<title>后台管理</title>
<script>
(function() {
var cached = localStorage.getItem('siteInfo');
if (cached) {
try {
var info = JSON.parse(cached);
if (info.siteName) {
document.title = info.siteName + ' - 管理后台';
}
if (info.siteLogo) {
var link = document.querySelector('link[rel="icon"]');
if (link) {
link.href = info.siteLogo;
link.type = 'image/png';
}
}
} catch (e) {}
}
})();
</script>
<script type="module" crossorigin src="/assets/index-CtDh7BHk.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
</head>
<body>
<div id="root"></div>
</body>
</html>
+12
View File
@@ -470,6 +470,18 @@ export async function deleteOpenType(id: string): Promise<void> {
await api.delete(`/open-type/delete/${id}`);
}
export interface OpenTypeItem {
id: string;
openType: number;
typeName: string;
description: string;
thumb?: string;
}
export async function getOpenTypeAll(): Promise<{ data: OpenTypeItem[] }> {
return api.get('/open-type/open_type_all');
}
// ── Generation Records (Admin) ─────────────────────────────
export async function getAdminGenerationRecords(params?: {
+24 -33
View File
@@ -2,20 +2,7 @@ import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { Button, Card, Space, Table, Tag, Modal, Select, App, Input, Typography } from 'antd';
import { PlusOutlined, LockOutlined } from '@ant-design/icons';
import { getOAuthList, requestOAuth } from '../api';
const OPEN_TYPE_MAP: Record<number, string> = {
1: '千川',
2: '广告',
3: '本地推',
4: '星图',
5: '快手代理商',
6: '巨量星图',
7: '巨量服务单',
8: '腾讯服务单',
9: '腾讯营销K2',
10: '腾讯营销K3',
};
import { getOAuthList, requestOAuth, getOpenTypeAll } from '../api';
const PORT_TYPE_MAP: Record<number, string> = {
1: '巨量',
@@ -62,11 +49,31 @@ const AuthorizationPage: React.FC = () => {
open_type: undefined as number | undefined,
account_id: '',
});
const [openTypeMap, setOpenTypeMap] = useState<Record<number, string>>({});
const [openTypeOptions, setOpenTypeOptions] = useState<{ value: number; label: string }[]>([]);
useEffect(() => {
loadOAuthList();
loadOpenTypeList();
}, []);
const loadOpenTypeList = async () => {
try {
const res = await getOpenTypeAll();
const data = res.data || [];
const map: Record<number, string> = {};
const options: { value: number; label: string }[] = [];
data.forEach(item => {
map[item.openType] = item.typeName;
options.push({ value: item.openType, label: item.typeName });
});
setOpenTypeMap(map);
setOpenTypeOptions(options);
} catch (error) {
console.error('加载开户方式列表失败:', error);
}
};
const loadOAuthList = async (page = 1, pageSize = 10, params = searchParams) => {
setListLoading(true);
try {
@@ -197,7 +204,7 @@ const AuthorizationPage: React.FC = () => {
title: '开户方式',
dataIndex: 'openType',
key: 'openType',
render: (text: number) => <span style={{ color: '#1e293b' }}>{OPEN_TYPE_MAP[text] || text}</span>,
render: (text: number) => <span style={{ color: '#1e293b' }}>{openTypeMap[text] || text}</span>,
},
{
title: '平台端口',
@@ -225,16 +232,6 @@ const AuthorizationPage: React.FC = () => {
width: 160,
render: (text: string) => <span style={{ color: '#64748b' }}>{formatDateTime(text)}</span>,
},
{
title: '操作',
key: 'action',
width: 120,
render: (_: unknown, record: AuthorizationData) => (
<Link to={`/consume?accountId=${record.id}`} style={{ color: '#6366f1' }}>
</Link>
),
},
];
const tableData = authorizations.map((item, index) => ({
@@ -279,10 +276,7 @@ const AuthorizationPage: React.FC = () => {
value={searchParams.open_type}
onChange={(value) => setSearchParams(prev => ({ ...prev, open_type: value }))}
style={{ width: 140 }}
options={Object.entries(OPEN_TYPE_MAP).map(([key, value]) => ({
value: Number(key),
label: value,
}))}
options={openTypeOptions}
/>
<Input
placeholder="账号ID"
@@ -349,10 +343,7 @@ const AuthorizationPage: React.FC = () => {
value={selectedOpenType}
onChange={(value) => setSelectedOpenType(value)}
style={{ width: '100%' }}
options={Object.entries(OPEN_TYPE_MAP).map(([key, value]) => ({
value: Number(key),
label: value,
}))}
options={openTypeOptions}
/>
</Modal>
</div>
+19 -8
View File
@@ -78,11 +78,13 @@ const AdminPlatform: React.FC = () => {
const handleCreate = async () => {
try {
const values = await createForm.validateFields();
const thumbUrl = createThumbUrl;
const thumbPath = thumbUrl.startsWith('http') ? thumbUrl.replace(/^https?:\/\/[^/]+/, '') : thumbUrl;
await createOpenType({
open_type: values.open_type,
type_name: values.type_name,
description: values.description,
thumb: createThumbUrl,
thumb: thumbPath,
});
message.success('创建成功');
setCreateModalVisible(false);
@@ -107,8 +109,11 @@ const AdminPlatform: React.FC = () => {
const handleUpdate = async (id: string) => {
try {
const openType = await getOpenType(id);
const thumb = openType.data?.thumb || '';
const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
const fullThumbUrl = thumb.startsWith('http') ? thumb : `${baseUrl}${thumb}`;
setCurrentOpenType(openType.data || {});
setUpdateThumbUrl(openType.thumb || '');
setUpdateThumbUrl(fullThumbUrl);
setUpdateModalVisible(true);
} catch (e: any) {
message.error(e?.message || '获取详情失败');
@@ -119,11 +124,13 @@ const AdminPlatform: React.FC = () => {
if (!currentOpenType) return;
try {
const values = await updateForm.validateFields();
const thumbUrl = updateThumbUrl;
const thumbPath = thumbUrl.startsWith('http') ? thumbUrl.replace(/^https?:\/\/[^/]+/, '') : thumbUrl;
await updateOpenType(currentOpenType.id, {
open_type: values.open_type,
type_name: values.type_name,
description: values.description,
thumb: updateThumbUrl,
thumb: thumbPath,
});
message.success('更新成功');
setUpdateModalVisible(false);
@@ -218,7 +225,7 @@ const AdminPlatform: React.FC = () => {
},
{
title: '操作',
width: 200,
width: 240,
render: (_: any, record: OpenType) => (
<Space>
<Button
@@ -337,8 +344,10 @@ const AdminPlatform: React.FC = () => {
try {
const uploadFile = assertUploadFile(file);
const res = await uploadImage(uploadFile);
setCreateThumbUrl(res.url);
onSuccess?.({ url: res.url });
const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
const fullUrl = res.url.startsWith('http') ? res.url : `${baseUrl}${res.url}`;
setCreateThumbUrl(fullUrl);
onSuccess?.({ url: fullUrl });
} catch (e) {
onError?.(normalizeUploadError(e));
}
@@ -481,8 +490,10 @@ const AdminPlatform: React.FC = () => {
try {
const uploadFile = assertUploadFile(file);
const res = await uploadImage(uploadFile);
setUpdateThumbUrl(res.url);
onSuccess?.({ url: res.url });
const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
const fullUrl = res.url.startsWith('http') ? res.url : `${baseUrl}${res.url}`;
setUpdateThumbUrl(fullUrl);
onSuccess?.({ url: fullUrl });
} catch (e) {
onError?.(normalizeUploadError(e));
}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
}
})();
</script>
<script type="module" crossorigin src="/assets/index-b7j6q-om.js"></script>
<script type="module" crossorigin src="/assets/index-CV-e6vqH.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-eLRg4pQk.css">
</head>
<body>
+12
View File
@@ -699,4 +699,16 @@ export async function getResourcesMaterialList(params: ResourcesMaterialListPara
if (params.page !== undefined) query.set('page', String(params.page));
if (params.page_size !== undefined) query.set('page_size', String(params.page_size));
return api.get(`/resources-material/list?${query.toString()}`);
}
export interface OpenTypeItem {
id: string;
openType: number;
typeName: string;
description: string;
thumb?: string;
}
export async function getOpenTypeAll(): Promise<{ data: OpenTypeItem[] }> {
return api.get('/open-type/open_type_all');
}
+62 -41
View File
@@ -1,21 +1,7 @@
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { Button, Table, Tag, Modal, Select, App, Input, Pagination, Typography } from 'antd';
import { PlusOutlined, LockOutlined } from '@ant-design/icons';
import { getOAuthList, requestOAuth } from '../api';
const OPEN_TYPE_MAP: Record<number, string> = {
1: '千川',
2: '广告',
3: '本地推',
4: '星图',
5: '快手代理商',
6: '巨量星图',
7: '巨量服务单',
8: '腾讯服务单',
9: '腾讯营销K2',
10: '腾讯营销K3',
};
import { getOAuthList, requestOAuth, getOpenTypeAll } from '../api';
const PORT_TYPE_MAP: Record<number, string> = {
1: '巨量',
@@ -25,7 +11,6 @@ const PORT_TYPE_MAP: Record<number, string> = {
5: '腾讯',
};
// 格式化时间 2026-06-12T03:47:28.542988Z -> 2026-06-12 03:47:28
const formatDateTime = (dateStr: string) => {
if (!dateStr) return '';
const date = new Date(dateStr);
@@ -62,11 +47,33 @@ const AuthorizationPage: React.FC = () => {
open_type: undefined as number | undefined,
account_id: '',
});
const [openTypeMap, setOpenTypeMap] = useState<Record<number, string>>({});
const [openTypeOptions, setOpenTypeOptions] = useState<{ value: number; label: string }[]>([]);
const [openTypeList, setOpenTypeList] = useState<any[]>([]);
useEffect(() => {
loadOAuthList();
loadOpenTypeList();
}, []);
const loadOpenTypeList = async () => {
try {
const res = await getOpenTypeAll();
const data = res.data || [];
const map: Record<number, string> = {};
const options: { value: number; label: string }[] = [];
data.forEach(item => {
map[item.openType] = item.typeName;
options.push({ value: item.openType, label: item.typeName });
});
setOpenTypeMap(map);
setOpenTypeOptions(options);
setOpenTypeList(data);
} catch (error) {
console.error('加载开户方式列表失败:', error);
}
};
const loadOAuthList = async (page = 1, pageSize = 10, params = searchParams) => {
setListLoading(true);
try {
@@ -121,6 +128,7 @@ const AuthorizationPage: React.FC = () => {
setSelectedOpenType(undefined);
}
};
const columns = [
{
title: 'ID',
@@ -197,7 +205,7 @@ const AuthorizationPage: React.FC = () => {
title: '开户方式',
dataIndex: 'openType',
key: 'openType',
render: (text: number) => <span style={{ color: '#1e293b' }}>{OPEN_TYPE_MAP[text] || text}</span>,
render: (text: number) => <span style={{ color: '#1e293b' }}>{openTypeMap[text] || text}</span>,
},
{
title: '平台端口',
@@ -225,16 +233,6 @@ const AuthorizationPage: React.FC = () => {
width: 160,
render: (text: string) => <span style={{ color: '#64748b' }}>{formatDateTime(text)}</span>,
},
// {
// title: '操作',
// key: 'action',
// width: 120,
// render: (_: unknown) => (
// <Link to={`/consume`} style={{ color: '#6366f1' }}>
// 查看消耗
// </Link>
// ),
// },
];
const tableData = authorizations.map((item, index) => ({
@@ -264,10 +262,7 @@ const AuthorizationPage: React.FC = () => {
value={searchParams.open_type}
onChange={(value) => setSearchParams(prev => ({ ...prev, open_type: value }))}
style={{ width: 140 }}
options={Object.entries(OPEN_TYPE_MAP).map(([key, value]) => ({
value: Number(key),
label: value,
}))}
options={openTypeOptions}
/>
<Input
placeholder="账号ID"
@@ -348,17 +343,43 @@ const AuthorizationPage: React.FC = () => {
okText="确认授权"
cancelText="取消"
confirmLoading={loading}
width={700}
>
<Select
placeholder="请选择开户方式"
value={selectedOpenType}
onChange={(value) => setSelectedOpenType(value)}
style={{ width: '100%' }}
options={Object.entries(OPEN_TYPE_MAP).map(([key, value]) => ({
value: Number(key),
label: value,
}))}
/>
<div style={{ display: 'flex', gap: 16, flexWrap: 'wrap', maxHeight: 420, overflowY: 'auto' }}>
{openTypeList.map((item) => (
<div
key={item.id}
onClick={() => setSelectedOpenType(item.openType)}
style={{
width: 'calc(33.33% - 12px)',
cursor: 'pointer',
borderRadius: 12,
border: `2px solid ${selectedOpenType === item.openType ? '#6366f1' : '#e2e8f0'}`,
padding: 16,
transition: 'all 0.3s ease',
background: selectedOpenType === item.openType ? '#f0f1ff' : '#fff',
}}
>
<div style={{ width: '100%', height: 120, marginBottom: 12, borderRadius: 8, overflow: 'hidden' }}>
{item.thumb ? (
<img
src={item.thumb}
alt={item.typeName}
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
) : (
<div style={{ width: '100%', height: '100%', background: '#f1f5f9', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Typography.Text type="secondary"></Typography.Text>
</div>
)}
</div>
<Typography.Text strong style={{ fontSize: 14, color: '#1e293b' }}>{item.typeName}</Typography.Text>
<p style={{ fontSize: 12, color: '#64748b', marginTop: 8, marginBottom: 0, lineHeight: 1.5 }}>
{item.description}
</p>
</div>
))}
</div>
</Modal>
</div>
);