diff --git a/.env b/.env
index 8e5417d..38cadfb 100644
--- a/.env
+++ b/.env
@@ -1,2 +1 @@
-REACT_APP_API_URL=https://api.wishpal.cn
REACT_APP_RSA_KEY=-----BEGIN PUBLIC KEY-----MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMXPIjKV6CMi5O9tIXJWNIfnqXjqOZ1KmRByRAP073DU+gzMLygzEsrztJzbz/K/Julkz6XhheZ8vdz+boAl1HsCAwEAAQ==-----END PUBLIC KEY-----
\ No newline at end of file
diff --git a/package.json b/package.json
index 7605b35..ec5f270 100644
--- a/package.json
+++ b/package.json
@@ -47,5 +47,5 @@
"devDependencies": {
"tailwindcss": "^3.3.5"
},
- "proxy": "https://api.tiefen.fun"
+ "proxy": "https://api.wishpal.cn"
}
diff --git a/src/pages/Contact/index.jsx b/src/pages/Contact/index.jsx
index e092820..7f8d759 100644
--- a/src/pages/Contact/index.jsx
+++ b/src/pages/Contact/index.jsx
@@ -1,17 +1,27 @@
import React, { useState, useEffect, useRef } from "react";
-import { Divider, Modal, Input, Button } from "antd";
+import { Divider, Modal, Input, Button, Menu } from "antd";
+import {
+ Routes,
+ Route,
+ Navigate,
+ useNavigate,
+ useLocation,
+} from "react-router-dom";
import baseRequest from "../../utils/baseRequest";
-export default function Contact() {
+const ContactContent = (props) => {
+ const current = props.current;
//请求未读消息队列
const [unreadMessageList, setUnreadMessageList] = useState([]);
const getUnreadMessages = async () => {
if (isModalOpen) return;
+ if (current !== "unread") return;
try {
//获取全部未读信息
const base = baseRequest();
+ //查询所有未读信息的session
const response = await fetch(
- "/op/contact_customer_service/list_unread_group_by_mid",
+ "/op/contact_customer_service/list_unread_group_by_session_id",
{
method: "POST",
headers: {
@@ -28,7 +38,7 @@ export default function Contact() {
return;
}
//获取用户头像、昵称
- const userMids = data.data.list.map((item) => item.mid);
+ const userMids = data.data.list.map((item) => item.sub_mid);
if (userMids.length === 0) {
setUnreadMessageList([]);
return;
@@ -51,7 +61,7 @@ export default function Contact() {
//合并未读信息和用户资料数组
const combinedArray = data.data.list.map((item1) => {
const matchingItem = userData.data.list.find(
- (item2) => item2.mid === item1.mid
+ (item2) => item2.mid === item1.sub_mid
);
return { ...item1, ...matchingItem };
});
@@ -66,6 +76,7 @@ export default function Contact() {
//轮询更新未读消息队列
useEffect(() => {
+ if (current !== "unread") return;
getUnreadMessages();
// 设置轮询请求,每隔一定时间执行一次
const intervalId = setInterval(() => {
@@ -80,6 +91,7 @@ export default function Contact() {
const { TextArea } = Input;
+ //对话列表的单个组件
const MassageItem = ({ item }) => {
//设置消息为已读
const ids = item.contents?.map((temItem) => temItem.id);
@@ -109,7 +121,6 @@ export default function Contact() {
console.error(error);
}
};
-
return (
-
- {item.contents.length}条未读
-
+ {current === "unread" && (
+
+ {item.contents.length}条未读
+
+ )}
{item.name}
@@ -155,20 +168,20 @@ export default function Contact() {
//获取聊天记录,并设置为已读
const getHistory = async () => {
try {
- //获取全部未读信息
+ //获取最新100条信息
const base = baseRequest();
if (!modalInfo.mid) return;
const response = await fetch(
- "/op/contact_customer_service/list_by_mid",
+ "/op/contact_customer_service/list_by_session_id",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
- mid: modalInfo.mid,
+ session_id: modalInfo.session_id,
offset: 0,
- limit: 30,
+ limit: 100,
...base,
}),
}
@@ -252,8 +265,7 @@ export default function Contact() {
"Content-Type": "application/json",
},
body: JSON.stringify({
- sub_mid: modalInfo.mid,
- obj_mid: base.b_mid,
+ session_id: modalInfo.session_id,
predicate: 1,
message: message,
...base,
@@ -352,15 +364,134 @@ export default function Contact() {
);
};
+ //获取所有对话
+ const [allMessageList, setAllMessageList] = useState([]);
+ useEffect(() => {
+ if (current !== "all") return;
+ const getAllMessages = async () => {
+ try {
+ const base = baseRequest();
+ const response = await fetch(
+ `/op/contact_customer_service_session/list`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ offset: 0,
+ limit: 1000,
+ ...base,
+ }),
+ }
+ );
+ const data = await response.json();
+ if (data.ret === -1) {
+ alert(data.msg);
+ return;
+ }
+ //获取用户头像、昵称
+ const userMids = data.data.list.map((item) => item.sub_mid);
+ if (userMids.length === 0) {
+ setAllMessageList([]);
+ return;
+ }
+ const userResponse = await fetch("/op/account/list_others_by_mids", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ mids: userMids,
+ ...base,
+ }),
+ });
+ const userData = await userResponse.json();
+ if (userData.ret === -1) {
+ alert(userData.msg);
+ return;
+ }
+ //合并信息数组和用户资料数组
+ const combinedArray = data.data.list.map((item1) => {
+ const matchingItem = userData.data.list.find(
+ (item2) => item2.mid === item1.sub_mid
+ );
+ return { ...item1, ...matchingItem };
+ });
+ //处理数据格式
+ const processedArray = combinedArray.map((item) => {
+ return {
+ ...item,
+ session_id: item.id,
+ contents: [{ message: item.recent_message, ct: item.ut }],
+ };
+ });
+ setAllMessageList(processedArray);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+ getAllMessages();
+ }, []);
+
return (
-
- {unreadMessageList.length === 0 &&
暂无未读消息
}
- {unreadMessageList?.map((item, index) => (
-
- ))}
-
+ {current === "unread" && (
+
+ {unreadMessageList.length === 0 &&
暂无未读消息
}
+ {unreadMessageList?.map((item, index) => (
+
+ ))}
+
+ )}
+ {current === "all" && (
+
+ {allMessageList?.map((item, index) => (
+
+ ))}
+
+ )}
);
+};
+
+export default function Contact() {
+ const navigate = useNavigate();
+ //当前tab
+ const location = useLocation();
+ const pathname = location.pathname.split("/")[2] || "unread";
+ const [current, setCurrent] = useState(pathname);
+ //tab名称
+ const items = [
+ {
+ label: "未读消息",
+ key: "unread",
+ },
+ {
+ label: "全部消息",
+ key: "all",
+ },
+ ];
+ const onClick = (e) => {
+ setCurrent(e.key);
+ navigate(e.key);
+ window.location.reload();
+ };
+
+ return (
+
+
+
+ } />
+ } />
+ } />
+
+
+ );
}
diff --git a/src/pages/ImageMachineReview/index.jsx b/src/pages/ImageMachineReview/index.jsx
index 836be53..cc30d31 100644
--- a/src/pages/ImageMachineReview/index.jsx
+++ b/src/pages/ImageMachineReview/index.jsx
@@ -45,12 +45,20 @@ const ImageMachineReviewContent = (props) => {
render: (data) => (
{data?.map((item, index) => {
- if (item.status === 2 || item.status === 5)
+ if (item.status === 2 || item.status === 5) {
return (
图{index + 1}无违规
);
+ }
+ if (item.status === 10) {
+ return (
+
+ 图{index + 1}审核失败
+
+ );
+ }
return (
图{index + 1}违规情况:
@@ -125,9 +133,10 @@ const ImageMachineReviewContent = (props) => {
- {current === "rollbackbymachine" && (
+ {(current === "rollbackbymachine" ||
+ current === "machinereviewfail") && (
)}
@@ -183,6 +192,9 @@ const ImageMachineReviewContent = (props) => {
case "rollbackbymachine":
querryStatus = 4;
break;
+ case "machinereviewfail":
+ querryStatus = 10;
+ break;
case "passbymachine":
querryStatus = 2;
break;
@@ -287,6 +299,10 @@ export default function ImageMachineReview() {
label: "机审回退",
key: "rollbackbymachine",
},
+ {
+ label: "机审失败",
+ key: "machinereviewfail",
+ },
{
label: "机审通过",
key: "passbymachine",
@@ -319,6 +335,10 @@ export default function ImageMachineReview() {
path="/rollbackbymachine"
element={}
/>
+ }
+ />
}
diff --git a/test.jsx b/test.jsx
index 272e9ae..1ab0161 100644
--- a/test.jsx
+++ b/test.jsx
@@ -1,5 +1,5 @@
-import React, { useState, useRef, useEffect } from "react";
-import { Form, Input, Button, Space, Table, Menu, Image } from "antd";
+import React, { useState, useEffect, useRef } from "react";
+import { Divider, Modal, Input, Button, Menu } from "antd";
import {
Routes,
Route,
@@ -9,334 +9,365 @@ import {
} from "react-router-dom";
import baseRequest from "../../utils/baseRequest";
-const ImageReviewContent = (props) => {
- const { TextArea } = Input;
- const current = props.current;
- //表头
- const columns = [
- {
- title: "新内容",
- dataIndex: "newMedia",
- key: "newMedia",
- render: (data) => (
-
- {data?.map((item, index) => (
-
- ))}
-
- ),
- },
- {
- title: "旧内容",
- dataIndex: "oldMedia",
- key: "oldMedia",
- render: (data) => (
-
- {data?.map((item, index) => (
-
- ))}
-
- ),
- },
- {
- title: "审核结果",
- dataIndex: "info",
- key: "info",
- render: (data) => (
-
- {data?.map((item, index) => {
- if (item.status === 2 || item.status === 5)
- return (
-
- 图{index + 1}无违规
-
- );
- return (
-
-
图{index + 1}违规情况:
-
-
-
色情审核:
-
- - 建议:{item.porn_scene_suggestion}
- - 结果:{item.porn_scene_label}
- - 结果:{item.porn_scene_rate.toFixed(1)}
-
-
-
-
暴恐审核:
-
- - 建议:{item.terrorism_scene_suggestion}
- - 结果:{item.terrorism_scene_label}
- - 结果:{item.terrorism_scene_rate.toFixed(1)}
-
-
-
-
广告审核:
-
- - 建议:{item.ad_scene_suggestion}
- - 结果:{item.ad_scene_label}
- - 结果:{item.ad_scene_rate.toFixed(1)}
-
-
-
-
不良审核:
-
- - 建议:{item.live_scene_suggestion}
- - 结果:{item.live_scene_label}
- - 结果:{item.live_scene_rate.toFixed(1)}
-
-
-
-
logo审核:
-
- - 建议:{item.logo_scene_suggestion}
- - 结果:{item.logo_scene_label}
- - 结果:{item.logo_scene_rate.toFixed(1)}
-
-
-
-
- );
- })}
-
- ),
- },
- {
- title: "提交时间",
- dataIndex: "submitTime",
- key: "submitTime",
- },
- {
- title: "备注",
- dataIndex: "remarks",
- key: "remarks",
- render: (_, record) => (
-
-
-
- ),
- },
- {
- title: "操作",
- dataIndex: "opeartion",
- key: "opeartion",
- render: (_, record) => (
-
-
-
- {current === "rollbackbymachine" && (
-
- )}
-
-
-
- ),
- },
- ];
- //给表单绑定ref
- const formRef = useRef(null);
- //点击修改状态按钮
- const onClickSubmit = (record) => {
- formRef.current.record = record;
- formRef.current.btn = "submit";
- formRef.current.submit();
- };
- //提交表单
- const handleSubmit = async () => {
- //提交数据
+export default function Contact() {
+ //请求未读消息队列
+ const [unreadMessageList, setUnreadMessageList] = useState([]);
+ const getUnreadMessages = async () => {
+ if (isModalOpen) return;
try {
+ //获取全部未读信息
const base = baseRequest();
- const response = await fetch("/op/image_audit_task/pass_batch", {
+ const response = await fetch(
+ "/op/contact_customer_service/list_unread_group_by_mid",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ ...base,
+ }),
+ }
+ );
+ const data = await response.json();
+ if (data.ret === -1) {
+ alert(data.msg);
+ return;
+ }
+ //获取用户头像、昵称
+ const userMids = data.data.list.map((item) => item.mid);
+ if (userMids.length === 0) {
+ setUnreadMessageList([]);
+ return;
+ }
+ const userResponse = await fetch("/op/account/list_others_by_mids", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
- tasks: [formRef.current.record.others],
+ mids: userMids,
...base,
}),
});
- const approveData = await response.json();
- if (approveData.ret === -1) {
- alert(approveData.msg);
+ const userData = await userResponse.json();
+ if (userData.ret === -1) {
+ alert(userData.msg);
return;
}
+ //合并未读信息和用户资料数组
+ const combinedArray = data.data.list.map((item1) => {
+ const matchingItem = userData.data.list.find(
+ (item2) => item2.mid === item1.mid
+ );
+ return { ...item1, ...matchingItem };
+ });
+ setUnreadMessageList(combinedArray);
} catch (error) {
console.error(error);
}
- //取消数据展示
- setShowData(
- showData.filter((item) => item.id !== formRef.current.record.others.id)
+ };
+
+ //控制modal是否出现
+ const [isModalOpen, setIsModalOpen] = useState(false);
+
+ //轮询更新未读消息队列
+ useEffect(() => {
+ getUnreadMessages();
+ // 设置轮询请求,每隔一定时间执行一次
+ const intervalId = setInterval(() => {
+ getUnreadMessages();
+ }, 3000); // 间隔时间为3秒
+
+ // 在组件卸载时清除定时器
+ return () => {
+ clearInterval(intervalId);
+ };
+ }, [isModalOpen]);
+
+ const { TextArea } = Input;
+
+ const MassageItem = ({ item }) => {
+ //设置消息为已读
+ const ids = item.contents?.map((temItem) => temItem.id);
+ const updateMessageStatus = async () => {
+ try {
+ const base = baseRequest();
+ const response = await fetch(
+ `/op/contact_customer_service/update_by_ids`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ is_read: 1,
+ ids: ids,
+ ...base,
+ }),
+ }
+ );
+ const data = await response.json();
+ if (data.ret === -1) {
+ alert(data.msg);
+ return;
+ }
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ return (
+ {
+ setModalInfo(item);
+ setIsModalOpen(!isModalOpen);
+ updateMessageStatus();
+ }}
+ >
+
+
+
+
+
+
+ {item.contents.length}条未读
+
+ {item.name}
+
+
+ {item.contents[0].message}
+
+
+
+
+ {new Date(item.contents[0].ct * 1000).toLocaleString()}
+
+
+
+
);
};
- //获取数据
- const [data, setData] = useState([]);
- const [offset, setOffset] = useState(0);
- const [more, setMore] = useState(1);
- const getData = async () => {
- if (!more) return;
- let querryStatus;
- switch (current) {
- case "rollbackbymachine":
- querryStatus = 4;
- break;
- case "passbymachine":
- querryStatus = 2;
- break;
- case "passbyoperator":
- querryStatus = 5;
- break;
- default:
- break;
- }
- try {
- const base = baseRequest();
- const response = await fetch("/op/image_audit_task/list", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- status: querryStatus,
- offset: offset,
- limit: 20,
- ...base,
- }),
- });
- const temData = await response.json();
- console.log(
- JSON.stringify({
- status: querryStatus,
- offset: offset,
- limit: 20,
- ...base,
- })
- );
- console.log(temData);
- if (temData.ret === -1) {
- alert(temData.msg);
- return;
+
+ //保存modal中用户的mid和昵称和历史记录
+ const [modalInfo, setModalInfo] = useState({});
+ const MessageModal = () => {
+ //获取并保存用户聊天历史记录
+ const [history, setHistory] = useState([]);
+ //获取聊天记录,并设置为已读
+ const getHistory = async () => {
+ try {
+ //获取全部未读信息
+ const base = baseRequest();
+ if (!modalInfo.mid) return;
+ const response = await fetch(
+ "/op/contact_customer_service/list_by_mid",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ mid: modalInfo.mid,
+ offset: 0,
+ limit: 100,
+ ...base,
+ }),
+ }
+ );
+ const data = await response.json();
+ if (data.ret === -1) {
+ alert(data.msg);
+ return;
+ }
+ setHistory((prev) => {
+ const temData = [...data.data.list].reverse();
+ if (
+ prev.length === 0 ||
+ temData[temData.length - 1].id !== prev[prev.length - 1].id
+ ) {
+ return temData;
+ } else {
+ return prev;
+ }
+ });
+ } catch (error) {
+ console.error(error);
}
- //匹配表格格式
- const structedData = temData.data.list.map((item, index) => {
- return {
- key: index,
- id: item.id,
- newMedia: item?.audited_media?.images,
- oldMedia: item?.old_media?.images,
- info: item.image_audits,
- submitTime: new Date(item.ct * 1000).toLocaleString(),
- remarks: item.remarks,
- others: {
- id: item.id,
- audited_media: item.audited_media,
- associative_database: item.associative_database,
- associative_table_name: item.associative_table_name,
- associative_table_id: item.associative_table_id,
- associative_table_column: item.associative_table_column,
+ };
+
+ //轮询更新聊天记录
+ useEffect(() => {
+ getHistory();
+ // 设置轮询请求,每隔一定时间执行一次
+ const intervalId = setInterval(() => {
+ getHistory();
+ }, 3000); // 间隔时间为3秒
+
+ // 在组件卸载时清除定时器
+ return () => {
+ clearInterval(intervalId);
+ };
+ }, [modalInfo]);
+
+ //将最新发送的信息设置为已读
+ const updateNewMessageToRead = async () => {
+ try {
+ //设置消息为已读
+ const base = baseRequest();
+ const ids = history.map((item) => {
+ if (item.is_read === 1) return;
+ return item.id;
+ });
+ if (ids.length === 0) return;
+ const updateResponse = await fetch(
+ `/op/contact_customer_service/update_by_ids`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ is_read: 1,
+ ids: ids,
+ ...base,
+ }),
+ }
+ );
+ const updateData = await updateResponse.json();
+ if (updateData.ret === -1) {
+ alert(updateData.msg);
+ return;
+ }
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ const sendMessage = async (message) => {
+ //请求接口发送私信
+ try {
+ const base = baseRequest();
+ const response = await fetch(`/op/contact_customer_service/create`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
},
- };
- });
- setData([...data, ...structedData]);
- setOffset(temData.data.offset);
- setMore(temData.data.more);
- } catch (error) {
- console.error(error);
- }
- };
- useEffect(() => {
- getData();
- }, [current]);
+ body: JSON.stringify({
+ sub_mid: modalInfo.mid,
+ obj_mid: base.b_mid,
+ predicate: 1,
+ message: message,
+ ...base,
+ }),
+ });
+ const data = await response.json();
+ if (data.ret === -1) {
+ alert(data.msg);
+ return;
+ }
+ setMessageContent("");
+ getHistory();
+ } catch (error) {
+ console.error(error);
+ }
+ };
- //展示的数据
- const [showData, setShowData] = useState([]);
- useEffect(() => {
- setShowData(data);
- }, [data]);
- //表单提交失败
- const onFinishFailed = (errorInfo) => {
- console.log("Failed:", errorInfo);
- };
- return (
-
-
- {current === "rollbackbymachine" && `机审核违规${showData.length}条`}
- {current === "passbymachine" && `机审核通过${showData.length}条`}
- {current === "passbyoperator" && `运营通过${showData.length}条`}
-
-