新增广场动态编辑功能
This commit is contained in:
parent
c6ac80cd12
commit
7a049a54b2
|
@ -203,7 +203,7 @@ export default function Wallet() {
|
||||||
style={{ maxWidth: "20px" }}
|
style={{ maxWidth: "20px" }}
|
||||||
/>
|
/>
|
||||||
<span className="text-base text-white font-medium ml-2">
|
<span className="text-base text-white font-medium ml-2">
|
||||||
近一周收支
|
近一周收益
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import {
|
import {
|
||||||
faAngleLeft,
|
faAngleLeft,
|
||||||
faAngleRight,
|
faAngleRight,
|
||||||
faClose,
|
|
||||||
// faSave,
|
// faSave,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import AddWeChat from "@/components/AddWeChat";
|
import AddWeChat from "@/components/AddWeChat";
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
Space,
|
Space,
|
||||||
SpinLoading,
|
SpinLoading,
|
||||||
} from "antd-mobile";
|
} from "antd-mobile";
|
||||||
import Empty from "@/components/Empty";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import {
|
import {
|
||||||
faAngleLeft,
|
faAngleLeft,
|
||||||
|
@ -72,7 +71,13 @@ export default function AgencySetting() {
|
||||||
setModalVisible(!modalVisible);
|
setModalVisible(!modalVisible);
|
||||||
const zid = Number(searchParams.get("zid"));
|
const zid = Number(searchParams.get("zid"));
|
||||||
handler.current = Dialog.show({
|
handler.current = Dialog.show({
|
||||||
content: <ModalMask setModalVisible={setModalVisible} zid={zid} />,
|
content: (
|
||||||
|
<ModalMask
|
||||||
|
setModalVisible={setModalVisible}
|
||||||
|
zid={zid}
|
||||||
|
router={router}
|
||||||
|
/>
|
||||||
|
),
|
||||||
bodyStyle: {
|
bodyStyle: {
|
||||||
backgroundColor: "#17161A",
|
backgroundColor: "#17161A",
|
||||||
maxHeight: "none",
|
maxHeight: "none",
|
||||||
|
@ -113,6 +118,7 @@ export default function AgencySetting() {
|
||||||
<div className="p-4 pt-20">
|
<div className="p-4 pt-20">
|
||||||
<div className="flex justify-center items-center">
|
<div className="flex justify-center items-center">
|
||||||
{data ? (
|
{data ? (
|
||||||
|
<div className="flex-1 flex flex-col justify-center items-center">
|
||||||
<Image
|
<Image
|
||||||
src={data?.third_partner_account.avatar.images[0].urls[0]}
|
src={data?.third_partner_account.avatar.images[0].urls[0]}
|
||||||
width={74}
|
width={74}
|
||||||
|
@ -120,6 +126,12 @@ export default function AgencySetting() {
|
||||||
className="h-full mr-1"
|
className="h-full mr-1"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
/>
|
/>
|
||||||
|
<div className="flex flex-col border-2 border-[#2c2b2f] rounded-2xl p-4 w-full mt-6 text-base font-medium">
|
||||||
|
<p>代运营昵称:{data.third_partner_account.name}</p>
|
||||||
|
<p>ID:{data.third_partner_account.user_id}</p>
|
||||||
|
<p>分成比例:{(data.sharing_ratio * 100).toFixed()}%</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
onClick={handleAddAgency}
|
onClick={handleAddAgency}
|
||||||
|
@ -133,7 +145,6 @@ export default function AgencySetting() {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-8 text-[#FFFFFF80] text-sm">
|
<div className="mt-8 text-[#FFFFFF80] text-sm">
|
||||||
<p className="text-base font-medium">注意事项:</p>
|
<p className="text-base font-medium">注意事项:</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -151,7 +162,7 @@ export default function AgencySetting() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalMask = ({ setModalVisible, zid }) => {
|
const ModalMask = ({ setModalVisible, zid, router }) => {
|
||||||
const [isloading, setIsloading] = useState([]);
|
const [isloading, setIsloading] = useState([]);
|
||||||
const [isSelected, setIsSelected] = useState(false);
|
const [isSelected, setIsSelected] = useState(false);
|
||||||
const [seconds, setSeconds] = useState(60);
|
const [seconds, setSeconds] = useState(60);
|
||||||
|
@ -162,6 +173,7 @@ const ModalMask = ({ setModalVisible, zid }) => {
|
||||||
const [userId, setUserId] = useState("");
|
const [userId, setUserId] = useState("");
|
||||||
const [isCounting, setIsCounting] = useState(false);
|
const [isCounting, setIsCounting] = useState(false);
|
||||||
const [rate, setRate] = useState([null]);
|
const [rate, setRate] = useState([null]);
|
||||||
|
// const router = useRouter();
|
||||||
//生成比例选项
|
//生成比例选项
|
||||||
const generateItems = useCallback((min, max) => {
|
const generateItems = useCallback((min, max) => {
|
||||||
const items = [];
|
const items = [];
|
||||||
|
@ -312,6 +324,7 @@ const ModalMask = ({ setModalVisible, zid }) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
|
router.back();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
List,
|
List,
|
||||||
Dialog,
|
Dialog,
|
||||||
} from "antd-mobile";
|
} from "antd-mobile";
|
||||||
import Empty from "@/components/Empty";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import {
|
import {
|
||||||
faAngleLeft,
|
faAngleLeft,
|
||||||
|
@ -28,7 +27,6 @@ import requireAPI from "@/utils/requireAPI";
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
import OwnInput from "@/components/OwnInput";
|
import OwnInput from "@/components/OwnInput";
|
||||||
import { get } from "@/utils/storeInfo";
|
import { get } from "@/utils/storeInfo";
|
||||||
import { JSEncrypt } from "jsencrypt";
|
|
||||||
export default function CollaboratorSetting() {
|
export default function CollaboratorSetting() {
|
||||||
const [data, setData] = useState(null);
|
const [data, setData] = useState(null);
|
||||||
const [selfMid, setSelfMid] = useState();
|
const [selfMid, setSelfMid] = useState();
|
||||||
|
@ -51,9 +49,9 @@ export default function CollaboratorSetting() {
|
||||||
const totalRate = data?.list?.reduce((acc, cur) => {
|
const totalRate = data?.list?.reduce((acc, cur) => {
|
||||||
return acc + cur.sharing_ratio || 0;
|
return acc + cur.sharing_ratio || 0;
|
||||||
}, 0);
|
}, 0);
|
||||||
return !totalRate
|
return (data?.zone_third_partner?.sharing_ratio - (totalRate || 0)).toFixed(
|
||||||
? 0
|
2
|
||||||
: (data?.zone_third_partner?.sharing_ratio - totalRate).toFixed(2);
|
);
|
||||||
}, [data]);
|
}, [data]);
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const zid = Number(searchParams.get("zid"));
|
const zid = Number(searchParams.get("zid"));
|
||||||
|
@ -92,6 +90,9 @@ export default function CollaboratorSetting() {
|
||||||
setModalVisible={setModalVisible}
|
setModalVisible={setModalVisible}
|
||||||
zid={zid}
|
zid={zid}
|
||||||
handleRefresh={getData}
|
handleRefresh={getData}
|
||||||
|
maxRate={
|
||||||
|
(data?.zone_third_partner?.sharing_ratio * 100).toFixed() || 0
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
bodyStyle: {
|
bodyStyle: {
|
||||||
|
@ -148,11 +149,7 @@ export default function CollaboratorSetting() {
|
||||||
style={{ "--border-radius": "100px", "--size": "42px" }}
|
style={{ "--border-radius": "100px", "--size": "42px" }}
|
||||||
/>
|
/>
|
||||||
<div className="ml-2 justify-around flex-1">
|
<div className="ml-2 justify-around flex-1">
|
||||||
<p
|
<p className="text-base font-medium whitespace-nowrap">
|
||||||
className="text-base font-medium"
|
|
||||||
numberOfLines={1}
|
|
||||||
ellipsizeMode="tail"
|
|
||||||
>
|
|
||||||
{item?.collaborator_account?.name}
|
{item?.collaborator_account?.name}
|
||||||
</p>
|
</p>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
|
@ -295,7 +292,7 @@ export default function CollaboratorSetting() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalMask = ({ setModalVisible, zid, handleRefresh }) => {
|
const ModalMask = ({ setModalVisible, zid, handleRefresh, maxRate }) => {
|
||||||
const [isloading, setIsloading] = useState([]);
|
const [isloading, setIsloading] = useState([]);
|
||||||
const [isSelected, setIsSelected] = useState(false);
|
const [isSelected, setIsSelected] = useState(false);
|
||||||
const [seconds, setSeconds] = useState(60);
|
const [seconds, setSeconds] = useState(60);
|
||||||
|
@ -313,7 +310,7 @@ const ModalMask = ({ setModalVisible, zid, handleRefresh }) => {
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}, []);
|
}, []);
|
||||||
const rates = useMemo(() => generateItems(1, 50), []);
|
const rates = useMemo(() => generateItems(1, maxRate), [maxRate]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getMobilePhone() {
|
async function getMobilePhone() {
|
||||||
setMobilePhone(await get("mobile_phone"));
|
setMobilePhone(await get("mobile_phone"));
|
||||||
|
|
|
@ -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 (
|
||||||
|
<div className="flex-1">
|
||||||
|
{/* 头部标题 */}
|
||||||
|
<div className="p-4 fixed top-0 z-10 w-full flex justify-between items-center bg-black">
|
||||||
|
<div className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full">
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faAngleLeft}
|
||||||
|
style={{ maxWidth: "12px" }}
|
||||||
|
size="xl"
|
||||||
|
onClick={() => {
|
||||||
|
router.back();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p className="text-base text-center leading-9">广场动态</p>
|
||||||
|
{isSubmitting ? (
|
||||||
|
<DotLoading />
|
||||||
|
) : (
|
||||||
|
<span className="text-primary text-lg" onClick={handleSubmit}>
|
||||||
|
发布
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{/* 内容 */}
|
||||||
|
<div className="pt-16 p-4">
|
||||||
|
<div className="mt-2">
|
||||||
|
<p className="text-base font-medium text-white">动态内容</p>
|
||||||
|
<div className="h-32">
|
||||||
|
<TextArea
|
||||||
|
placeholder="请遵守平台准则,严禁发布违规内容"
|
||||||
|
value={formData.content}
|
||||||
|
autoSize={{ minRows: 6, maxRows: 15 }}
|
||||||
|
onChange={(value) =>
|
||||||
|
setFormData((old) => ({ ...old, content: value }))
|
||||||
|
}
|
||||||
|
style={{ "--font-size": "16px" }}
|
||||||
|
className="h-full bg-[#FFFFFF1A] rounded-2xl mt-2 mb-4 p-2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4">
|
||||||
|
<p className="text-base font-medium mt-4 mb-1">
|
||||||
|
图片
|
||||||
|
<span className="text-[#FFFFFF80] text-sm">
|
||||||
|
(添加图片后不可添加视频)
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<UploadImgs
|
||||||
|
type={1}
|
||||||
|
id="uploadAvatarBtn1"
|
||||||
|
existImages={oldPhotos}
|
||||||
|
assets={formData.imageAssets}
|
||||||
|
getImgs={(imgs) => {
|
||||||
|
setFormData((old) => ({
|
||||||
|
...old,
|
||||||
|
imageAssets: imgs,
|
||||||
|
videoAssets: [],
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4">
|
||||||
|
<p className="text-base font-medium mt-4 mb-1">
|
||||||
|
视频
|
||||||
|
<span className="text-[#FFFFFF80] text-sm">
|
||||||
|
(添加视频后不可添加图片)
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<UploadImgs
|
||||||
|
type={2}
|
||||||
|
accept="video/*"
|
||||||
|
id="uploadAvatarBtn2"
|
||||||
|
assets={formData.videoAssets}
|
||||||
|
getImgs={(imgs) => {
|
||||||
|
setFormData((old) => ({
|
||||||
|
...old,
|
||||||
|
videoAssets: imgs,
|
||||||
|
imageAssets: [],
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -189,23 +189,24 @@ export default function PostItem({
|
||||||
)}
|
)}
|
||||||
{(type == "space"
|
{(type == "space"
|
||||||
? data?.status === 3
|
? data?.status === 3
|
||||||
: data?.status === 5 || data?.status === 6) &&
|
: data?.status === 5 || data?.status === 6) && (
|
||||||
(type == "space" ? (
|
|
||||||
<p
|
<p
|
||||||
className="py-1 px-2 inline-block bg-[#F53030] rounded"
|
className="py-1 px-2 inline-block bg-[#F53030] rounded"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(`/space/editSpacePost/${data.id}`);
|
router.push(
|
||||||
|
`${
|
||||||
|
type == "space"
|
||||||
|
? "/space/editSpacePost"
|
||||||
|
: "/streamerPosts/editPost"
|
||||||
|
}/${data.id}`
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
审核未通过,请<span className="underline">重新编辑</span>。
|
审核未通过,请<span className="underline">重新编辑</span>。
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
) : (
|
)}
|
||||||
<p className="py-1 px-2 inline-block bg-[#F53030] rounded">
|
|
||||||
<span className="text-sm">审核未通过,请删除后重新提交。</span>
|
|
||||||
</p>
|
|
||||||
))}
|
|
||||||
<div>
|
<div>
|
||||||
{!data?.is_zone_moment_unlocked ? (
|
{!data?.is_zone_moment_unlocked ? (
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -46,7 +46,7 @@ export default function customFetch(
|
||||||
|
|
||||||
// 合并选项
|
// 合并选项
|
||||||
const mergedOptions = { ...defaultOptions, body };
|
const mergedOptions = { ...defaultOptions, body };
|
||||||
// console.log("body", body);
|
console.log("body", body);
|
||||||
// 返回 Promise 对象
|
// 返回 Promise 对象
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fetch(url, mergedOptions)
|
fetch(url, mergedOptions)
|
||||||
|
|
Loading…
Reference in New Issue