修复无法在第一次获取微信的bug

This commit is contained in:
jueweijue 2024-06-26 08:58:15 +08:00
parent a2e25cd973
commit 6a2a635584
1 changed files with 19 additions and 24 deletions

View File

@ -65,7 +65,6 @@ export default function Purchased() {
getData(); getData();
}, []); }, []);
const [currentWechat, setCurrentWechat] = useState("");
const getWechat = async (streamerMid) => { const getWechat = async (streamerMid) => {
// //
try { try {
@ -94,7 +93,7 @@ export default function Purchased() {
}); });
return; return;
} }
setCurrentWechat(detailData.data.wechat_contact); return detailData.data.wechat_contact;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
@ -103,28 +102,24 @@ export default function Purchased() {
const DirectGetWechatItem = ({ item }) => { const DirectGetWechatItem = ({ item }) => {
// //
const handleClick = async () => { const handleClick = async () => {
await getWechat(item?.account.mid); const wechat = await getWechat(item?.account.mid);
setTimeout( Modal.alert({
() => showCloseButton: true,
Modal.alert({ confirmText: "复制",
showCloseButton: true, onConfirm: () => {
confirmText: "复制", copy(wechat);
onConfirm: () => { Toast.show({
copy(currentWechat); content: "复制成功",
Toast.show({ });
content: "复制成功", },
}); content: (
}, <div className="p-2">
content: ( <p className="text-white text-base font-medium text-center mb-4">
<div className="p-2"> Ta的微信号<span>{wechat}</span>
<p className="text-white text-base font-medium text-center mb-4"> </p>
Ta的微信号<span>{currentWechat}</span> </div>
</p> ),
</div> });
),
}),
100
);
}; };
// //