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) => ( - -