import { Component } from "react";
import { View, Text, Image } from "@tarojs/components";
import "./index.scss";
import { AtTabBar } from "taro-ui";
import React, { useCallback, useEffect, useState } from "react";
import { AtGrid } from "taro-ui";
import { Swiper, SwiperItem } from "@tarojs/components";
import { AtCard } from "taro-ui";
import { AtImagePicker } from "taro-ui";
import Taro from "@tarojs/taro";
import { AtAvatar } from "taro-ui";
import { AtTag } from "taro-ui";
import { AtList, AtListItem } from "taro-ui";
import avatar from "../../images/avatar.jpg";

// export default class Index extends Component {
const My = () => {
  const [current, setcurrent] = useState(2);
  const [wxid, setwxid] = useState(null);

  useEffect(()=>{
    getWxid()
  },[])

  const getWxid = () => {
    let newWxid = window.localStorage.getItem("wxid");
    if (!!newWxid) {
      setwxid(newWxid);
    }
  };

  const handleClick = (value) => {
    console.log("value", value);
    setcurrent(value);
    if (value == 2) {
      // 跳转到目的页面，在当前页面打开
      Taro.navigateTo({
        url: "/pages/my/index",
      });
    } else if (value == 0) {
      Taro.navigateTo({
        url: "/pages/index/index",
      });
    } else {
      Taro.navigateTo({
        url: "/pages/meetup/index",
      });
    }
  };
  return (
    <View className="my">
      {/* <Text>Hello world!</Text> */}

      <View className="myAtAvatar">
        <AtAvatar className="AtAvatar" image={avatar}></AtAvatar>
        <AtTag type="primary" circle>
          新注册用户
        </AtTag>
      </View>

      <AtList>
        <AtListItem
          title="联系我们"
          note=""
          arrow="right"
          iconInfo={{ size: 25, color: "#78A4FA", value: "calendar" }}
        />
        <AtListItem
          title="版本日志"
          note=""
          extraText=""
          arrow="right"
          iconInfo={{ size: 25, color: "#FF4949", value: "bookmark" }}
        />
      </AtList>

      <View className="indexTablebar">
        <AtTabBar
          tabList={[
            { title: "首页", text: "" },
            { title: "活动" },
            { title: "我的" },
          ]}
          onClick={(value) => handleClick(value)}
          current={current}
        />
      </View>
    </View>
  );
};

export default My;
