场景获客支持拉群
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
// 步骤定义 - 四个步骤
|
||||
// 步骤定义 - 五个步骤
|
||||
import { DeviceSelectionItem } from "@/components/DeviceSelection/data";
|
||||
import { GroupSelectionItem } from "@/components/GroupSelection/data";
|
||||
export const steps = [
|
||||
{ id: 1, title: "步骤一", subtitle: "基础设置" },
|
||||
{ id: 2, title: "步骤二", subtitle: "好友申请设置" },
|
||||
{ id: 3, title: "步骤三", subtitle: "渠道设置" },
|
||||
{ id: 4, title: "步骤四", subtitle: "消息设置" },
|
||||
{ id: 4, title: "步骤四", subtitle: "拉群设置" },
|
||||
{ id: 5, title: "步骤五", subtitle: "消息设置" },
|
||||
];
|
||||
|
||||
// 类型定义
|
||||
@@ -31,6 +32,10 @@ export interface FormData {
|
||||
wechatGroups: string[];
|
||||
wechatGroupsOptions: GroupSelectionItem[];
|
||||
messagePlans: any[];
|
||||
// 拉群设置
|
||||
groupInviteEnabled?: boolean;
|
||||
groupName?: string;
|
||||
fixedGroupMembers?: any[]; // 固定群成员,使用好友选择组件结构
|
||||
// 分销相关
|
||||
distributionEnabled?: boolean;
|
||||
// 选中的分销渠道ID列表(前端使用,提交时转为 distributionChannels)
|
||||
@@ -72,6 +77,9 @@ export const defFormData: FormData = {
|
||||
wechatGroupsOptions: [],
|
||||
contentGroups: [],
|
||||
contentGroupsOptions: [],
|
||||
groupInviteEnabled: false,
|
||||
groupName: "",
|
||||
fixedGroupMembers: [],
|
||||
distributionEnabled: false,
|
||||
distributionChannelIds: [],
|
||||
distributionChannelsOptions: [],
|
||||
|
||||
@@ -5,6 +5,7 @@ import NavCommon from "@/components/NavCommon";
|
||||
import BasicSettings from "./steps/BasicSettings";
|
||||
import FriendRequestSettings from "./steps/FriendRequestSettings";
|
||||
import DistributionSettings from "./steps/DistributionSettings";
|
||||
import GroupSettings from "./steps/GroupSettings";
|
||||
import MessageSettings from "./steps/MessageSettings";
|
||||
import Layout from "@/components/Layout/Layout";
|
||||
import StepIndicator from "@/components/StepIndicator";
|
||||
@@ -112,6 +113,15 @@ export default function NewPlan() {
|
||||
wechatGroupsOptions: detail.wechatGroupsOptions ?? [],
|
||||
contentGroups: detail.contentGroups ?? [],
|
||||
contentGroupsOptions: detail.contentGroupsOptions ?? [],
|
||||
// 拉群设置
|
||||
groupInviteEnabled: detail.groupInviteEnabled ?? false,
|
||||
groupName: detail.groupName ?? "",
|
||||
// 优先使用后端返回的 options(完整好友信息),否则退回到 ID 数组或旧字段
|
||||
fixedGroupMembers:
|
||||
detail.groupFixedMembersOptions ??
|
||||
detail.fixedGroupMembers ??
|
||||
detail.groupFixedMembers ??
|
||||
[],
|
||||
status: detail.status ?? 0,
|
||||
messagePlans: detail.messagePlans ?? [],
|
||||
// 分销相关数据回填
|
||||
@@ -196,11 +206,26 @@ export default function NewPlan() {
|
||||
submitData.distributionEnabled = false;
|
||||
}
|
||||
|
||||
// 拉群设置字段转换
|
||||
if (formData.groupInviteEnabled) {
|
||||
submitData.groupInviteEnabled = true;
|
||||
submitData.groupName = formData.groupName || "";
|
||||
// 后端期望的字段:groupFixedMembers,使用好友ID数组
|
||||
submitData.groupFixedMembers = (formData.fixedGroupMembers || []).map(
|
||||
(f: any) => f.id,
|
||||
);
|
||||
} else {
|
||||
submitData.groupInviteEnabled = false;
|
||||
submitData.groupName = "";
|
||||
submitData.groupFixedMembers = [];
|
||||
}
|
||||
|
||||
// 移除前端使用的字段,避免提交到后端
|
||||
delete submitData.distributionChannelIds;
|
||||
delete submitData.distributionChannelsOptions;
|
||||
delete submitData.distributionCustomerReward;
|
||||
delete submitData.distributionAddReward;
|
||||
delete submitData.fixedGroupMembers;
|
||||
|
||||
if (isEdit && planId) {
|
||||
// 编辑:拼接后端需要的完整参数
|
||||
@@ -272,6 +297,8 @@ export default function NewPlan() {
|
||||
/>
|
||||
);
|
||||
case 4:
|
||||
return <GroupSettings formData={formData} onChange={onChange} />;
|
||||
case 5:
|
||||
return <MessageSettings formData={formData} onChange={onChange} />;
|
||||
default:
|
||||
return null;
|
||||
|
||||
110
src/pages/mobile/scenarios/plan/new/steps/GroupSettings.tsx
Normal file
110
src/pages/mobile/scenarios/plan/new/steps/GroupSettings.tsx
Normal file
@@ -0,0 +1,110 @@
|
||||
import React from "react";
|
||||
import { Input, Switch } from "antd";
|
||||
import styles from "./base.module.scss";
|
||||
import FriendSelection from "@/components/FriendSelection";
|
||||
import type { FriendSelectionItem } from "@/components/FriendSelection/data";
|
||||
|
||||
interface GroupSettingsProps {
|
||||
formData: any;
|
||||
onChange: (data: any) => void;
|
||||
}
|
||||
|
||||
const GroupSettings: React.FC<GroupSettingsProps> = ({ formData, onChange }) => {
|
||||
const handleToggleGroupInvite = (value: boolean) => {
|
||||
onChange({
|
||||
...formData,
|
||||
groupInviteEnabled: value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleGroupNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
onChange({
|
||||
...formData,
|
||||
groupName: e.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleFixedMembersSelect = (friends: FriendSelectionItem[]) => {
|
||||
onChange({
|
||||
...formData,
|
||||
fixedGroupMembers: friends,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles["basic-container"]}>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 16,
|
||||
padding: 16,
|
||||
borderRadius: 8,
|
||||
border: "1px solid #f0f0f0",
|
||||
background: "#fff",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
marginBottom: 12,
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 16,
|
||||
fontWeight: 500,
|
||||
marginBottom: 4,
|
||||
}}
|
||||
>
|
||||
拉群设置
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: "#8c8c8c" }}>
|
||||
开启后,可配置群名称和固定群成员,将用户引导到指定微信群
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
checked={!!formData.groupInviteEnabled}
|
||||
onChange={handleToggleGroupInvite}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{formData.groupInviteEnabled && (
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
||||
<Input
|
||||
placeholder="请输入群名称"
|
||||
value={formData.groupName || ""}
|
||||
onChange={handleGroupNameChange}
|
||||
/>
|
||||
{/* 固定成员选择,复用好友选择组件 */}
|
||||
<div>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 13,
|
||||
marginBottom: 4,
|
||||
color: "#595959",
|
||||
}}
|
||||
>
|
||||
固定群成员
|
||||
</div>
|
||||
<FriendSelection
|
||||
selectedOptions={
|
||||
(formData.fixedGroupMembers || []) as FriendSelectionItem[]
|
||||
}
|
||||
onSelect={handleFixedMembersSelect}
|
||||
placeholder="选择固定群成员"
|
||||
showSelectedList={true}
|
||||
// 根据已选择设备过滤好友列表
|
||||
deviceIds={formData.deviceGroups || []}
|
||||
enableDeviceFilter={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default GroupSettings;
|
||||
Reference in New Issue
Block a user