import { useState } from "react"; import { View, Text, Image } from "@tarojs/components"; import Taro, { useRouter, useUnload } from "@tarojs/taro"; import PageCustom from "@/components/page-custom/index"; import NavBarNormal from "@/components/NavBarNormal/index"; import WemetaTextarea from "@/components/wemeta-textarea/index"; import WemetaInput from "@/components/wemeta-input/index"; import { useComponentStore } from "@/store/componentStore"; import { SocialMediaType } from "@/consts/socialMedia"; import BottomBar from "@/components/BottomBar"; import { EComponentType } from "@/consts/enum"; import Popup from "@/components/popup/popup"; import ButtonMain from "@/components/buttons/ButtonMain"; export default function Index() { const router = useRouter(); // 社交媒体类型 const { mediaType } = router.params; let mt = mediaType ?? "link"; let defaultLabel = `${SocialMediaType[mt]?.label} 链接`; if (mediaType === "shiping") { defaultLabel = "视频号"; } let currentComponent = useComponentStore((state) => state.currentComponent); if (!currentComponent) { return <>; } const { saveComponent } = useComponentStore(); const loading = useComponentStore((state) => state.loading); const data = currentComponent?.data ?? {}; const { value, text, layout } = data; const [show, setShow] = useState(false); const [linkValue, setLinkValue] = useState(value ?? ""); const [linkText, setLinkText] = useState(text ?? ""); // 是否为视频号, 视频号需要特殊提示 // 如果后期还有更特殊需求,抽取单独页面 const isShiping = SocialMediaType[mt]?.value === "shiping"; const handleSubmit = async () => { if (!data?.id) { return; } if (loading) { return; } const c = { data: { value: linkValue, text: linkText, layout: layout ?? "", id: data.id, index: data.index, }, enabled: currentComponent?.enabled ?? true, type: mediaType as EComponentType, }; console.log(c); await saveComponent(c); Taro.navigateBack(); }; return ( {defaultLabel} {isShiping ? '视频号ID': '链接'}* {isShiping && ( setShow(true)}> 如何获取? )} setLinkValue(value)} placeholder="填写视频号ID" maxlength={50} > 链接描述 setLinkText(value)} placeholder="请输入..." maxlength={50} /> 保存 🌟 小蓝本提示: 获取视频号ID的需要登录视频号助手,在首页可以查看自己的视频号ID ); }