ToggleRole.jsx 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { useState, useEffect } from 'react';
  2. import touristON from '@/assets/icons/UserCenter/touristON.png'
  3. import touristOFF from '@/assets/icons/UserCenter/touristOFF.png'
  4. import hotelBossON from '@/assets/icons/UserCenter/hotelBossON.png'
  5. import hotelBossOFF from '@/assets/icons/UserCenter/hotelBossOFF.png'
  6. import shopBossON from '@/assets/icons/UserCenter/shopBossON.png'
  7. import shopBossOFF from '@/assets/icons/UserCenter/shopBossOFF.png'
  8. import Popup from '@/components/Popup'
  9. import './ToggleRole.less'
  10. import { useModel } from '@/store'
  11. export default (props) => {
  12. const { showCutover, onClose, maskClosable, role } = props
  13. const { getRole } = useModel('person')
  14. const goToPerson = () => {
  15. getRole('normal')
  16. }
  17. const goToHotel = () => {
  18. getRole('hotel')
  19. }
  20. const goToShop = () => {
  21. getRole('shop')
  22. }
  23. return (
  24. <Popup show={showCutover} maskClosable={maskClosable} onClose={onClose}>
  25. <view className='User-box-sths' >
  26. <view className='User-box-selectUser'>请选择身份:</view>
  27. <view className='User-box-tourist' onClick={goToPerson}>
  28. <image className='Ubs-tourist-image' src={role === 'normal' ? touristON : touristOFF} />
  29. <text className='Ubs-tourist-text'>游客</text>
  30. </view>
  31. <view className='User-box-hotelBoss' onClick={goToHotel}>
  32. <image className='Ubs-hotelBoss-image' src={role === 'hotel' ? hotelBossON : hotelBossOFF} />
  33. <text className='Ubs-hotelBoss-text'>民宿老板</text>
  34. </view>
  35. <view className='User-box-shopBoss' onClick={goToShop}>
  36. <image className='Ubs-shopBoss-image' src={role === 'shop' ? shopBossON : shopBossOFF} />
  37. <text className='Ubs-shopBoss-text'>店铺老板</text>
  38. </view>
  39. </view>
  40. </Popup>
  41. )
  42. }