好友迁移
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<any>(null);
|
||||
const [showRestrictions, setShowRestrictions] = useState(false);
|
||||
const [showTransferConfirm, setShowTransferConfirm] = useState(false);
|
||||
const [selectedDevices, setSelectedDevices] = useState<DeviceSelectionItem[]>([]);
|
||||
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 = () => {
|
||||
<p className={style["popup-description"]}>
|
||||
确定要将该微信号的好友转移到其他账号吗?此操作将创建一个好友转移计划。
|
||||
</p>
|
||||
|
||||
<div className={style["transfer-form"]}>
|
||||
{/* 设备选择 */}
|
||||
<div className={style["form-item"]}>
|
||||
<div className={style["form-label"]}>迁移的新设备</div>
|
||||
<div className={style["form-control"]}>
|
||||
<DeviceSelection
|
||||
selectedOptions={selectedDevices}
|
||||
onSelect={setSelectedDevices}
|
||||
placeholder="请选择目标设备"
|
||||
showSelectedList={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 同步原有信息 */}
|
||||
<div className={style["form-item"]}>
|
||||
<div className={style["form-label"]}>同步原有信息</div>
|
||||
<div className={style["form-control-switch"]}>
|
||||
<Switch
|
||||
checked={inheritInfo}
|
||||
onChange={setInheritInfo}
|
||||
/>
|
||||
<span className={style["switch-label"]}>
|
||||
{inheritInfo ? "是" : "否"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={style["popup-actions"]}>
|
||||
<Button block color="primary" onClick={confirmTransferFriends}>
|
||||
确认转移
|
||||
<Button
|
||||
block
|
||||
color="primary"
|
||||
onClick={confirmTransferFriends}
|
||||
loading={transferLoading}
|
||||
disabled={transferLoading}
|
||||
>
|
||||
{transferLoading ? "转移中..." : "确认转移"}
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
color="danger"
|
||||
fill="outline"
|
||||
onClick={() => setShowTransferConfirm(false)}
|
||||
onClick={() => {
|
||||
setShowTransferConfirm(false);
|
||||
setSelectedDevices([]);
|
||||
}}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
|
||||
@@ -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'] .')',
|
||||
|
||||
Reference in New Issue
Block a user