diff --git a/app/messageDetail/page.js b/app/messageDetail/page.js index 8c88c93..ee75572 100644 --- a/app/messageDetail/page.js +++ b/app/messageDetail/page.js @@ -85,7 +85,8 @@ export default function MessageDetail({}) { } }, [oldMessages.list, oldMessages.isGetHistory]); useEffect(() => { - if (sessionId && userInfo.mid) { + console.log("sessionId", sessionId, userInfo?.mid); + if (typeof sessionId === "number" && userInfo.mid) { loadEarlierHistory().then((res) => { setMessages((old) => { toScrollBottom.current = 1; @@ -155,7 +156,9 @@ export default function MessageDetail({}) { }; //请求历史记录 const loadEarlierHistory = async () => { + console.log("-------", more); if (!more) return; + try { setLoading(true); const data = await requireAPI( @@ -244,7 +247,7 @@ export default function MessageDetail({}) { return; } // updateLatestHistory(); - // console.log("oldArr", oldArr); + console.log("oldArr", oldArr); updateMessages(lastId, 0, oldArr).then((res) => { setNewMessage(""); toScrollBottom.current = 1; @@ -267,7 +270,8 @@ export default function MessageDetail({}) { // throw new Error("刷新失败"); // } async function loadMore() { - if (sessionId && userInfo.mid && offset && more) { + console.log("loadMore", sessionId, userInfo.mid, offset, more); + if (typeof sessionId === "number" && userInfo.mid && offset && more) { const append = await loadEarlierHistory(); if (append) { // setMessages((val) => [...val, ...append]); @@ -591,7 +595,9 @@ export default function MessageDetail({}) { } onSend( newMessage, - oldMessages.list[0]?.id || -1, + typeof oldMessages.list[0]?.id == "number" + ? oldMessages.list[0]?.id + : -1, oldMessages.list ); }} diff --git a/app/my/createProfile/page.jsx b/app/my/createProfile/page.jsx index c4beaab..713d184 100644 --- a/app/my/createProfile/page.jsx +++ b/app/my/createProfile/page.jsx @@ -8,7 +8,7 @@ import { Button, Toast, TextArea, - Radio, + Form, } from "antd-mobile"; import { useRouter, useSearchParams } from "next/navigation"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -34,9 +34,10 @@ const superSingles = [ // ]; const ListItemWithCheckbox = ({ superSingle, - formData, - setFormData, + superSinglesContr, + setSuperSinglesContr, superSingleCheckeds, + index, }) => { return (
  • {}}> @@ -57,38 +58,37 @@ const ListItemWithCheckbox = ({ {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); + const newSuperSinglesContr = [...superSinglesContr]; + newSuperSinglesContr[index].enable = value; + // newSuperSinglesContr[index].price = 0; + // newSuperSinglesContr[index].wechatFree = false; + setSuperSinglesContr(newSuperSinglesContr); }} > {superSingle.text}
    ¥ { - const newFormData = { ...formData }; - newFormData.superSingle[superSingle.key].price = value; - setFormData(newFormData); + const newSuperSinglesContr = [...superSinglesContr]; + newSuperSinglesContr[index].price = value; + setSuperSinglesContr(newSuperSinglesContr); }} />
    @@ -96,26 +96,15 @@ const ListItemWithCheckbox = ({ | { - const newFormData = { ...formData }; - newFormData.superSingle[superSingle.key].wechatFree = value; - setFormData(newFormData); + const newSuperSinglesContr = [...superSinglesContr]; + newSuperSinglesContr[index].wechatFree = value; + setSuperSinglesContr(newSuperSinglesContr); }} >

    赠送微信

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

    赠送微信

    -
    */}
    @@ -124,52 +113,40 @@ const ListItemWithCheckbox = ({ }; export default function CreateProfile() { const router = useRouter(); - const searchParams = useSearchParams(); - const [formData, setFormData] = useState({ - spacePrice: "", - ironFanPrice: "", - openSuper: true, - superSingle: [ - { enable: true, price: 0, wechatFree: true }, - { enable: false, price: 0, wechatFree: true }, - { enable: false, price: 0, wechatFree: true }, - { enable: false, price: 0, wechatFree: true }, - { enable: false, price: 0, wechatFree: true }, - ], - spaceIntro: "", - }); - const [spacePriceAble, setSpacePriceAble] = useState(false); - const [tiefenPriceAble, setTiefenPriceAble] = useState(false); + const [form] = Form.useForm(); + const [openSuper, setOpenSuper] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const [superSingleCheckeds, setSuperSingleCheckeds] = useState([]); - const [superSingleChecked, setSuperSingleChecked] = useState(0); - + const [superSinglesContr, setSuperSinglesContr] = useState([ + { enable: false, price: 0, wechatFree: false, key: 0 }, + { enable: false, price: 0, wechatFree: false, key: 4 }, + { enable: false, price: 0, wechatFree: false, key: 3 }, + { enable: false, price: 0, wechatFree: false, key: 2 }, + { enable: false, price: 0, wechatFree: false, key: 1 }, + ]); + // const [superSingleChecked, setSuperSingleChecked] = useState(0); const listItemWithCheckboxMemo = useMemo(() => { - return superSingles.map((item) => ( + return superSingles.map((item, index) => ( )); - }, [formData, superSingleChecked]); + }, [superSingleCheckeds, superSinglesContr]); - const handleSubmit = async () => { - const { spaceIntro, spacePrice, ironFanPrice, openSuper, superSingle } = - formData; + const handleSubmit = async (newFormData) => { + const { spaceIntro, spacePrice, ironFanPrice } = newFormData; + const superSingle = [...superSinglesContr]; const openSuperEveryFalse = Object.values(superSingle).every( (it) => !it.enable ); - if ( - !spaceIntro || - !spacePrice || - !ironFanPrice || - (openSuper && openSuperEveryFalse) - ) { + if (openSuper && openSuperEveryFalse) { Toast.show({ icon: "fail", content: "请完善内容后提交", @@ -178,23 +155,7 @@ export default function CreateProfile() { return; } const _spacePrice = parseInt(spacePrice * 100, 10); - if (isNaN(_spacePrice) || _spacePrice < 0 || _spacePrice > 388800) { - Toast.show({ - icon: "fail", - content: "请输入有效的解锁空间价格", - position: "top", - }); - return; - } const _ironFanPrice = parseInt(ironFanPrice * 100, 10); - if (isNaN(_ironFanPrice) || _ironFanPrice < 100 || _ironFanPrice > 388800) { - Toast.show({ - icon: "fail", - content: "请输入有效的铁粉价格", - position: "top", - }); - return; - } let isPrice = false; if (openSuper) { Object.values(superSingle).forEach((it) => { @@ -203,7 +164,7 @@ export default function CreateProfile() { if (!superFanPrice) { Toast.show({ icon: "fail", - content: "请填写超粉价格", + content: "请输入有效的超粉价格", position: "top", }); isPrice = true; @@ -286,7 +247,6 @@ export default function CreateProfile() { // } } if (isPrice) return; - debugger; // 旧版本 // const superfanList = superSingle.map((it, index) => ({ // period: index, @@ -296,8 +256,8 @@ export default function CreateProfile() { // })); // const superfanObj = superfanList.filter((it) => it.enable)[0]; // 新版本代码 - const superfan_price_list = superSingle.map((it, index) => ({ - period: index, + const superfan_price_list = superSinglesContr.map((it) => ({ + period: it.key, enable: it.enable ? 1 : 0, price: parseInt(it.price * 100, 10), is_superfanship_give_wechat: it.wechatFree ? 1 : 0, @@ -306,8 +266,8 @@ export default function CreateProfile() { try { const body = { profile: spaceIntro, - admission_price: parseInt(spacePrice * 100, 10), - ironfanship_price: parseInt(ironFanPrice * 100, 10), + admission_price: _spacePrice, + ironfanship_price: _ironFanPrice, is_superfanship_enabled: openSuper ? 1 : 0, // 旧版本 // superfanship_price: superfanObj.price, @@ -344,6 +304,7 @@ export default function CreateProfile() { setIsSubmitting(false); } }; + const messageEle = (message) =>

    {message}

    ; return (
    {/* 头部标题 */} @@ -364,165 +325,273 @@ export default function CreateProfile() {
    {/* 内容 */}
    -
    -
    -

    - 空间介绍 - * -

    -

    -
    -
    -