diff --git a/app/my/createProfile/page.jsx b/app/my/createProfile/page.jsx index b5abc6c..f6a3f48 100644 --- a/app/my/createProfile/page.jsx +++ b/app/my/createProfile/page.jsx @@ -86,9 +86,9 @@ export default function CreateProfile() { const router = useRouter(); const searchParams = useSearchParams(); const [formData, setFormData] = useState({ - spacePrice: 0, - ironFanPrice: 0, - openSuper: true, + spacePrice: "", + ironFanPrice: "", + openSuper: false, superSingle: [ { enable: false, price: 0, wechatFree: false }, { enable: false, price: 0, wechatFree: false }, @@ -119,8 +119,15 @@ export default function CreateProfile() { const handleSubmit = async () => { const { spaceIntro, spacePrice, ironFanPrice, openSuper, superSingle } = formData; - - if (!spaceIntro || !spacePrice || !ironFanPrice) { + const openSuperEveryFalse = Object.values(superSingle).every( + (it) => !it.enable + ); + if ( + !spaceIntro || + !spacePrice || + !ironFanPrice || + (openSuper && openSuperEveryFalse) + ) { Toast.show({ icon: "fail", content: "请完善内容后提交", @@ -196,41 +203,41 @@ export default function CreateProfile() { })); setIsSubmitting(true); - try { - const body = { - profile: spaceIntro, - admission_price: parseInt(spacePrice * 100, 10), - ironfanship_price: parseInt(ironFanPrice * 100, 10), - is_superfanship_enabled: openSuper ? 1 : 0, - superfan_price_list, - }; - const _data = await requireAPI( - "POST", - "/api/zone/update", - { - body, - }, - true - ); - if (_data.ret === -1) { - Toast.show({ - icon: "error", - content: _data.msg, - position: "top", - }); - return; - } - Toast.show({ - icon: "success", - content: "修改成功,请重进空间刷新查看", - position: "top", - }); - router.back(); - } catch (error) { - console.error(error); - } finally { - setIsSubmitting(false); - } + // try { + // const body = { + // profile: spaceIntro, + // admission_price: parseInt(spacePrice * 100, 10), + // ironfanship_price: parseInt(ironFanPrice * 100, 10), + // is_superfanship_enabled: openSuper ? 1 : 0, + // superfan_price_list, + // }; + // const _data = await requireAPI( + // "POST", + // "/api/zone/create", + // { + // body, + // }, + // true + // ); + // if (_data.ret === -1) { + // Toast.show({ + // icon: "fail", + // content: _data.msg, + // position: "top", + // }); + // return; + // } + // Toast.show({ + // icon: "success", + // content: "修改成功,请重进空间刷新查看", + // position: "top", + // }); + // router.back(); + // } catch (error) { + // console.error(error); + // } finally { + // setIsSubmitting(false); + // } }; return (
@@ -287,10 +294,13 @@ export default function CreateProfile() { id="spacePrice" type="number" fontSize="22" + placeholder="1~3888,仅支持整数" value={formData.spacePrice} onChange={(value) => setFormData((old) => ({ ...old, spacePrice: value })) } + inputClassName="placeholder:text-[14px]" + className={!formData.spacePrice ? "pb-1.5" : ""} />