$(function() { var parameter = $(".section_2_html_root").data("page-params"); parameter = JSON.parse(parameter); var sectionsHtmlArr = [ // "section_2_class_all", "section_2_class_single", // "section_2_level", // "section_2_part", // "section_2_lin_all", // "section_2_lin_single", // "section_2_excellent_all" ]; $(".section_2.score_analysis_root").html(sectionsHtmlArr.map(function (htmlName) { return "
"; }).join("")); var cjfx = parameter.cjfx; var djfx = parameter.djfx; var class_all_arr = []; var class_single_arr = []; for (var s_key in cjfx) { var s_item = cjfx[s_key]; if (s_key === "总分") { class_all_arr = s_item; } else { class_single_arr.push({ subjectname: s_key, arr: s_item }); } } sectionsHtmlArr.forEach(function(htmlName) { if (htmlName === "section_2_class_all") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify({ subjectname: "全科", arr: class_all_arr })); } else if (htmlName === "section_2_class_single") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify(class_single_arr)); } else if (htmlName === "section_2_level") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify({ cjfx: parameter.cjfx, djfx: parameter.djfx })); } else if (htmlName === "section_2_part") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify({ cjfx: parameter.cjfx, djfx: parameter.djfx })); } else if (htmlName === "section_2_lin_all") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify({ cjfx: parameter.cjfx, djfx: parameter.djfx })); } else if (htmlName === "section_2_lin_single") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify({ cjfx: parameter.cjfx, djfx: parameter.djfx })); } else if (htmlName === "section_2_excellent_all") { $(".section_2.score_analysis_root ." + htmlName + "_html_root").data("page-params", JSON.stringify({ cjfx: parameter.cjfx, djfx: parameter.djfx })); } $(".section_2.score_analysis_root ." + htmlName + "_html_root").load("./sections/scoreAnalysis/" + htmlName + ".html"); }); });