import { View, Text, ScrollView, KeyboardAvoidingView, Platform, ActivityIndicator, } from "react-native"; import { Button, CheckBox } from "@rneui/themed"; import React, { useState, useCallback } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Divider } from "@rneui/themed"; import baseRequest from "../../../utils/baseRequest"; import Toast from "react-native-toast-message"; import { generateSignature } from "../../../utils/crypto"; import { useFocusEffect } from "@react-navigation/native"; import dayjs from "dayjs"; export default function RefundDetail({ navigation, route }) { const tailwind = useTailwind(); const insets = useSafeAreaInsets(); const [data, setData] = useState(null); const [dragging, setDragging] = useState(true); const [isSubmitting, setIsSubmitting] = useState(false); const [selectedIndex, setIndex] = useState(2); const [checkAble, setCheckAble] = useState(true); //每次focus都更新一次数据 useFocusEffect( useCallback(() => { const getData = async () => { //获取环境变量 const apiUrl = process.env.EXPO_PUBLIC_API_URL; const base = await baseRequest(); const signature = await generateSignature({ ...base, audit_id: route.params.id, }); try { const refundResponse = await fetch( `${apiUrl}/api/zone/refund_info?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ ...base, audit_id: route.params.id, }), } ); const refundData = await refundResponse.json(); if (refundData.ret === -1) { Toast.show({ type: "error", text1: refundData.msg, topOffset: 60, }); return; } setData(refundData.data); setIndex(refundData.data.refunds_status); setCheckAble(refundData.data.refunds_status === 1); } catch (error) { console.error(error); } }; getData(); }, []) ); const handleSubmit = async (values) => { setIsSubmitting(true); //获取环境变量 const apiUrl = process.env.EXPO_PUBLIC_API_URL; //上传表单 const base = await baseRequest(); const body = { audit_id: route.params.id, refunds_status: selectedIndex, ...base, }; const signature = await generateSignature(body); try { const response = await fetch( `${apiUrl}/api/zone/refund_audit?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), } ); const responseData = await response.json(); if (responseData.ret === -1) { Toast.show({ type: "error", text1: responseData.msg, topOffset: 60, }); return; } setCheckAble(false); } catch (error) { console.error(error); } finally { setIsSubmitting(false); } }; return ( 退款价格 ¥ {data ? data?.price / 100 : "0"} 退款用户 {data?.nike_name} 购买时间 {dayjs(data?.ct * 1000).format("YYYY-MM-DD HH:mm:ss")} 退款时间 {dayjs(data?.refund_t * 1000).format("YYYY-MM-DD HH:mm:ss")} 退款联系人 {data?.contact_name} 退款联系方式 {data?.contact_phone} 退款备注 {data?.note} 是否同意当前退款 setIndex(2)} checkedIcon="dot-circle-o" uncheckedIcon="circle-o" checkedColor={checkAble ? "#FF669E" : "#FFFFFF80"} containerStyle={tailwind("bg-transparent p-0 m-0")} wrapperStyle={tailwind("items-center")} title={ 同意退款 同意退回用户的[空间成员]费用,同时自动禁止用户再次购买此商品。 {data && data?.refunds_status} } /> setIndex(-1)} checkedIcon="dot-circle-o" uncheckedIcon="circle-o" checkedColor={checkAble ? "#FF669E" : "#FFFFFF80"} containerStyle={tailwind("bg-transparent p-0 m-0")} wrapperStyle={tailwind("items-center")} title={ 拒绝退款 拒绝退回用户的[空间成员]费用。 } /> ); }