Switch2.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { View, Image } from "@tarojs/components";
  2. import './Switch2.scss'
  3. import { rpxToPx } from "@/utils/tools";
  4. export default function Component(props: { isOn: boolean, onClick: Function }) {
  5. // alert('aa')
  6. if (process.env.TARO_ENV == 'weapp') {
  7. return <View className="switch1" style={{ backgroundColor: global.isDebug ? 'blue' : 'transparent' }} onClick={(e) => {
  8. if (process.env.TARO_ENV == 'weapp') {
  9. e.stopPropagation()
  10. }; props.onClick()
  11. }}>
  12. {
  13. props.isOn ? <Image src={require('@/assets/images/bell.png')} style={{ height: rpxToPx(56), width: rpxToPx(56) }} /> :
  14. <Image src={require('@/assets/images/switch_off.png')} style={{ height: rpxToPx(56), width: rpxToPx(92) }} />
  15. }
  16. {/* <Image className="switch2" style={{ backgroundColor:'blue' }}
  17. src={require(props.isOn ? '@/assets/images/switch.png' : '@/assets/images/switch.png')} /> */}
  18. </View>
  19. }
  20. return <View className="switch1" style={{ backgroundColor: global.isDebug ? 'blue' : 'transparent' }} onClick={(e) => {
  21. props.onClick()
  22. }}>
  23. {
  24. props.isOn ? <Image src={require('@/assets/images/bell.png')} style={{ height: rpxToPx(56), width: rpxToPx(56) }} /> :
  25. <Image src={require('@/assets/images/switch_off.png')} style={{ height: rpxToPx(56), width: rpxToPx(92) }} />
  26. }
  27. {/* <Image className="switch2" style={{ backgroundColor:'blue' }}
  28. src={require(props.isOn ? '@/assets/images/switch.png' : '@/assets/images/switch.png')} /> */}
  29. </View>
  30. }