import { Tabbar, TabbarItem } from "@antmjs/vantui";
import { View } from "@tarojs/components";
import Taro from "@tarojs/taro";
import react from "react";

const TabbarCom = (props: any) => {
  const [active, setActive] = react.useState(props?.active ?? 0);

  return (
    <View style={{marginTop:'40px'}}>
      <Tabbar
        active={active}
        onChange={(e: any) => {
          console.log("e", e);
          setActive(e?.detail);
          if(e?.detail===0){
            Taro.redirectTo({
                url: "/pages/home/index",
              });
          }
          if(e?.detail===1){
            Taro.redirectTo({
                url: "/pages/activityList/index",
              });
          }
          if(e?.detail===2){
            Taro.redirectTo({
                url: "/pages/my/index",
              });
          }
        }}
        safeAreaInsetBottom={true}
      >
        <TabbarItem icon="home-o">首页</TabbarItem>
        {/* <TabbarItem icon="search">标签</TabbarItem> */}
        <TabbarItem icon="friends-o">活动</TabbarItem>
        <TabbarItem icon="setting-o">我的</TabbarItem>
      </Tabbar>
    </View>
  );
};

export default TabbarCom;
