ToggleRole.jsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { useState, useEffect } from 'react';
  2. import SpinBox from "@/components/Spin/SpinBox";
  3. import touristON from '@/assets/icons/UserCenter/touristON.png'
  4. import touristOFF from '@/assets/icons/UserCenter/touristOFF.png'
  5. import hotelBossON from '@/assets/icons/UserCenter/hotelBossON.png'
  6. import hotelBossOFF from '@/assets/icons/UserCenter/hotelBossOFF.png'
  7. import shopBossON from '@/assets/icons/UserCenter/shopBossON.png'
  8. import shopBossOFF from '@/assets/icons/UserCenter/shopBossOFF.png'
  9. import Popup from '@/components/Popup'
  10. import './ToggleRole.less'
  11. import { useModel } from '@/store'
  12. export default (props) => {
  13. const { showCutover, onClose, maskClosable, role } = props
  14. const { getRole, loading } = useModel('person')
  15. // const [loading, setLoading] = useState(false)
  16. const goToPerson = () => {
  17. getRole('normal')
  18. }
  19. const goToHotel = () => {
  20. getRole('hotel')
  21. }
  22. const goToShop = () => {
  23. getRole('shop')
  24. }
  25. return (
  26. <Popup show={showCutover} maskClosable={maskClosable} onClose={onClose}>
  27. <SpinBox loading={loading} className='index-container' >
  28. <view className='User-box-sths' >
  29. <view className='User-box-selectUser'>请选择身份:</view>
  30. <view className='User-box-tourist' onClick={goToPerson}>
  31. <image className='Ubs-tourist-image' src={role === 'normal' ? touristON : touristOFF} />
  32. <text className='Ubs-tourist-text'>我是用户</text>
  33. </view>
  34. <view className='User-box-hotelBoss' onClick={goToHotel}>
  35. <image className='Ubs-hotelBoss-image' src={role === 'hotel' ? hotelBossON : hotelBossOFF} />
  36. <text className='Ubs-hotelBoss-text'>我是房东</text>
  37. </view>
  38. <view className='User-box-shopBoss' onClick={goToShop}>
  39. <image className='Ubs-shopBoss-image' src={role === 'shop' ? shopBossON : shopBossOFF} />
  40. <text className='Ubs-shopBoss-text'>我是商铺</text>
  41. </view>
  42. </view>
  43. </SpinBox>
  44. </Popup >
  45. )
  46. }