diff --git a/app/my/createProfile/page.jsx b/app/my/createProfile/page.jsx index 9fd04df..866d87e 100644 --- a/app/my/createProfile/page.jsx +++ b/app/my/createProfile/page.jsx @@ -1,7 +1,15 @@ "use client"; import React, { useState, useRef, useMemo, Fragment } from "react"; -import { Switch, Space, Checkbox, Button, Toast, TextArea } from "antd-mobile"; +import { + Switch, + Space, + Checkbox, + Button, + Toast, + TextArea, + Radio, +} from "antd-mobile"; import { useRouter, useSearchParams } from "next/navigation"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; @@ -32,23 +40,46 @@ const ListItemWithCheckbox = ({ }} >
e.stopPropagation()}> - { + const newFormData = { ...formData }; + newFormData.superSingle.forEach((el) => { + el.enable = 0; + }); + newFormData.superSingle[superSingle.key].enable = value; + // newFormData.superSingle[superSingle.key].price = 0; + // newFormData.superSingle[superSingle.key].wechatFree = false; + setFormData(newFormData); + }} + > + {superSingle.text} + + {/* { const newFormData = { ...formData }; newFormData.superSingle[superSingle.key].enable = value; + newFormData.superSingle[superSingle.key].price = 0; + newFormData.superSingle[superSingle.key].wechatFree = false; setFormData(newFormData); }} > {superSingle.text} - + */}
¥ @@ -65,7 +96,7 @@ const ListItemWithCheckbox = ({
| - { @@ -75,7 +106,18 @@ const ListItemWithCheckbox = ({ }} >

赠送微信

-
+ + {/* { + const newFormData = { ...formData }; + newFormData.superSingle[superSingle.key].wechatFree = value; + setFormData(newFormData); + }} + > +

赠送微信

+
*/}
@@ -101,7 +143,8 @@ export default function CreateProfile() { const [spacePriceAble, setSpacePriceAble] = useState(false); const [tiefenPriceAble, setTiefenPriceAble] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); - const [superSingleCheckeds, setSuperSingleCheckeds] = useState([]); + // const [superSingleCheckeds, setSuperSingleCheckeds] = useState([]); + const [superSingleChecked, setSuperSingleChecked] = useState(null); const listItemWithCheckboxMemo = useMemo(() => { return superSingles.map((item) => ( @@ -110,11 +153,12 @@ export default function CreateProfile() { superSingle={item} formData={formData} setFormData={setFormData} - superSingleCheckeds={superSingleCheckeds} + superSingleCheckeds={superSingleChecked} + // superSingleCheckeds={superSingleCheckeds} /> )); - }, [formData, superSingleCheckeds]); + }, [formData, superSingleChecked]); const handleSubmit = async () => { const { spaceIntro, spacePrice, ironFanPrice, openSuper, superSingle } = @@ -155,16 +199,65 @@ export default function CreateProfile() { } let isPrice = false; if (openSuper) { - Object.values(superSingle).forEach((it) => { - if (it.enable) { - const superFanPrice = it.price; + // Object.values(superSingle).forEach((it) => { + // if (it.enable) { + // const superFanPrice = it.price; + // if (!superFanPrice) { + // Toast.show({ + // icon: "fail", + // content: "请填写超粉价格", + // position: "top", + // }); + // isPrice = true; + // return; + // } else { + // const _superFanPrice = parseInt(superFanPrice * 100, 10); + // if ( + // openSuper && + // (isNaN(_superFanPrice) || + // _superFanPrice < 100 || + // _superFanPrice > 388800) + // ) { + // isPrice = true; + // Toast.show({ + // icon: "fail", + // content: "请输入有效的超粉价格", + // position: "top", + // }); + // return; + // } + // if (openSuper && _superFanPrice <= _ironFanPrice) { + // isPrice = true; + // Toast.show({ + // icon: "fail", + // content: "请输入大于铁粉价格的超粉价格", + // position: "top", + // }); + // return; + // } + // } + // } + // }); + if (superSingleChecked == null) { + Toast.show({ + icon: "fail", + content: "请选择铁粉类型", + position: "top", + }); + } else { + const superChecked = superSingle.filter( + (_, index) => index == superSingleChecked + )[0]; + if (superChecked) { + const superFanPrice = superChecked.price; if (!superFanPrice) { - isPrice = true; Toast.show({ icon: "fail", content: "请填写超粉价格", position: "top", }); + isPrice = true; + return; } else { const _superFanPrice = parseInt(superFanPrice * 100, 10); if ( @@ -192,51 +285,52 @@ export default function CreateProfile() { } } } - }); - } - if (isSubmitting) return; - const superfan_price_list = superSingle.map((it, index) => ({ - period: index, - enable: it.enable ? 1 : 0, - price: parseInt(it.price * 100, 10), - is_superfanship_give_wechat: it.wechatFree ? 1 : 0, - })); - setIsSubmitting(true); + } + if (isPrice) return; + if (isSubmitting) return; + const superfan_price_list = superSingle.map((it, index) => ({ + period: index, + enable: it.enable ? 1 : 0, + price: parseInt(it.price * 100, 10), + is_superfanship_give_wechat: it.wechatFree ? 1 : 0, + })); + 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/create", - { - body, - }, - true - ); - if (_data.ret === -1) { + 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: "fail", - content: _data.msg, + icon: "success", + content: "开通空间成功!空间简介将在审核完成后生效。", position: "top", }); - return; + router.back(); + } catch (error) { + console.error(error); + } finally { + setIsSubmitting(false); } - Toast.show({ - icon: "success", - content: "修改成功,请重进空间刷新查看", - position: "top", - }); - router.back(); - } catch (error) { - console.error(error); - } finally { - setIsSubmitting(false); } }; return ( @@ -384,13 +478,24 @@ export default function CreateProfile() {

- { + setSuperSingleChecked(values); + // setSuperSingleCheckeds(values); + }} + > + + + {/* { setSuperSingleCheckeds(values); }} >
    {listItemWithCheckboxMemo}
-
+
*/}
)} diff --git a/app/my/editprofile/editHome/page.jsx b/app/my/editprofile/editHome/page.jsx index d42edec..e303c2f 100644 --- a/app/my/editprofile/editHome/page.jsx +++ b/app/my/editprofile/editHome/page.jsx @@ -88,7 +88,7 @@ export default function EditHome() { info: "", autoResponse: "", wechat: "", - wechatAddWay: 0, + wechatAddWay: 1, }); const [spacePriceAble, setSpacePriceAble] = useState(false); // const [wechatAddWay, setWechatAddWay] = useState("0"); @@ -137,8 +137,8 @@ export default function EditHome() { } }, [data]); const superSingles = [ - { key: 0, text: "主动添加对方" }, - { key: 1, text: "向对方展示微信" }, + { key: 1, text: "主动添加对方" }, + { key: 0, text: "向对方展示微信" }, ]; const [fieldNamesOptions, setFieldNamesOptions] = useState([]); const ListItemWithCheckbox = ({ superSingle }) => { @@ -224,7 +224,7 @@ export default function EditHome() { }); return; } - if (values.wechatAddWay === "1" && !values.wechat) { + if (values.wechatAddWay === "0" && !values.wechat) { Toast.show({ icon: "fail", content: "请填写微信号", @@ -595,7 +595,7 @@ export default function EditHome() { ))} - {formData.wechatAddWay == 1 && ( + {formData.wechatAddWay == 0 && (
-

编辑资源

+

编辑资料

{/* 内容 */}
diff --git a/app/my/streamerVerification/completeStreamerInformation/page.jsx b/app/my/streamerVerification/completeStreamerInformation/page.jsx index 967bb78..25bd814 100644 --- a/app/my/streamerVerification/completeStreamerInformation/page.jsx +++ b/app/my/streamerVerification/completeStreamerInformation/page.jsx @@ -103,7 +103,7 @@ export default function CompleteStreamerInformation() { info: "", autoResponse: "", wechat: "", - wechatAddWay: 0, + wechatAddWay: 1, fans: 0, imageAssets: [], displayImage: [], @@ -156,7 +156,7 @@ export default function CompleteStreamerInformation() { setFormData((old) => ({ ...old, fans, - wechatPrice: wechat_coin_price, + wechatPrice: wechat_coin_price / 10, gender: [`${gender}`], age: [`${age}`], height: [`${height}`], @@ -190,8 +190,8 @@ export default function CompleteStreamerInformation() { setFormData((old) => ({ ...old, imageAssets: oldPhotos })); }, [oldPhotos]); const superSingles = [ - { key: 0, text: "主动添加对方" }, - { key: 1, text: "向对方展示微信" }, + { key: 1, text: "主动添加对方" }, + { key: 0, text: "向对方展示微信" }, ]; const [fieldNamesOptions, setFieldNamesOptions] = useState([]); const ListItemWithCheckbox = ({ superSingle }) => { @@ -360,7 +360,7 @@ export default function CompleteStreamerInformation() { }); return; } - if (wechatAddWay === 1 && !wechat) { + if (wechatAddWay === 0 && !wechat) { Toast.show({ icon: "fail", content: "请填写微信号", @@ -883,7 +883,7 @@ export default function CompleteStreamerInformation() { ))} - {formData.wechatAddWay == 1 && ( + {formData.wechatAddWay == 0 && (
e.stopPropagation()}> - { + const newFormData = { ...formData }; + newFormData.superSingle.forEach((el) => { + el.enable = 0; + }); + newFormData.superSingle[superSingle.key].enable = value; + // newFormData.superSingle[superSingle.key].price = 0; + // newFormData.superSingle[superSingle.key].wechatFree = false; + setFormData(newFormData); + }} + > + {superSingle.text} + + {/* { @@ -43,13 +59,18 @@ const ListItemWithCheckbox = ({ }} > {superSingle.text} - + */}
¥ @@ -66,7 +87,7 @@ const ListItemWithCheckbox = ({
| - { @@ -76,7 +97,18 @@ const ListItemWithCheckbox = ({ }} >

赠送微信

-
+ + {/* { + const newFormData = { ...formData }; + newFormData.superSingle[superSingle.key].wechatFree = value; + setFormData(newFormData); + }} + > +

赠送微信

+
*/}
@@ -101,16 +133,23 @@ export default function spacePaymentSetting() { const [spacePriceAble, setSpacePriceAble] = useState(false); const [tiefenPriceAble, setTiefenPriceAble] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); - const [superSingleCheckeds, setSuperSingleCheckeds] = useState([]); + // const [superSingleCheckeds, setSuperSingleCheckeds] = useState([]); + const [superSingleChecked, setSuperSingleChecked] = useState(null); useEffect(() => { const account = get("account"); getStreamerInfo(Number(account.mid)).then((res) => { - setSuperSingleCheckeds( - res.superfan_price_list - .map((it, index) => ({ ...it, index })) - .filter((it) => it.enable) - .map((it) => superSingles[it.index].key) - ); + const haveChecked = res.superfan_price_list + .map((it, index) => ({ ...it, index })) + .filter((it) => it.enable); + if (haveChecked.length > 0) { + setSuperSingleChecked(haveChecked[0].period); + } + // setSuperSingleCheckeds( + // res.superfan_price_list + // .map((it, index) => ({ ...it, index })) + // .filter((it) => it.enable) + // .map((it) => superSingles[it.index].key) + // ); setFormData({ spacePrice: res.admission_price / 100, ironFanPrice: res.ironfanship_price / 100, @@ -131,11 +170,12 @@ export default function spacePaymentSetting() { superSingle={item} formData={formData} setFormData={setFormData} - superSingleCheckeds={superSingleCheckeds} + superSingleCheckeds={superSingleChecked} + // superSingleCheckeds={superSingleCheckeds} /> )); - }, [formData, superSingleCheckeds]); + }, [formData, superSingleChecked]); const handleSubmit = async () => { const { spacePrice, ironFanPrice, openSuper, superSingle } = formData; const openSuperEveryFalse = Object.values(superSingle).every( @@ -169,9 +209,57 @@ export default function spacePaymentSetting() { } let isPrice = false; if (openSuper) { - Object.values(superSingle).forEach((it) => { - if (it.enable) { - const superFanPrice = it.price; + // Object.values(superSingle).forEach((it) => { + // if (it.enable) { + // const superFanPrice = it.price; + // if (!superFanPrice) { + // Toast.show({ + // icon: "fail", + // content: "请填写超粉价格", + // position: "top", + // }); + // isPrice = true; + // return; + // } else { + // const _superFanPrice = parseInt(superFanPrice * 100, 10); + // if ( + // openSuper && + // (isNaN(_superFanPrice) || + // _superFanPrice < 100 || + // _superFanPrice > 388800) + // ) { + // isPrice = true; + // Toast.show({ + // icon: "fail", + // content: "请输入有效的超粉价格", + // position: "top", + // }); + // return; + // } + // if (openSuper && _superFanPrice <= _ironFanPrice) { + // isPrice = true; + // Toast.show({ + // icon: "fail", + // content: "请输入大于铁粉价格的超粉价格", + // position: "top", + // }); + // return; + // } + // } + // } + // }); + if (superSingleChecked == null) { + Toast.show({ + icon: "fail", + content: "请选择铁粉类型", + position: "top", + }); + } else { + const superChecked = superSingle.filter( + (_, index) => index == superSingleChecked + )[0]; + if (superChecked) { + const superFanPrice = superChecked.price; if (!superFanPrice) { Toast.show({ icon: "fail", @@ -207,7 +295,7 @@ export default function spacePaymentSetting() { } } } - }); + } } if (isPrice) return; // if ( @@ -233,7 +321,6 @@ export default function spacePaymentSetting() { price: parseInt(it.price * 100, 10), is_superfanship_give_wechat: it.wechatFree ? 1 : 0, })); - setIsSubmitting(true); try { const body = { @@ -416,14 +503,24 @@ export default function spacePaymentSetting() {

- { + setSuperSingleChecked(values); + // setSuperSingleCheckeds(values); + }} + > +
    {listItemWithCheckboxMemo}
+ + {/* { setSuperSingleCheckeds(values); }} >
    {listItemWithCheckboxMemo}
-
+
*/}
)}