import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components"
import classnames from "classnames";
import Search from '@/components/search'
import Product from '@/components/product'
import InfiniteScroll from '@/components/infiniteScroll'
import styles  from './index.module.scss'
import { useEffect, useState } from "react";
import Filter from "./components/filter";
import SortBtn from "@/components/sortBtn";
import SelectData from "../searchList/components/selectData";
import {GetSubjectList} from '@/api/subjectMaterial'

export default () => {
    const [showPopup, setShowPopup] = useState(false)
    const [selectList, setSelectList] = useState([
        {title: '系列', value:1},
        {title: '系列', value:2},
        {title: '系列', value:3},
        {title: '系列', value:4},
        {title: '系列', value:6},
        {title: '系列', value:7},
        {title: '系列', value:8},
        {title: '系列', value:9},
        {title: '系列', value:10},
    ])

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

    //获取专题
    const [list, setList] = useState<any>([])
    const {fetchData} = GetSubjectList()
    const getSubjectList = async () => {
        let res = await fetchData()
        console.log('res::', res)
    }

    return (
        <View className={styles.main}>
            <View className={styles.search}>
                <Search placeIcon="out" showBtn={true} btnStyle={{color: '#007AFF'}}/>
            </View>
            <View className={styles.filter}>
                <View className={styles.filter_all}>
                    <View className={styles.text_one}>
                        <Text>综合</Text>
                        <SortBtn status="top"/>
                    </View>
                    <View className={styles.text_two} onClick={() => setShowPopup(true)}>
                        <Text>筛选</Text>
                        <Text className={classnames('iconfont icon-bianji_bianji', styles.miconfont)}></Text>
                    </View>
                </View>
                <View className={styles.filter_btns}>
                    <SelectData list={selectList}/>
                </View>
            </View>
            <View className={styles.list}>
                <InfiniteScroll selfonScrollToLower={() => console.log('123123')}>
                    <Product desStatus={false}/>
                </InfiniteScroll>
            </View>
            <Filter show={showPopup} onClose={() => setShowPopup(false)} onFiltr={(e) => console.log('e:::',e)}/>
        </View>
    )
}