feat: 会员协议
This commit is contained in:
parent
bfcebf90fb
commit
792c3a0888
@ -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() {
|
||||
|
||||
</View>
|
||||
{/* 协议弹窗 */}
|
||||
<PrivacyModal modalVisible={showTerms} setModalVisible={setShowTerms} type={"user"} />
|
||||
<PrivacyModal modalVisible={showTerms} setModalVisible={setShowTerms} type={"member"} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -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<Policy>({} 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<Policy>(`/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);
|
||||
}}>
|
||||
<View style={styles.centeredView}>
|
||||
<View style={[styles.centeredView, { bottom: insets.bottom }]}>
|
||||
<View style={styles.modalView}>
|
||||
<View style={styles.modalHeader}>
|
||||
<Text style={{ opacity: 0 }}>Settings</Text>
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user