From 7a049a54b2afc9e7da0d05ceae39bf3ece286e68 Mon Sep 17 00:00:00 2001 From: al Date: Tue, 19 Nov 2024 16:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B9=BF=E5=9C=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/my/wallet/page.js | 2 +- .../person_space_introduce/[mid]/page.js | 1 - app/space/setting/agencySetting/page.jsx | 35 ++- .../setting/collaboratorSetting/page.jsx | 21 +- app/streamerPosts/editPost/[zid]/page.jsx | 226 ++++++++++++++++++ components/PostItem/index.js | 35 +-- utils/requireAPI.js | 2 +- 7 files changed, 279 insertions(+), 43 deletions(-) create mode 100644 app/streamerPosts/editPost/[zid]/page.jsx diff --git a/app/my/wallet/page.js b/app/my/wallet/page.js index 3f79089..05f0392 100644 --- a/app/my/wallet/page.js +++ b/app/my/wallet/page.js @@ -203,7 +203,7 @@ export default function Wallet() { style={{ maxWidth: "20px" }} /> - 近一周收支 + 近一周收益 , + content: ( + + ), bodyStyle: { backgroundColor: "#17161A", maxHeight: "none", @@ -113,13 +118,20 @@ export default function AgencySetting() {
{data ? ( - +
+ +
+

代运营昵称:{data.third_partner_account.name}

+

ID:{data.third_partner_account.user_id}

+

分成比例:{(data.sharing_ratio * 100).toFixed()}%

+
+
) : (
)}
-

注意事项:

@@ -151,7 +162,7 @@ export default function AgencySetting() { ); } -const ModalMask = ({ setModalVisible, zid }) => { +const ModalMask = ({ setModalVisible, zid, router }) => { const [isloading, setIsloading] = useState([]); const [isSelected, setIsSelected] = useState(false); const [seconds, setSeconds] = useState(60); @@ -162,6 +173,7 @@ const ModalMask = ({ setModalVisible, zid }) => { const [userId, setUserId] = useState(""); const [isCounting, setIsCounting] = useState(false); const [rate, setRate] = useState([null]); + // const router = useRouter(); //生成比例选项 const generateItems = useCallback((min, max) => { const items = []; @@ -312,6 +324,7 @@ const ModalMask = ({ setModalVisible, zid }) => { return; } setModalVisible(false); + router.back(); } catch (error) { console.error(error); } diff --git a/app/space/setting/collaboratorSetting/page.jsx b/app/space/setting/collaboratorSetting/page.jsx index a6ac83b..59662b2 100644 --- a/app/space/setting/collaboratorSetting/page.jsx +++ b/app/space/setting/collaboratorSetting/page.jsx @@ -16,7 +16,6 @@ import { List, Dialog, } from "antd-mobile"; -import Empty from "@/components/Empty"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft, @@ -28,7 +27,6 @@ import requireAPI from "@/utils/requireAPI"; import { useRouter, useSearchParams } from "next/navigation"; import OwnInput from "@/components/OwnInput"; import { get } from "@/utils/storeInfo"; -import { JSEncrypt } from "jsencrypt"; export default function CollaboratorSetting() { const [data, setData] = useState(null); const [selfMid, setSelfMid] = useState(); @@ -51,9 +49,9 @@ export default function CollaboratorSetting() { const totalRate = data?.list?.reduce((acc, cur) => { return acc + cur.sharing_ratio || 0; }, 0); - return !totalRate - ? 0 - : (data?.zone_third_partner?.sharing_ratio - totalRate).toFixed(2); + return (data?.zone_third_partner?.sharing_ratio - (totalRate || 0)).toFixed( + 2 + ); }, [data]); const getData = async () => { const zid = Number(searchParams.get("zid")); @@ -92,6 +90,9 @@ export default function CollaboratorSetting() { setModalVisible={setModalVisible} zid={zid} handleRefresh={getData} + maxRate={ + (data?.zone_third_partner?.sharing_ratio * 100).toFixed() || 0 + } /> ), bodyStyle: { @@ -148,11 +149,7 @@ export default function CollaboratorSetting() { style={{ "--border-radius": "100px", "--size": "42px" }} />

-

+

{item?.collaborator_account?.name}

@@ -295,7 +292,7 @@ export default function CollaboratorSetting() { ); } -const ModalMask = ({ setModalVisible, zid, handleRefresh }) => { +const ModalMask = ({ setModalVisible, zid, handleRefresh, maxRate }) => { const [isloading, setIsloading] = useState([]); const [isSelected, setIsSelected] = useState(false); const [seconds, setSeconds] = useState(60); @@ -313,7 +310,7 @@ const ModalMask = ({ setModalVisible, zid, handleRefresh }) => { } return items; }, []); - const rates = useMemo(() => generateItems(1, 50), []); + const rates = useMemo(() => generateItems(1, maxRate), [maxRate]); useEffect(() => { async function getMobilePhone() { setMobilePhone(await get("mobile_phone")); diff --git a/app/streamerPosts/editPost/[zid]/page.jsx b/app/streamerPosts/editPost/[zid]/page.jsx new file mode 100644 index 0000000..422b3aa --- /dev/null +++ b/app/streamerPosts/editPost/[zid]/page.jsx @@ -0,0 +1,226 @@ +"use client"; +import React, { useState, useEffect } from "react"; +import { DotLoading, Popup, Toast, TextArea, Switch } from "antd-mobile"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; +import requireAPI from "@/utils/requireAPI"; +import { useRouter, useParams } from "next/navigation"; +import { multiUploadImage } from "@/utils/upload"; +import UploadImgs from "@/components/UploadImgs"; +export default function EditPost() { + const params = useParams(); + const [isSubmitting, setIsSubmitting] = useState(false); + const [oldPhotos, setOldPhotos] = useState([]); + const [data, setData] = useState(null); + //价格 + const [formData, setFormData] = useState({ + content: "", + imageAssets: [], + videoAssets: [], + }); + const router = useRouter(); + useEffect(() => { + getData(); + }, []); + const getData = async () => { + const ids = [parseInt(params.zid, 10)]; + try { + const body = { + ids, + }; + const _data = await requireAPI( + "POST", + "/api/moment/list_by_ids_from_creater", + { + body, + }, + true + ); + if (_data.ret === -1) { + Toast.show({ + icon: "fail", + content: _data.msg, + position: "top", + }); + return; + } + setData(_data.data.list[0]); + const { text, media_component } = _data.data.list[0]; + setFormData({ + content: text, + imageAssets: media_component.images.map((it) => ({ + url: it.urls[0], + id: it.id, + })), + videoAssets: media_component.videos.map((it) => ({ + url: it.urls[0], + id: it.id, + })), + }); + } catch (error) { + console.error(error); + } finally { + setIsSubmitting(false); + } + }; + //发布内容 + const handleSubmit = async () => { + if (formData.content == "") { + Toast.show({ + icon: "fail", + content: "动态内容不能为空", + position: "top", + }); + return; + } + if ( + formData.imageAssets.length === 0 && + formData.videoAssets.length === 0 + ) { + Toast.show({ + icon: "fail", + content: "请上传图片或视频", + position: "top", + }); + return; + } + //提交数据 + if (isSubmitting) return; + setIsSubmitting(true); + const { content, imageAssets, videoAssets } = formData; + const newImageMedia = imageAssets.filter((it) => it.id == undefined); + const type = formData.imageAssets.length > 0 ? 1 : 2; + const media = await multiUploadImage( + type == 1 ? newImageMedia : videoAssets, + type + ); + // const media = await multiUploadImage(imageAssets); + if (type == 1) { + media.image_ids = [ + ...imageAssets.filter((it) => it.id != undefined).map((it) => it.id), + ...media.image_ids, + ]; + } + try { + const body = { + id: parseInt(params.zid, 10), + text: content, + media_component: media, + status: 2, + }; + const data = await requireAPI( + "POST", + "/api/moment/update", + { + body, + }, + true, + 100000 + ); + if (data.ret === -1) { + Toast.show({ + icon: "fail", + content: data.msg, + position: "top", + }); + return; + } + //提交成功后显示Toast并返回上一页 + Toast.show({ + icon: "success", + content: "更新成功", + position: "top", + }); + router.back(); + } catch (error) { + console.error(error); + } finally { + setIsSubmitting(false); + } + }; + return ( +
+ {/* 头部标题 */} +
+
+ { + router.back(); + }} + /> +
+

广场动态

+ {isSubmitting ? ( + + ) : ( + + 发布 + + )} +
+ {/* 内容 */} +
+
+

动态内容

+
+