import { View, Text, Image, Button, Icon, Dialog } from "@tarojs/components";
import { useLoad } from "@tarojs/taro";
import Taro from "@tarojs/taro";
import {
  AtAvatar,
  AtTag,
  AtIcon,
  AtTabBar,
  AtButton,
  AtAccordion,
  AtList,
  AtListItem,
  AtModal,
  AtModalHeader,
  AtModalContent,
  AtModalAction,
  AtCurtain,
} from "taro-ui";
import "./index.scss";
import beijing from "@/images/city/beijing.jpg";
import guangzhou from "@/images/city/guangzhou.jpg";
import shanghai from "@/images/city/shanghai.jpg";
import shenzhen from "@/images/city/shenzhen.jpg";
import touxiang from "@/images/index/touxiang.jpg";
import QRcodePng from "@/images/index/QRcode.png";

import TabbarCom from "@/componments/TabbarCom";
import { useEffect, useState } from "react";
const QrCode = (props) => {
  console.log("props", props);
  const [isOpened, setisOpened] = useState(false);
  useEffect(() => {
    setisOpened(props.isOpened);
  }, [props.isOpened]);

  const Qrcode = () => {
    return (
      <View className="wechatCode">
        <View>长按识别二维码</View>
        <Image
          style={{ width: "100px", height: "100px" }}
          showMenuByLongpress={true}
          src={QRcodePng}
          // src='cloud://citynew-0givkbre03955d8c.6369-citynew-0givkbre03955d8c-1253655588/images/touxiang/download-1.jpg'
        ></Image>
      </View>
    );
  };
  return (
    <View className="QrCode">
      {/* <AtModal
        isOpened={isOpened}
        title="长按识别二维码"
        cancelText="取消"
        confirmText="确认"
        onClose={() => {
          setisOpened(false);
        }}
        onCancel={() => {
          setisOpened(false);
        }}
        onConfirm={() => {
          setisOpened(false);
        }}
        content={Qrcode}
      /> */}

      <AtCurtain
        isOpened={isOpened}
        closeBtnPosition="top-right"
        onClose={() => {
          setisOpened(false);
          // 设置父组件状态
          props.setisOpened(false);
        }}
      >
        <Qrcode />
      </AtCurtain>
    </View>
  );
};

export default QrCode;
