import { View } from "@tarojs/components";
import react, { useEffect, useState } from "react";
import {  DropdownMenu } from "@antmjs/vantui";
import { DropdownItem } from "@antmjs/vantui";
import TabbarCom from "../components/TabbarCom";
import Taro from "@tarojs/taro";
import ActiveCard from "../components/ActiveCard";
import './index.scss'
import { getTable } from "../../utils/index";

const activityList = () => {
  const [details,setdetails]=useState<any>([{
    title: "自由职业交流会",
    address: "深圳莲花山",
    date: "20231123",
    tagName: "报名中",
    tagCode: "ut ipsum esse Excepteur velit",
    Status: "dolor",
    images: [],
    peopleArr: [],
    detailsId: "laboris pariatur commodo",
    startTime: -83917740.70315647,
    endTime: -52170253.25949725,
    rules: [],
    isDelete: false,
    useridArr: [],
    latitude: "velit ea do i",
    longitude: "voluptate sint dolore "
  }])  //活动详情
  
  useEffect(() => {
    // 设置标题
    definePageConfig({
      navigationBarTitleText: "活动列表",
    });

    let objParams = {
      tableName: "details",
      // id: "80516fb66370bcf300b8f43c5f4dd52b",
      okFun: (res) => {
        console.log("details--", res);
        // setdetails(res?.data??[])
      },
    };

    getTable(objParams);
    
  }, []);
  
  const [state, setState] = react.useState({
    option1: [
      {
        text: "全部活动",
        value: 0,
      },
      {
        text: "附近活动",
        value: 1,
      },
    ],
    option2: [
      {
        text: "默认排序",
        value: "a",
      },
      {
        text: "最近距离",
        value: "b",
      },
      {
        text: "参与最多",
        value: "c",
      },
    ],
    value1: 0,
    value2: "a",
  });
  return (
    <View className="activityList">

      <View>
        <DropdownMenu>
          <DropdownItem value={state.value1} options={state.option1} />
          <DropdownItem value={state.value2} options={state.option2} />
        </DropdownMenu>
      </View>

      {details.map((item: any,index:any) => {
        return (
          <View
            onClick={() => {
              console.log("Card");
              Taro.navigateTo({
                url: `/pages/activityList/components/details/index?id=${item?._id}`,
              });
            }}
          >
            {/* 活动卡片 */}
            <ActiveCard dataSource={item} />
          </View>
        );
      })}



      <TabbarCom active={1} />
    </View>
  );
};

export default activityList;
