index.jsx 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import React from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View, Text } from '@tarojs/components';
  4. import { Popup, Cell, Icon } from '@antmjs/vantui';
  5. import RatioView from '@/components/RatioView';
  6. import style from './style.module.less';
  7. const Bar = (props) => {
  8. const {cursor, total, onClick} = props;
  9. const handleClick = (e) => {
  10. if (onClick) {
  11. onClick(e);
  12. }
  13. }
  14. return (
  15. <View className={style['qu-board-title']} onClick={handleClick}>
  16. <Icon name="weapp-nav" size={60} color="var(--main-bg-color)" />
  17. <Text>{cursor + 1}</Text>
  18. <Text> / </Text>
  19. <Text>{total}</Text>
  20. </View>
  21. )
  22. }
  23. export default (props) => {
  24. const { value = 0, list, onChange } = props;
  25. const [show, setShow] = React.useState(false);
  26. const handleClick = (e, inx) => {
  27. e.stopPropagation();
  28. setShow(false);
  29. if (onChange) {
  30. onChange(inx);
  31. }
  32. }
  33. return (
  34. <View className={style['qu-board-bar']}>
  35. <Bar cursor={value} total={list?.length} onClick={() => setShow(true)} />
  36. <Popup position="bottom" show={show} onClose={() => setShow(false)}>
  37. <View className={style['qu-board-wrapper']}>
  38. <Bar cursor={value} total={list?.length} />
  39. <View className={style['qu-board-bd']}>
  40. {
  41. list?.map((it, inx) => {
  42. const cls = [
  43. style['qu-board-bd-item'],
  44. it?.finished ? style['qu-board-bd-active'] : false,
  45. ].filter(Boolean).join(' ')
  46. return (
  47. <RatioView key={inx}>
  48. <View className={cls} onClick={e => handleClick(e, inx)}>{inx + 1}</View>
  49. </RatioView>
  50. )
  51. })
  52. }
  53. </View>
  54. </View>
  55. </Popup>
  56. </View>
  57. )
  58. }