import { useState, useEffect } from 'react' import '@/assets/css/iconfont.css' import { Image, Slider, Textarea } from '@tarojs/components' import './index.scss' import questions from './formData' export default function RentingHouse (props) { const { change = () => { }, toSubmit = () => {}, AreaInfo = {}, selectArea = () => {} } = props const [FormData, setFormData] = useState(questions) const [StepId, setStepId] = useState(1) const [StepRange, setStepRange] = useState([0, 4]) useEffect(() => { if(StepId === 1) { setStepRange([0, 4]) } else if(StepId === 2) { setStepRange([4, 6]) } change(StepId) }, [StepId]) const CutCheckbox = (item, index) => { return () => { let newFormData = [...FormData] newFormData[index].resultId = item.id newFormData[index].result = item.name setFormData([...newFormData]) } } const Rangehange = (e, index) => { let newFormData = [...FormData] newFormData[index].result = e.detail.value setFormData([...newFormData]) } const remarkInput = (e, index) => { let newFormData = [...FormData] newFormData[index].remark = e.detail.value setFormData([...newFormData]) } const textareaInput = (e, index) => { let newFormData = [...FormData] newFormData[index].result = e.detail.value setFormData([...newFormData]) } const NextStep = () => { if (StepId < 2) { setStepId(StepId + 1) } else { toSubmit(FormData) } } const PrevStep = () => { if (StepId > 1) { setStepId(StepId - 1) } } return ( { FormData.map((item, index) => ( { index >= StepRange[0] && index < StepRange[1] && {item.question} { item.type === 'checkbox' && { item.options.map((subItem, subIndex) => ( {subItem.name} )) } } { item.type === 'checkbox' && item.remark !== undefined &&