index.jsx 4.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React, { useEffect, useState } from 'react'
  2. import Taro from "@tarojs/taro";
  3. import { useSelector } from 'react-redux'
  4. import { View, Button, Image } from '@tarojs/components'
  5. import uploadicon from '../../assets/uploadicon.png'
  6. import roleList from '../../util/userRole'
  7. import './index.scss'
  8. const getColor = (role) => {
  9. switch (role) {
  10. case roleList.landlord: return '#274291'
  11. case roleList.adminuser: return '#274291'
  12. // landlord: 'landlord',
  13. case roleList.customer: return '#fed12f'
  14. }
  15. }
  16. const tab = (props) => {
  17. const user = useSelector(state => state.user)
  18. const { value, openType, pageState, formType, color, ...prop } = props
  19. const [state, setState] = useState(1)
  20. console.log(props, openType, 'formType')
  21. useEffect(() => {
  22. }, [])
  23. // &-on{
  24. // color: #fed12f;
  25. // }${props.className}
  26. return <View className='tab'>
  27. {value.length == 1 &&
  28. <>
  29. {openType && <button openType="share" className={`tab,tab1,${props.className}`} style={{ backgroundColor: getColor(user.role), color }} onClick={() => props.onClick('2')}>{value[0]}</button>}
  30. {!openType && <View className={`tab,tab1,${props.className}`} style={{ backgroundColor: getColor(user.role), color }} onClick={() => props.onClick('2')}>{value[0]}</View>}
  31. </>
  32. }
  33. {value.length == 2 && <View className={`tab,tab2,${props.className}`} style={{ display: 'flex', }}>
  34. <View style={{ width: '50%' }} style={pageState == '2' ? { color: getColor(user.role), width: '50%' } : { width: '50%' }} onClick={props.onClick[0]}>{value[0]}</View>
  35. {formType && <Button className='tab-btn' formType="submit" plain={true} style={pageState == '3' ? { color: getColor(user.role), width: '50%', border: 'none' } : { width: '50%', border: 'none' }}>{value[1]}</Button>}
  36. {openType && <button className='tab-btn' openType="share" plain={true} style={pageState == '3' ? { color: getColor(user.role), width: '50%', border: 'none' } : { width: '50%', border: 'none' }}>{value[1]}</button>}
  37. {!formType&&!openType &&
  38. <View style={{ width: '50%' }} style={pageState == '3' ? { color: getColor(user.role), width: '50%' } : { width: '50%' }} onClick={props.onClick[1]}>{value[1]}</View>
  39. }
  40. </View>}
  41. </View>
  42. };
  43. export default tab
  44. // import React, { useEffect, useState } from 'react'
  45. // import Taro from "@tarojs/taro";
  46. // import { Button, View } from '@tarojs/components'
  47. // import './index.scss'
  48. // const getColor = (role) => {
  49. // switch (role) {
  50. // case roleList.landlord: return '#274291'
  51. // case roleList.adminuser: return '#274291'
  52. // // landlord: 'landlord',
  53. // case roleList.customer: return '#fed12f'
  54. // }
  55. // }
  56. // const tab = (props) => {
  57. // // formType="submit"
  58. // const { value, pageState, formType, color, ...prop } = props
  59. // const [state, setState] = useState(1)
  60. // // console.log(props)
  61. // useEffect(() => {
  62. // }, [])
  63. // // &-on{
  64. // // color: #fed12f; style={{ backgroundColor:'#274291' ,color}}
  65. // // }${props.className}
  66. // return <View className='tab'>
  67. // {value.length == 1 && <View className={`tab tab1 ${props.className}`} onClick={() => props.onClick('2')}>{value[0]}
  68. // </View>}
  69. // {value.length == 2 && <View className={`tab tab2 ${props.className}`} style={{ display: 'flex', }}>
  70. // <View style={{ width: '50%' }} style={pageState == '2' ? { color: '#274291', width: '50%' } : { width: '50%' }} onClick={props.onClick[0]}>{value[0]}</View>
  71. // { !formType?
  72. // <View formType={formType} style={{ width: '50%' }} style={pageState == '3' ? { color: '#274291', width: '50%' } : { width: '50%' }} onClick={props.onClick[1]}>{value[1]}</View>
  73. // :<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>}
  74. // </View>}
  75. // </View>
  76. // };
  77. // export default tab