FEAT => 本次更新项目为:新增获取京东社交媒体和推广站点列表的接口,并优化相关组件的状态管理与数据处理
This commit is contained in:
@@ -5,7 +5,7 @@ import React, {
|
||||
forwardRef,
|
||||
} from "react";
|
||||
import { Form, Select, Card } from "antd";
|
||||
import request from "@/api/request";
|
||||
import { fetchSocialMediaList, fetchPromotionSiteList } from "../index.api";
|
||||
|
||||
// 京东社交媒体接口
|
||||
interface JdSocialMedia {
|
||||
@@ -73,71 +73,31 @@ const JingDongLink = forwardRef<JingDongLinkRef, JingDongLinkProps>(
|
||||
},
|
||||
}));
|
||||
|
||||
// 获取京东社交媒体列表
|
||||
const fetchSocialMediaList = async () => {
|
||||
setLoadingSocialMedia(true);
|
||||
try {
|
||||
const response = await request(
|
||||
"/v1/workbench/getJdSocialMedia",
|
||||
{},
|
||||
"GET",
|
||||
);
|
||||
if (response && Array.isArray(response)) {
|
||||
setSocialMediaList(response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取京东社交媒体列表失败:", error);
|
||||
} finally {
|
||||
setLoadingSocialMedia(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取京东推广站点列表
|
||||
const fetchPromotionSiteList = async (socialMediaId: string) => {
|
||||
setLoadingPromotionSite(true);
|
||||
try {
|
||||
const response = await request(
|
||||
"/v1/workbench/getJdPromotionSite",
|
||||
{ socialMediaId },
|
||||
"GET",
|
||||
);
|
||||
if (response && Array.isArray(response)) {
|
||||
setPromotionSiteList(response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取京东推广站点列表失败:", error);
|
||||
} finally {
|
||||
setLoadingPromotionSite(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 组件挂载时获取社交媒体列表
|
||||
useEffect(() => {
|
||||
fetchSocialMediaList();
|
||||
fetchSocialMediaList().then(res => {
|
||||
setSocialMediaList(res);
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 监听社交媒体选择变化
|
||||
const handleSocialMediaChange = (value: string) => {
|
||||
const handleSocialMediaChange = (value: number) => {
|
||||
form.setFieldsValue({ socialMediaId: value });
|
||||
// 清空推广站点选择
|
||||
form.setFieldsValue({ promotionSiteId: undefined });
|
||||
setPromotionSiteList([]);
|
||||
|
||||
if (value) {
|
||||
fetchPromotionSiteList(value);
|
||||
fetchPromotionSiteList(value).then(res => {
|
||||
setPromotionSiteList(res);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ marginBottom: 24 }}>
|
||||
<Card title="京东联盟">
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={defaultValues}
|
||||
onValuesChange={(changedValues, allValues) => {
|
||||
// 可以在这里处理表单值变化
|
||||
}}
|
||||
>
|
||||
<Form form={form} layout="vertical" initialValues={defaultValues}>
|
||||
{/* 京东社交媒体选择 */}
|
||||
<Form.Item label="京东联盟" style={{ marginBottom: 16 }}>
|
||||
<div style={{ display: "flex", gap: 12, alignItems: "flex-end" }}>
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import request from "@/api/request";
|
||||
export async function createGroupPushTask(
|
||||
taskData: Partial<GroupPushTask>,
|
||||
): Promise<ApiResponse> {
|
||||
export function createGroupPushTask(taskData) {
|
||||
return request("/v1/workspace/group-push/tasks", taskData, "POST");
|
||||
}
|
||||
|
||||
// 获取京东社交媒体列表
|
||||
export const fetchSocialMediaList = async () => {
|
||||
return request("/v1/workbench/getJdSocialMedia", {}, "GET");
|
||||
};
|
||||
|
||||
// 获取京东推广站点列表
|
||||
export const fetchPromotionSiteList = async (id: number) => {
|
||||
return request("/v1/workbench/getJdPromotionSite", { id }, "GET");
|
||||
};
|
||||
|
||||
@@ -112,8 +112,8 @@ const NewGroupPush: React.FC = () => {
|
||||
isLoopPush: formData.isLoopPush,
|
||||
isImmediatePush: formData.isImmediatePush,
|
||||
isEnabled: formData.isEnabled,
|
||||
targetGroups: formData.wechatGroups,
|
||||
contentLibraries: formData.contentGroups,
|
||||
wechatGroups: formData.wechatGroups,
|
||||
contentGroups: formData.contentGroups,
|
||||
// 京东联盟数据
|
||||
socialMediaId: jingDongLinkValues?.socialMediaId,
|
||||
promotionSiteId: jingDongLinkValues?.promotionSiteId,
|
||||
|
||||
Reference in New Issue
Block a user