看广场动态特权是否为会员特权改为服务器控制
This commit is contained in:
parent
39e50ca2ce
commit
c8f29ef9c3
|
@ -0,0 +1,49 @@
|
|||
import React, { useState, createContext, useContext, useEffect } from "react";
|
||||
import baseRequest from "../utils/baseRequest";
|
||||
import { generateSignature } from "../utils/crypto";
|
||||
|
||||
const VipVisibilityContext = createContext();
|
||||
|
||||
export const VipVisibilityProvider = ({ children }) => {
|
||||
const [isVipVisible, setIsVipVisible] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
|
||||
const base = await baseRequest();
|
||||
const signature = await generateSignature({
|
||||
...base,
|
||||
});
|
||||
const _response = await fetch(
|
||||
`${apiUrl}/api/moment/is_moment_image_encrypt_enabled?signature=${signature}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...base,
|
||||
}),
|
||||
}
|
||||
);
|
||||
const _data = await _response.json();
|
||||
if (_data.ret === -1) {
|
||||
return;
|
||||
}
|
||||
setIsVipVisible(_data.data === 1 ? true : false);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<VipVisibilityContext.Provider value={{ isVipVisible }}>
|
||||
{children}
|
||||
</VipVisibilityContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useVipVisibility = () => useContext(VipVisibilityContext);
|
|
@ -16,11 +16,15 @@ import baseRequest from "../../utils/baseRequest";
|
|||
import { generateSignature } from "../../utils/crypto";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { TabView, SceneMap, TabBar } from "react-native-tab-view";
|
||||
import { useVipVisibility } from "../../context/VipVisibilityProvider";
|
||||
|
||||
export default function Posts({ navigation }) {
|
||||
const tailwind = useTailwind();
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
//查看是否展示vip功能
|
||||
const { isVipVisible } = useVipVisibility();
|
||||
|
||||
//每次focus都更新一次数据,查看会员状态是否改变
|
||||
const [blur, setBlur] = useState(true);
|
||||
useFocusEffect(
|
||||
|
@ -60,7 +64,7 @@ export default function Posts({ navigation }) {
|
|||
}
|
||||
const role = accountData.data.account.role;
|
||||
const isVip = accountData.data.account.is_a_member;
|
||||
if (role !== 0 || isVip === 1) {
|
||||
if (role !== 0 || isVip === 1 || !isVipVisible) {
|
||||
setBlur(false);
|
||||
} else {
|
||||
setBlur(true);
|
||||
|
@ -71,7 +75,7 @@ export default function Posts({ navigation }) {
|
|||
}
|
||||
};
|
||||
getData();
|
||||
}, [])
|
||||
}, [isVipVisible])
|
||||
);
|
||||
|
||||
//tab组件相关
|
||||
|
|
|
@ -15,10 +15,14 @@ import { FlashList } from "@shopify/flash-list";
|
|||
import Post from "../../components/Post";
|
||||
import { get } from "../../utils/storeInfo";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useVipVisibility } from "../../context/VipVisibilityProvider";
|
||||
|
||||
export default function StreamerPosts({ navigation, route }) {
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
//查看是否展示vip功能
|
||||
const { isVipVisible } = useVipVisibility();
|
||||
|
||||
//获取会员价格
|
||||
const [vipPrice, setVipPrice] = useState();
|
||||
const getVipPrice = async () => {
|
||||
|
@ -126,7 +130,7 @@ export default function StreamerPosts({ navigation, route }) {
|
|||
const account = await get("account");
|
||||
const role = account.role;
|
||||
const isVip = account.is_a_member;
|
||||
if (role !== 0 || isVip === 1) {
|
||||
if (role !== 0 || isVip === 1 || !isVipVisible) {
|
||||
return setBlur(false);
|
||||
}
|
||||
return setBlur(true);
|
||||
|
|
|
@ -30,6 +30,7 @@ import StreamerProfileSkeleton from "./skeleton";
|
|||
import { generateSignature } from "../../utils/crypto";
|
||||
import Svg, { Path } from "react-native-svg";
|
||||
import { useImageViewer } from "../../context/ImageViewProvider";
|
||||
import { useVipVisibility } from "../../context/VipVisibilityProvider";
|
||||
|
||||
const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk";
|
||||
|
||||
|
@ -54,13 +55,16 @@ export default function StreamerProfile({ navigation, route }) {
|
|||
});
|
||||
}, []);
|
||||
|
||||
//查看是否展示vip功能
|
||||
const { isVipVisible } = useVipVisibility();
|
||||
|
||||
//动态是否需要blur
|
||||
const [blur, setBlur] = useState(true);
|
||||
const checkBlur = async () => {
|
||||
const account = await get("account");
|
||||
const role = account.role;
|
||||
const isVip = account.is_a_member;
|
||||
if (role !== 0 || isVip === 1) {
|
||||
if (role !== 0 || isVip === 1 || !isVipVisible) {
|
||||
return setBlur(false);
|
||||
}
|
||||
return setBlur(true);
|
||||
|
|
|
@ -35,7 +35,6 @@ export async function storeAppInfo() {
|
|||
}
|
||||
|
||||
const b_did = await getDid();
|
||||
console.log(b_did);
|
||||
const b_ver = Application.nativeApplicationVersion;
|
||||
const b_dt = Device.osName === "Android" ? 0 : 1;
|
||||
const b_ch = "production";
|
||||
|
|
Loading…
Reference in New Issue