From 92bbcb290969671dcf28f18164d7b0a0714748da Mon Sep 17 00:00:00 2001 From: yezian Date: Thu, 26 Dec 2024 23:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=BB=E7=BB=93=E6=8F=90=E7=8E=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/BlockWithdraw/index.jsx | 308 ++++++++++++++++++++++++++++++ src/routes/index.js | 5 + 2 files changed, 313 insertions(+) create mode 100644 src/pages/BlockWithdraw/index.jsx diff --git a/src/pages/BlockWithdraw/index.jsx b/src/pages/BlockWithdraw/index.jsx new file mode 100644 index 0000000..6e67458 --- /dev/null +++ b/src/pages/BlockWithdraw/index.jsx @@ -0,0 +1,308 @@ +import React, { useState, useRef, useEffect } from "react"; +import { Form, Input, Button, Space, Table, Image, Modal } from "antd"; +import baseRequest from "../../utils/baseRequest"; + +const BlockWithdrawContent = (props) => { + const current = props.current; + //表头 + const columns = [ + { + title: "用户信息", + dataIndex: "user", + key: "user", + render: (data) => ( +
+ +

+ 昵称:{data.name} +

+

+ ID:{data.user_id} +

+
+ ), + }, + { + title: "冻结时间", + dataIndex: "ct", + key: "ct", + }, + { + title: "操作", + dataIndex: "opeartion", + key: "opeartion", + render: (_, record) => ( +
+ + + + + +
+ ), + }, + ]; + //给表单绑定ref + const formRef = useRef(null); + //点击修改状态按钮 + const unblock = (record) => { + formRef.current.user_id = record.user.user_id; + formRef.current.btn = "unblock"; + formRef.current.submit(); + }; + //解封 + const handleSubmit = async (value) => { + //提交数据 + try { + const base = baseRequest(); + const _response = await fetch("/op/vas/del_withdraw_freeze", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + user_id: formRef.current.user_id, + ...base, + }), + }); + const _data = await _response.json(); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + } catch (error) { + console.error(error); + } + //刷新页面 + window.location.reload(); + }; + + //获取数据 + const [data, setData] = useState([]); + const getData = async () => { + try { + const base = baseRequest(); + const _response = await fetch("/op/vas/get_withdraw_freeze_list", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...base, + }), + }); + const _data = await _response.json(); + console.log(_data); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + //匹配表格格式 + const structedData = _data.data.list.map((item, index) => { + return { + key: index, + user: { + // avatar: item.account.avatar?.images[0].urls[0], + user_id: item.user_id, + // name: item.account.name, + }, + ct: new Date(item.ct * 1000).toLocaleString(), + }; + }); + setData([...data, ...structedData]); + } catch (error) { + console.error(error); + } + }; + useEffect(() => { + getData(); + }, [current]); + + //展示的数据 + const [showData, setShowData] = useState([]); + useEffect(() => { + setShowData(data); + }, [data]); + + //搜索用户 + const search = (value) => { + value.id + ? setShowData(data.filter((item) => item.user.user_id == value.id)) + : setShowData(data); + }; + + //打开添加封禁Modal + const [isModalVisible, setIsModalVisible] = useState(false); + + //在modal中搜索用户 + const [userInfo, setUserInfo] = useState(); + const modalSearch = async (value) => { + try { + const base = baseRequest(); + const _response = await fetch(`/op/account/list_by_user_id`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + user_id: parseInt(value.userId, 10), + ...base, + }), + }); + const _data = await _response.json(); + console.log(_data); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + setSelectedUser(); + setUserInfo(_data.data.account); + } catch (error) { + console.error(error); + } + }; + //选中用户 + const [selectedUser, setSelectedUser] = useState(); + const handleSelected = () => { + if (selectedUser) { + setSelectedUser(); + return; + } + setSelectedUser(userInfo.user_id); + }; + //添加封禁 + const [form] = Form.useForm(); + const block = async (value) => { + if (!selectedUser) { + alert("还未选中用户"); + return; + } + try { + const base = baseRequest(); + const _response = await fetch("/op/vas/add_withdraw_freeze", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + user_id: selectedUser, + ...base, + }), + }); + const _data = await _response.json(); + console.log(_data); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + handleCancelModal(); + //刷新页面 + window.location.reload(); + } catch (error) { + console.error(error); + } + }; + + //关闭弹窗 + const handleCancelModal = () => { + form.resetFields(); + setUserInfo(); + setSelectedUser(); + setIsModalVisible(false); + }; + + //表单提交失败 + const onFinishFailed = (errorInfo) => { + console.log("Failed:", errorInfo); + }; + return ( +
+
+ + + + + + +
+ +
+ + + {isModalVisible && ( + +

+ *请选中用户后再执行操作 +

+
+ + + + + + + + {userInfo && ( +
+ +
+

ID:{userInfo.user_id}

+

昵称:{userInfo.name}

+
+ +
+ )} +
+ + +
+ )} + + ); +}; + +export default function BlockWithdraw() { + return ; +} diff --git a/src/routes/index.js b/src/routes/index.js index 1ba6e27..5a37650 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -34,6 +34,7 @@ import StreamerTextMachineReview from "../pages/StreamerTextMachineReview"; import StreamerVideoMachineReview from "../pages/StreamerVideoMachineReview"; import RollbackUserLeaveSpace from "../pages/RollbackUserLeaveSpace"; import RollbackUserRefundSpaceStatus from "../pages/RollbackUserRefundSpaceStatus/index"; +import BlockWithdraw from "../pages/BlockWithdraw"; const routes = [ { @@ -180,6 +181,10 @@ const routes = [ path: "rollbackUserRefundSpaceStatus/*", element: , }, + { + path: "blockWithdraw/*", + element: , + }, ], }, ];