$(function () {
  function loadSectionHtml(sectionsData) {

    var loadHtmlArr = [
      // "cover", //封面
      // "preface", //前言
      "section_1",
      // "section_2",
      // "section_3",
      // "section_4",
      // "section_5",
    ];
    $(".pdf_root").html(loadHtmlArr.map(function (htmlName) {
      return "<div class='" + htmlName + "_html_root'></div>";
    }).join(""));
    loadHtmlArr.forEach(function (htmlName) {
      // 考试概况ksgk, 成绩分析cjfx, 成绩分析-等级分析djfx, 违纪分析wjfx, 优秀试卷yxsj
      if (htmlName === "cover") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.ksgk));
      } else if (htmlName === "preface") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData));
      } else if (htmlName === "section_1") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData));
      } else if (htmlName === "section_2") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify({
          cjfx: sectionsData.cjfx,
          djfx: sectionsData.djfx
        }));
      } else if (htmlName === "section_3") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.wjfx));
      } else if (htmlName === "section_4") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.yxsj));
      } else if (htmlName === "section_5") {
        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.wjsj));
      }
      $("." + htmlName + "_html_root").load("../sections/" + htmlName + ".html");
    });
  }
  // 请求接口前缀
  var _pdfBaseurl = "https://schoolapitest.xhkjedu.com/";
  // 47.1.1pdf报告
  var _sexam_ers_pdf = _pdfBaseurl + "sexam/erc/pdf";
  $.ajax({
    type: "POST",
    url: _sexam_ers_pdf,
    data: JSON.stringify({
      examid: 2,
      classid:9666
    }),
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    success: function (data) {
      if (data.code === 0) {
        loadSectionHtml(data.obj);
      } else {
        alert(data.msg);
      }
    }
  });
});