| | |
| | | const activeNormal = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/active-normal.png'; |
| | | const activeGood = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/active-good.png'; |
| | | const { visible, animationData } = useBottomPopupAnimation(show); |
| | | const [selectedTypeId, setSelectedTypeId] = useState<number | null>(null); // 当前选择的问题类型 |
| | | const [selectedTypeIds, setSelectedTypeIds] = useState<string[]>([]); // 当前选择的问题类型列表 |
| | | const [feedbackContent, setFeedbackContent] = useState(''); // 反馈文本内容 |
| | | const [typeOptions, setTypeOptions] = useState<any[]>([]); // 问题类型选项 |
| | | const isSubmittingRef = useRef(false); // 同步提交锁,防止快速重复点击导致的并发提交 |
| | |
| | | }; |
| | | const evaluateDimension = evaluateDimensionMap[currentOrderRating] || 3; // 接口维度:1 满意,2 一般,3 不满意 |
| | | const shouldRequireFeedbackType = !hideFeedbackType; |
| | | const canSubmit = shouldRequireFeedbackType ? !!selectedTypeId && !!feedbackContent.trim() : !!feedbackContent.trim(); |
| | | const canSubmit = shouldRequireFeedbackType ? selectedTypeIds.length > 0 && !!feedbackContent.trim() : !!feedbackContent.trim(); |
| | | const normalizeFeedbackTypeId = (typeId: unknown) => { |
| | | if (typeId === null || typeId === undefined || typeId === '') { |
| | | return ''; |
| | | } |
| | | return String(typeId); |
| | | }; |
| | | const toggleFeedbackType = (typeId: unknown) => { |
| | | const normalizedTypeId = normalizeFeedbackTypeId(typeId); |
| | | if (!normalizedTypeId) { |
| | | return; |
| | | } |
| | | setSelectedTypeIds((prev) => ( |
| | | prev.includes(normalizedTypeId) |
| | | ? prev.filter((id) => id !== normalizedTypeId) |
| | | : [...prev, normalizedTypeId] |
| | | )); |
| | | }; |
| | | |
| | | // 提交反馈(评价/投诉) |
| | | const submit = () => { |
| | | if (isSubmittingRef.current) { |
| | | return; |
| | | } |
| | | if (shouldRequireFeedbackType && !selectedTypeId) { |
| | | if (shouldRequireFeedbackType && selectedTypeIds.length === 0) { |
| | | Taro.showToast({ |
| | | title: '请选择问题类型', |
| | | icon: 'none' |
| | |
| | | feedbackPictures: picturePayload, |
| | | orderId: targetOrderId |
| | | }; |
| | | if (!hideFeedbackType && selectedTypeId) { |
| | | payload.feedbackTypeId = selectedTypeId; |
| | | if (!hideFeedbackType && selectedTypeIds.length > 0) { |
| | | payload.feedbackTypeId = selectedTypeIds.join(','); |
| | | } |
| | | submitter(payload).then((res: any) => { |
| | | const isFailure = res?.success === false || (typeof res?.code === 'number' && res.code !== 0); |
| | |
| | | if (!show) { |
| | | return; |
| | | } |
| | | setSelectedTypeId(null); |
| | | setSelectedTypeIds([]); |
| | | setFeedbackContent(''); |
| | | resetImages(); |
| | | getOrderCommentType(evaluateDimension).then((res: any) => { |
| | |
| | | <View className='evaluate-problem-type-title'>反馈的问题类型:</View> |
| | | <View className='evaluate-problem-type-content'> |
| | | {typeOptions.map((item) => ( |
| | | <View key={item?.id} className={`evaluate-problem-type-content-item ${selectedTypeId === item?.id && 'active-tag'}`} onClick={() => setSelectedTypeId(item?.id)}> |
| | | <View key={item?.id} className={`evaluate-problem-type-content-item ${selectedTypeIds.includes(normalizeFeedbackTypeId(item?.id)) && 'active-tag'}`} onClick={() => toggleFeedbackType(item?.id)}> |
| | | <Text className='evaluate-problem-type-content-item-text'>{item?.tagContent}</Text> |
| | | </View> |
| | | ))} |