| | |
| | | import Taro, { useDidShow } from '@tarojs/taro'; |
| | | import { Image, View } from '@tarojs/components'; |
| | | import { useState } from 'react'; |
| | | import { syncWhitelistBlockPageAccess } from '../../utils/whitelist'; |
| | | import './index.less'; |
| | | |
| | |
| | | * 非白名单拦截页。 |
| | | */ |
| | | export default function NotOnWhitelist() { |
| | | const [shouldRenderImage, setShouldRenderImage] = useState(false); // 白名单接口确认非白名单后才展示图片 |
| | | |
| | | useDidShow(() => { |
| | | if (typeof Taro.hideHomeButton === 'function') { |
| | | Taro.hideHomeButton(); |
| | | } |
| | | void syncWhitelistBlockPageAccess(); |
| | | setShouldRenderImage(false); |
| | | void syncWhitelistBlockPageAccess().then((whitelistAccessResult) => { |
| | | setShouldRenderImage(whitelistAccessResult === 'deny'); |
| | | }); |
| | | }); |
| | | |
| | | return ( |
| | | <View className="not-on-whitelist-page"> |
| | | <Image |
| | | className="not-on-whitelist-image" |
| | | src={NOT_ON_WHITELIST_IMAGE_URL} |
| | | mode="aspectFill" |
| | | /> |
| | | {shouldRenderImage ? ( |
| | | <Image |
| | | className="not-on-whitelist-image" |
| | | src={NOT_ON_WHITELIST_IMAGE_URL} |
| | | mode="aspectFill" |
| | | /> |
| | | ) : null} |
| | | </View> |
| | | ); |
| | | } |