import classnames from "classnames"; import Taro from "@tarojs/taro"; import { Component } from "react"; import { Block, View, Image, Text, Button, PageMeta } from "@tarojs/components"; export default class BaseComponent extends Component { constructor(props) { super(props); this.state = { name: "全局组件", }; } async onLoad() {} componentDidMount() {} componentWillUnmount() {} componentDidShow() {} componentDidHide() {} async initData() {} showInit() { const isFirst = Taro.getStorageSync("isWelcome"); if (isFirst) { this.checkShowPrivacyPopup(); } } // 检测是否弹出隐私协议 checkShowPrivacyPopup() { Taro.getPrivacySetting({ success: (res) => { // console.log("检测是否弹出隐私协议", res); // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' } if (res.needAuthorization) { this.setState({ isShowPrivacyPopup: true }); } else { // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口 this.initData(); } }, fail: () => {}, complete: () => { // 授权完成运行页面初始化 }, }); } render() { return ; } }