import { Button } from '@tarojs/components';
import Taro from '@tarojs/taro';
import useAppBackState from '@/hooks/useAppBackState';
import './AppBackButton.scss';

const AppBackButton = () => {
  const isShow = useAppBackState();
  const goBackAppError = e => {
    console.log(e);
    Taro.showModal({
      title: '提示',
      content: '呼起APP失败,请手动回到APP',
    });
  };

  return isShow ? (
    <Button
      className='AppBackButton'
      open-type='launchApp'
      app-parameter='wechat'
      onError={goBackAppError}>
      返回
    </Button>
  ) : null;
};

export default AppBackButton;
