index.jsx 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React, { useEffect, useState } from 'react'
  2. import Taro from "@tarojs/taro";
  3. import { Button, View } from '@tarojs/components'
  4. import './index.scss'
  5. // const getColor = (role) => {
  6. // switch (role) {
  7. // case roleList.landlord: return '#274291'
  8. // case roleList.adminuser: return '#274291'
  9. // // landlord: 'landlord',
  10. // case roleList.customer: return '#fed12f'
  11. // }
  12. // }
  13. const tab = (props) => {
  14. // formType="submit"
  15. const { value, pageState, formType, color, ...prop } = props
  16. const [state, setState] = useState(1)
  17. // console.log(props)
  18. useEffect(() => {
  19. }, [])
  20. // &-on{
  21. // color: #fed12f; style={{ backgroundColor:'#274291' ,color}}
  22. // }${props.className}
  23. return <View className='tab'>
  24. {value.length == 1 && <View className={`tab tab1 ${props.className}`} onClick={() => props.onClick('2')}>{value[0]}
  25. </View>}
  26. {value.length == 2 && <View className={`tab tab2 ${props.className}`} style={{ display: 'flex', }}>
  27. <View style={{ width: '50%' }} style={pageState == '2' ? { color: '#274291', width: '50%' } : { width: '50%' }} onClick={props.onClick[0]}>{value[0]}</View>
  28. { !formType?
  29. <View formType={formType} style={{ width: '50%' }} style={pageState == '3' ? { color: '#274291', width: '50%' } : { width: '50%' }} onClick={props.onClick[1]}>{value[1]}</View>
  30. :<Button className='tab-btn' formType={formType} plain={true} style={{ width: '50%' }} style={pageState == '3' ? { color: '#274291', width: '50%',border:'none' } : { width: '50%',border:'none' }} onClick={props.onClick[1]}>{value[1]}</Button>}
  31. </View>}
  32. </View>
  33. };
  34. export default tab