diff --git a/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/api.ts b/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/api.ts index d98ec6d2..557ae0c9 100644 --- a/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/api.ts +++ b/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/api.ts @@ -27,3 +27,12 @@ export function getWechatFriends(params: { export function getWechatFriendDetail(id: string) { return request("/v1/WechatFriend/detail", { id }, "GET"); } + +// 好友转移接口 +export function transferWechatFriends(params: { + wechatId: string; + devices: number[]; + inherit: boolean; +}) { + return request("/v1/wechats/transfer-friends", params, "POST"); +} diff --git a/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/detail.module.scss b/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/detail.module.scss index c77c7dd4..c6309f70 100644 --- a/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/detail.module.scss +++ b/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/detail.module.scss @@ -582,6 +582,36 @@ line-height: 1.5; } + .transfer-form { + margin-top: 20px; + + .form-item { + margin-bottom: 16px; + + .form-label { + font-size: 14px; + font-weight: 500; + color: #333; + margin-bottom: 8px; + } + + .form-control { + width: 100%; + } + + .form-control-switch { + display: flex; + align-items: center; + + .switch-label { + margin-left: 8px; + font-size: 14px; + color: #666; + } + } + } + } + .popup-actions { display: flex; flex-direction: column; diff --git a/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/index.tsx b/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/index.tsx index 12eb5e0f..3be617b5 100644 --- a/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/index.tsx +++ b/Cunkebao/src/pages/mobile/mine/wechat-accounts/detail/index.tsx @@ -10,6 +10,7 @@ import { Toast, Avatar, Tag, + Switch, } from "antd-mobile"; import { Input, Pagination } from "antd"; import NavCommon from "@/components/NavCommon"; @@ -20,7 +21,9 @@ import { } from "@ant-design/icons"; import Layout from "@/components/Layout/Layout"; import style from "./detail.module.scss"; -import { getWechatAccountDetail, getWechatFriends } from "./api"; +import { getWechatAccountDetail, getWechatFriends, transferWechatFriends } from "./api"; +import DeviceSelection from "@/components/DeviceSelection"; +import { DeviceSelectionItem } from "@/components/DeviceSelection/data"; import { WechatAccountSummary, Friend } from "./data"; @@ -33,6 +36,9 @@ const WechatAccountDetail: React.FC = () => { const [accountInfo, setAccountInfo] = useState(null); const [showRestrictions, setShowRestrictions] = useState(false); const [showTransferConfirm, setShowTransferConfirm] = useState(false); + const [selectedDevices, setSelectedDevices] = useState([]); + const [inheritInfo, setInheritInfo] = useState(true); + const [transferLoading, setTransferLoading] = useState(false); const [searchQuery, setSearchQuery] = useState(""); const [activeTab, setActiveTab] = useState("overview"); const [loadingInfo, setLoadingInfo] = useState(true); @@ -181,16 +187,54 @@ const WechatAccountDetail: React.FC = () => { }; const handleTransferFriends = () => { + setSelectedDevices([]); + setInheritInfo(true); setShowTransferConfirm(true); }; - const confirmTransferFriends = () => { - Toast.show({ - content: "好友转移计划已创建,请在场景获客中查看详情", - position: "top", - }); - setShowTransferConfirm(false); - navigate("/scenarios"); + const confirmTransferFriends = async () => { + if (!id) { + Toast.show({ + content: "微信账号ID不存在", + position: "top", + }); + return; + } + + if (selectedDevices.length === 0) { + Toast.show({ + content: "请选择至少一个目标设备", + position: "top", + }); + return; + } + + try { + setTransferLoading(true); + + // 调用好友转移API + await transferWechatFriends({ + wechatId: id, + devices: selectedDevices.map(device => device.id), + inherit: inheritInfo + }); + + Toast.show({ + content: "好友转移计划已创建,请在场景获客中查看详情", + position: "top", + }); + setShowTransferConfirm(false); + setSelectedDevices([]); + navigate("/scenarios"); + } catch (error) { + console.error("好友转移失败:", error); + Toast.show({ + content: "好友转移失败,请重试", + position: "top", + }); + } finally { + setTransferLoading(false); + } }; const getRestrictionLevelColor = (level: number) => { @@ -545,15 +589,54 @@ const WechatAccountDetail: React.FC = () => {

确定要将该微信号的好友转移到其他账号吗?此操作将创建一个好友转移计划。

+ +
+ {/* 设备选择 */} +
+
迁移的新设备
+
+ +
+
+ + {/* 同步原有信息 */} +
+
同步原有信息
+
+ + + {inheritInfo ? "是" : "否"} + +
+
+
+
- diff --git a/Server/application/cunkebao/controller/wechat/PostTransferFriends.php b/Server/application/cunkebao/controller/wechat/PostTransferFriends.php index 2b1106a8..1839231a 100644 --- a/Server/application/cunkebao/controller/wechat/PostTransferFriends.php +++ b/Server/application/cunkebao/controller/wechat/PostTransferFriends.php @@ -69,7 +69,8 @@ class PostTransferFriends extends BaseController 'greeting' => '您好,我是'. $wechat['nickname'] .'的辅助客服,请通过' ]; - $createAddFriendPlan = new PostCreateAddFriendPlanV1Controller(); + // 使用容器获取控制器实例,而不是直接实例化 + $createAddFriendPlan = app('app\cunkebao\controller\plan\PostCreateAddFriendPlanV1Controller'); $taskId = Db::name('customer_acquisition_task')->insertGetId([ 'name' => '迁移好友('. $wechat['nickname'] .')',