const loopExp = async () => {
  if (distance_list.value[step_form.value.select_distance] === undefined) return;

  const performExperiment = async (method) => {
    const params = {
      position_index: distance_list.value[step_form.value.select_distance]['val'],
      rotate_index: method
    };
    let res = await readyShiYan(params);
    if (!res.data) {
      let res2 = await start_experiment2();
      return res2.data;
    }
    return false;
  };

  const updateExperimentData = async () => {
    let methodName = methods[step_form.value.select_method];
    let experimentResult = await performExperiment(step_form.value.select_method);

    if (experimentResult) {
      exp_data.value[distance_list.value[step_form.value.select_distance]] = `${methodName}是`;

      if (methodName === '正立') {
        step_form.value.select_method = 1; // 进行倒置实验
        experimentResult = await performExperiment(step_form.value.select_method);
        if (experimentResult) {
          exp_data.value[distance_list.value[step_form.value.select_distance]] = `${methodName}是`;
        } else {
          exp_data.value[distance_list.value[step_form.value.select_distance]] = `${methodName}否`;
        }
      }
    } else {
      exp_data.value[distance_list.value[step_form.value.select_distance]] = `${methodName}否`;

      if (methodName === '正立') {
        step_form.value.select_method = 1; // 进行倒置实验
        experimentResult = await performExperiment(step_form.value.select_method);
        if (experimentResult) {
          exp_data.value[distance_list.value[step_form.value.select_distance]] = `${methodName}是`;
        } else {
          exp_data.value[distance_list.value[step_form.value.select_distance]] = `${methodName}否`;
        }
      }
    }

    step_form.value.select_method = 0; // 重置为正立
    step_form.value.select_distance++;
    if (distance_list.value[step_form.value.select_distance] !== undefined) {
      loopExp(); // 递归调用进行下一个实验
    }
  };

  await updateExperimentData();
};
