diff --git a/app/(tabs)/rights.tsx b/app/(tabs)/rights.tsx index c77579d..1fb9eda 100644 --- a/app/(tabs)/rights.tsx +++ b/app/(tabs)/rights.tsx @@ -5,7 +5,7 @@ import PrivacyModal from '@/components/owner/qualification/privacy'; import Normal from '@/components/owner/rights/normal'; import Premium, { PayItem } from '@/components/owner/rights/premium'; import ProRights from '@/components/owner/rights/proRights'; -import { createOrder, createPayment, getPAy, isOrderExpired, payFailure, paySuccess } from '@/components/owner/rights/utils'; +import { createOrder, createPayment, getPAy, isOrderExpired, payFailure, payProcessing, paySuccess } from '@/components/owner/rights/utils'; import { ThemedText } from '@/components/ThemedText'; import { CreateOrder } from '@/types/personal-info'; import { ErrorCode, getAvailablePurchases, getPurchaseHistories, ProductPurchase, useIAP } from 'expo-iap'; @@ -82,8 +82,9 @@ export default function Rights() { // 处理购买 const handlePurchase = async (sku: string, transaction_id: string) => { - console.log('handlePurchase', sku); try { + // 支付中 + await payProcessing(transaction_id, "") const res = await requestPurchase({ request: { ios: { @@ -93,8 +94,9 @@ export default function Rights() { }, }); console.log('Purchase success:', res); + // 支付成功 - paySuccess(transaction_id, res?.transactionId || "") + await paySuccess(transaction_id, res?.transactionId || "") } catch (error: any) { console.log('Purchase failed:', error); // 支付失败 @@ -104,8 +106,6 @@ export default function Rights() { // 获取苹果订单信息 useEffect(() => { - console.log('connected', connected); - if (!connected) return; const initializeStore = async () => { @@ -121,7 +121,6 @@ export default function Rights() { // 初始化获取产品项 useEffect(() => { - console.log('subscriptions', subscriptions); setLoading(true); getPAy().then(({ bestValue, payInfo }) => { setPayType(bestValue?.product_code) @@ -172,13 +171,6 @@ export default function Rights() { }; useEffect(() => { - if (currentPurchase) { - console.log('currentPurchase', currentPurchase); - } - }, [currentPurchase]); - - useEffect(() => { - console.log('pro', pro); if (pro === "Pro") { setUserType('premium') } else { @@ -314,7 +306,7 @@ export default function Rights() { {/* 协议弹窗 */} - + ); } diff --git a/components/owner/qualification/privacy.tsx b/components/owner/qualification/privacy.tsx index 3540069..58ab7f8 100644 --- a/components/owner/qualification/privacy.tsx +++ b/components/owner/qualification/privacy.tsx @@ -3,10 +3,12 @@ import { Policy } from '@/types/personal-info'; import React, { useEffect, useState } from 'react'; import { Modal, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import RenderHtml from 'react-native-render-html'; +import { useSafeAreaInsets } from "react-native-safe-area-context"; const PrivacyModal = (props: { modalVisible: boolean, setModalVisible: (visible: boolean) => void, type: string }) => { const { modalVisible, setModalVisible, type } = props; const [article, setArticle] = useState({} as Policy); + const insets = useSafeAreaInsets(); useEffect(() => { const loadArticle = async () => { // ai协议 @@ -41,6 +43,14 @@ const PrivacyModal = (props: { modalVisible: boolean, setModalVisible: (visible: console.log(error) }) } + // 会员协议 + if (type === 'member') { + fetchApi(`/system-config/policy/membership_agreement`).then((res: any) => { + setArticle(res) + }).catch((error: any) => { + console.log(error) + }) + } }; if (type) { loadArticle(); @@ -63,7 +73,7 @@ const PrivacyModal = (props: { modalVisible: boolean, setModalVisible: (visible: onRequestClose={() => { setModalVisible(!modalVisible); }}> - + Settings diff --git a/components/owner/rights/utils.ts b/components/owner/rights/utils.ts index db9c48f..475475b 100644 --- a/components/owner/rights/utils.ts +++ b/components/owner/rights/utils.ts @@ -54,8 +54,7 @@ export const payProcessing = async (transaction_id: string, third_party_transact const payment = await fetchApi(`/order/pay-processing`, { method: 'POST', body: JSON.stringify({ - transaction_id, - third_party_transaction_id + transaction_id }) }) return payment