"use client"; import React, { useState, useEffect } from "react"; import AuthBar from "@/components/AuthBar"; import { Toast } from "antd-mobile"; import { checkAuth } from "@/utils/auth"; import { useRouter } from "next/navigation"; import baseRequest from "@/utils/baseRequest"; import { generateSignature } from "@/utils/crypto"; import copy from "@/utils/copy"; export default function Purchased() { //如果没登录直接跳转下载页 const router = useRouter(); useEffect(() => { const prepare = async () => { if (window.location.origin === "https://weixin.tiefen.fun") { router.replace("https://tiefen.fun/purchased"); return; } const isLogined = await checkAuth(); if (!isLogined) { router.replace("/auth/login/phonenumlogin"); } }; prepare(); }, []); //获取订单数据 const [data, setData] = useState([]); useEffect(() => { const getData = async () => { try { const base = baseRequest(); const signature = generateSignature({ offset: 0, limit: 99, ...base, }); const detailResponse = await fetch( `/api/vas/h5_get_unlock_wechat_list?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ offset: 0, limit: 99, ...base, }), } ); const detailData = await detailResponse.json(); if (detailData.ret === -1) { Toast.show({ content: detailData.msg, }); return; } setData(detailData.data.list); } catch (error) { console.error(error); } }; getData(); }, []); const [currentWechat, setCurrentWechat] = useState(""); const getWechat = async (streamerMid) => { // 获取微信 try { const base = baseRequest(); const signature = generateSignature({ uid: streamerMid, ...base, }); const detailResponse = await fetch( `/api/vas/query_wechat?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ uid: streamerMid, ...base, }), } ); const detailData = await detailResponse.json(); if (detailData.ret === -1) { Toast.show({ content: detailData.msg, }); return; } setCurrentWechat(detailData.data.wechat_contact); } catch (error) { console.error(error); } }; const DirectGetWechatItem = ({ item }) => { //点击查看微信 const handleClick = async () => { await getWechat(item?.account.mid); setTimeout( () => document.getElementById("get_wechat_modal").showModal(), 100 ); }; //点击主播 const handleNavigation = () => { router.push(`../${item?.account.user_id}`); }; let orderLabel; switch (item.order_status) { case 3: orderLabel = item.lock_type === 1 ? `等待${item.account.name}添加您的微信` : "请查看并添加微信"; break; case 4: orderLabel = `${item.account.name}已确认完成添加`; break; case 5: orderLabel = `订单已完成`; break; case 6: orderLabel = `已退款`; break; default: orderLabel = ""; } return (
{item.account?.name}
{orderLabel}
{item.account?.name}
{status === "pending" ? "请填写您的微信等待Ta添加您" : "已提交您的微信,请留意好友请求"}
若购买成功却未展示订单,请刷新页面