浏览代码

对接接口数据

wzl_h
wangzl 2 年前
父节点
当前提交
3a10d485bf
共有 8 个文件被更改,包括 58 次插入36 次删除
  1. 3
    0
      index.html
  2. 45
    26
      js/index.js
  3. 1
    1
      js/preface.js
  4. 5
    5
      js/scoreAnalysis/section_2_excellent_all.js
  5. 1
    1
      js/section_1.js
  6. 1
    1
      js/section_2.js
  7. 1
    1
      js/section_3.js
  8. 1
    1
      js/section_4.js

+ 3
- 0
index.html 查看文件

@@ -9,6 +9,9 @@
9 9
 </head>
10 10
 <body class="root_body">
11 11
   <div class="pdf_root"></div>
12
+  <script>
13
+    var _pdfBaseurl = "https://schoolapitest.xhkjedu.com/";
14
+  </script>
12 15
   <script src="./librarys/jquery@3.6.1/jquery.js"></script>
13 16
   <script src="./librarys/echarts@4.8.0/echarts.min.js"></script>
14 17
   <script src="./librarys/utils/index.js"></script>

+ 45
- 26
js/index.js 查看文件

@@ -1,30 +1,49 @@
1 1
 $(function () {
2
-  var loadHtmlArr = [
3
-    "cover",
4
-    "preface",
5
-    "section_1",
6
-    "section_2",
7
-    "section_3",
8
-    "section_4",
9
-  ];
10
-  $(".pdf_root").html(loadHtmlArr.map(function (htmlName) {
11
-    return "<div class='" + htmlName + "_html_root'></div>";
12
-  }).join(""));
13
-  loadHtmlArr.forEach(function (htmlName) {
14
-    if (htmlName === "preface") {
15
-      $("." + htmlName + "_html_root").data("page-params", JSON.stringify({
16
-        htmlName: htmlName,
17
-        subjectname: "语文",
18
-        num: 12
19
-      }));
20
-    } else if (htmlName === "section_1") {
21
-      $("." + htmlName + "_html_root").data("page-params", JSON.stringify({
22
-        htmlName: htmlName,
23
-        subjectname: "数学",
24
-        num: 33
25
-      }));
2
+  function loadSectionHtml(sectionsData) {
3
+    var loadHtmlArr = [
4
+      "cover",
5
+      "preface",
6
+      "section_1",
7
+      "section_2",
8
+      "section_3",
9
+      "section_4",
10
+    ];
11
+    $(".pdf_root").html(loadHtmlArr.map(function (htmlName) {
12
+      return "<div class='" + htmlName + "_html_root'></div>";
13
+    }).join(""));
14
+    loadHtmlArr.forEach(function (htmlName) {
15
+      // 考试概况ksgk, 成绩分析cjfx, 成绩分析-等级分析djfx, 违纪分析wjfx, 优秀试卷yxsj
16
+      if (htmlName === "preface") {
17
+        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData));
18
+      } else if (htmlName === "section_1") {
19
+        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.ksgk));
20
+      } else if (htmlName === "section_2") {
21
+        $("." + htmlName + "_html_root").data("page-params", JSON.stringify({
22
+          cjfx: sectionsData.cjfx,
23
+          djfx: sectionsData.djfx
24
+        }));
25
+      } else if (htmlName === "section_3") {
26
+        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.wjfx));
27
+      } else if (htmlName === "section_4") {
28
+        $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.yxsj));
29
+      }
30
+      $("." + htmlName + "_html_root").load("../sections/" + htmlName + ".html");
31
+    });
32
+  }
33
+  $.ajax({
34
+    type: "POST",
35
+    url: _pdfBaseurl + "sexam/ers/pdf",
36
+    data: JSON.stringify({
37
+      examid: 2
38
+    }),
39
+    dataType: "json",
40
+    contentType: "application/json; charset=utf-8",
41
+    success: function (data) {
42
+      if (data.code === 0) {
43
+        loadSectionHtml(data.obj);
44
+      } else {
45
+        alert(data.msg);
46
+      }
26 47
     }
27
-    console.log(htmlName);
28
-    $("." + htmlName + "_html_root").load("../sections/" + htmlName + ".html");
29 48
   });
30 49
 });

+ 1
- 1
js/preface.js 查看文件

@@ -1,5 +1,5 @@
1 1
 $(function() {
2 2
   // outerHeight(true) 高度为 height+margin+padding+border
3 3
   var parameter = $(".preface_html_root").data("page-params");
4
-  console.log("preface:parameter", parameter);
4
+  console.log("preface:parameter", JSON.parse(parameter));
5 5
 });

+ 5
- 5
js/scoreAnalysis/section_2_excellent_all.js 查看文件

@@ -1,11 +1,11 @@
1 1
 $(function () {
2 2
   // 优秀生、学困生统计
3 3
   function initClassExcellenceEcharts() {
4
-    let legend_data = ["优秀生", "学困生"];
5
-    let xAxis_data = ["全部班级", "九年级一班", "九年级二班"];
6
-    let series_data1 = [10, 6, 4];
7
-    let series_data2 = [-11, -11, -11];
8
-    let option = {
4
+    var legend_data = ["优秀生", "学困生"];
5
+    var xAxis_data = ["全部班级", "九年级一班", "九年级二班"];
6
+    var series_data1 = [10, 6, 4];
7
+    var series_data2 = [-11, -11, -11];
8
+    var option = {
9 9
       title: {
10 10
         text: "人",
11 11
         x: "left",

+ 1
- 1
js/section_1.js 查看文件

@@ -448,7 +448,7 @@ $(function () {
448 448
     myEcharts.setOption(option);
449 449
   }
450 450
   var parameter = $(".section_1_html_root").data("page-params");
451
-  console.log("section_1:parameter", parameter);
451
+  console.log("section_1:parameter", JSON.parse(parameter));
452 452
   initAverageScoreEcharts();
453 453
   initExcellenceRateEcharts();
454 454
   initExamnumEcharts();

+ 1
- 1
js/section_2.js 查看文件

@@ -1,7 +1,7 @@
1 1
 $(function() {
2 2
   // outerHeight(true) 高度为 height+margin+padding+border
3 3
   var parameter = $(".section_2_html_root").data("page-params");
4
-  console.log("section_2:parameter", parameter);
4
+  console.log("section_2:parameter", JSON.parse(parameter));
5 5
 
6 6
   var sectionsHtmlArr = [
7 7
     "section_2_class_all",

+ 1
- 1
js/section_3.js 查看文件

@@ -110,7 +110,7 @@ $(function () {
110 110
     myEcharts.setOption(option);
111 111
   }
112 112
   var parameter = $(".section_3_html_root").data("page-params");
113
-  console.log("section_3:parameter", parameter);
113
+  console.log("section_3:parameter", JSON.parse(parameter));
114 114
 
115 115
   initSubjectBadEcharts();
116 116
 });

+ 1
- 1
js/section_4.js 查看文件

@@ -110,7 +110,7 @@ $(function () {
110 110
     myEcharts.setOption(option);
111 111
   }
112 112
   var parameter = $(".section_4_html_root").data("page-params");
113
-  console.log("section_4:parameter", parameter);
113
+  console.log("section_4:parameter", JSON.parse(parameter));
114 114
 
115 115
   initSubjectGoodEcharts();
116 116
 });

正在加载...
取消
保存