import React, { useState, useEffect,useRef } from 'react' import Taro from '@tarojs/taro' import CustomNav from '@/components/CustomNav' import logo from '@/assets/icons/comm/logo_small.png' import withLayout from '@/layouts' import tabList from './tabbar' import Guide from './tabs/Guide' import Mine from './tabs/Mine' import Recommend from './tabs/Recommend' import './index.less' import { getLocation } from '@/utils/location' import { getIndexType, getResourceList } from '@/services/home' export default withLayout((props) => { const { router, person } = props const { params, path } = router const { tab } = params || {} const [currentTab, setCurrentTab] = useState(0) const locRef = useRef() const handleTabChange = (e) => { const { index } = e.detail setCurrentTab(index) } const [queryParams, setQueryParams] = useState({ location: '', pageNum: 1, pageSize: 10, typeId: '' }) useEffect(() => { getLocation().then((res) => { locRef.current = `${res.longitude},${res.latitude}` setQueryParams({ ...queryParams, location: locRef.current }) }) }, []) useEffect(() => { if (tab) { setCurrentTab(tab - 0) } }, [tab]) return ( {currentTab === 0 && } {currentTab === 1 && } {/* {currentTab === 2 && } */} {currentTab === 2 && } ) })