"use client"; import React, { useEffect, useState } from "react"; import { Image, Mask, Toast, Input, TextArea } from "antd-mobile"; import require from "@/utils/require"; import { get } from "@/utils/storeInfo"; import { useRouter } from "next/navigation"; import {getStreamerDetailInfo} from "@/api/space" export default function AddWeChat({ visible, closeMask, name, price, streamerMid, avatar, streamerData, }) { const [isMoneyEnough, setIsMoneyEnough] = useState(true); const [streamerDetailData, setStreamerDetailData] = useState(null); const router = useRouter(); useEffect(()=>{ if(!streamerMid)return; getStreamerDetailInfo(streamerMid).then(res=>{ setStreamerDetailData(res) }) },[]) //点击解锁微信按钮 const unlockWechat = async () => { //余额不够就显示余额不足前往充值,够就直接购买 //先支付,支付成功后添加解锁关系,再展示解锁界面 //支付金币解锁微信 const account = get("account"); if (account) { try { const userResponse = await require("POST", "/api/account/list_by_mid", { body: { mid: account.mid, }, }); if (userResponse.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } if (userResponse?.data.account?.gold_num >= price) { console.log("余额足够"); const data = await require("POST", "/api/vas/one_step_unlock", { body: { contact_product_id: "contact_wechat", uid: streamerMid, }, }); if (data.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } //展示解锁界面 // setIsWechatUnlocked(true); } else { setIsMoneyEnough(false); } } catch (error) { console.error(error); } } }; return (
closeMask(false)}>
{isMoneyEnough ? ( <>

{name}

{streamerData?.streamer_ext?.wechat_lock_type === 0 ? (
解锁后展示

添加时请备注自己“铁粉空间”昵称
若解锁后72小时为通过好友,请联系客服

) : (

* 您的微信

备注