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 Normal from '@/components/owner/rights/normal';
|
||||||
import Premium, { PayItem } from '@/components/owner/rights/premium';
|
import Premium, { PayItem } from '@/components/owner/rights/premium';
|
||||||
import ProRights from '@/components/owner/rights/proRights';
|
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 { ThemedText } from '@/components/ThemedText';
|
||||||
import { CreateOrder } from '@/types/personal-info';
|
import { CreateOrder } from '@/types/personal-info';
|
||||||
import { ErrorCode, getAvailablePurchases, getPurchaseHistories, ProductPurchase, useIAP } from 'expo-iap';
|
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) => {
|
const handlePurchase = async (sku: string, transaction_id: string) => {
|
||||||
console.log('handlePurchase', sku);
|
|
||||||
try {
|
try {
|
||||||
|
// 支付中
|
||||||
|
await payProcessing(transaction_id, "")
|
||||||
const res = await requestPurchase({
|
const res = await requestPurchase({
|
||||||
request: {
|
request: {
|
||||||
ios: {
|
ios: {
|
||||||
@ -93,8 +94,9 @@ export default function Rights() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log('Purchase success:', res);
|
console.log('Purchase success:', res);
|
||||||
|
|
||||||
// 支付成功
|
// 支付成功
|
||||||
paySuccess(transaction_id, res?.transactionId || "")
|
await paySuccess(transaction_id, res?.transactionId || "")
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log('Purchase failed:', error);
|
console.log('Purchase failed:', error);
|
||||||
// 支付失败
|
// 支付失败
|
||||||
@ -104,8 +106,6 @@ export default function Rights() {
|
|||||||
|
|
||||||
// 获取苹果订单信息
|
// 获取苹果订单信息
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('connected', connected);
|
|
||||||
|
|
||||||
if (!connected) return;
|
if (!connected) return;
|
||||||
|
|
||||||
const initializeStore = async () => {
|
const initializeStore = async () => {
|
||||||
@ -121,7 +121,6 @@ export default function Rights() {
|
|||||||
|
|
||||||
// 初始化获取产品项
|
// 初始化获取产品项
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('subscriptions', subscriptions);
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
getPAy().then(({ bestValue, payInfo }) => {
|
getPAy().then(({ bestValue, payInfo }) => {
|
||||||
setPayType(bestValue?.product_code)
|
setPayType(bestValue?.product_code)
|
||||||
@ -172,13 +171,6 @@ export default function Rights() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentPurchase) {
|
|
||||||
console.log('currentPurchase', currentPurchase);
|
|
||||||
}
|
|
||||||
}, [currentPurchase]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log('pro', pro);
|
|
||||||
if (pro === "Pro") {
|
if (pro === "Pro") {
|
||||||
setUserType('premium')
|
setUserType('premium')
|
||||||
} else {
|
} else {
|
||||||
@ -314,7 +306,7 @@ export default function Rights() {
|
|||||||
|
|
||||||
</View>
|
</View>
|
||||||
{/* 协议弹窗 */}
|
{/* 协议弹窗 */}
|
||||||
<PrivacyModal modalVisible={showTerms} setModalVisible={setShowTerms} type={"user"} />
|
<PrivacyModal modalVisible={showTerms} setModalVisible={setShowTerms} type={"member"} />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,10 +3,12 @@ import { Policy } from '@/types/personal-info';
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Modal, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
import { Modal, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
||||||
import RenderHtml from 'react-native-render-html';
|
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 PrivacyModal = (props: { modalVisible: boolean, setModalVisible: (visible: boolean) => void, type: string }) => {
|
||||||
const { modalVisible, setModalVisible, type } = props;
|
const { modalVisible, setModalVisible, type } = props;
|
||||||
const [article, setArticle] = useState<Policy>({} as Policy);
|
const [article, setArticle] = useState<Policy>({} as Policy);
|
||||||
|
const insets = useSafeAreaInsets();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadArticle = async () => {
|
const loadArticle = async () => {
|
||||||
// ai协议
|
// ai协议
|
||||||
@ -41,6 +43,14 @@ const PrivacyModal = (props: { modalVisible: boolean, setModalVisible: (visible:
|
|||||||
console.log(error)
|
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) {
|
if (type) {
|
||||||
loadArticle();
|
loadArticle();
|
||||||
@ -63,7 +73,7 @@ const PrivacyModal = (props: { modalVisible: boolean, setModalVisible: (visible:
|
|||||||
onRequestClose={() => {
|
onRequestClose={() => {
|
||||||
setModalVisible(!modalVisible);
|
setModalVisible(!modalVisible);
|
||||||
}}>
|
}}>
|
||||||
<View style={styles.centeredView}>
|
<View style={[styles.centeredView, { bottom: insets.bottom }]}>
|
||||||
<View style={styles.modalView}>
|
<View style={styles.modalView}>
|
||||||
<View style={styles.modalHeader}>
|
<View style={styles.modalHeader}>
|
||||||
<Text style={{ opacity: 0 }}>Settings</Text>
|
<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`, {
|
const payment = await fetchApi(`/order/pay-processing`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
transaction_id,
|
transaction_id
|
||||||
third_party_transaction_id
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return payment
|
return payment
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user