ソースを参照

修改时判断结果隐显

wyq 4 年 前
コミット
c3426e288e
1 ファイル変更65 行追加42 行削除
  1. 65 42
      src/js/staticInfo.js

+ 65 - 42
src/js/staticInfo.js

@@ -115,11 +115,6 @@ function renderContent(list, contentWrapClassName) {
 function renderContentscale(list, contentWrapClassName, name) {
   var pushInfo = []
   var textType = []
-  // anchors = '<li><i></i><a href="#' + contentWrapClassName +
-  //   '">' + name + '</a></li><li class="anchor-line"></li>';
-  // str = '<p class="scaletitle">' + name + '</p>'
-  // $(`.${contentWrapClassName} .infos .infos-box`).append(str);
-  // $(`.${contentWrapClassName} .anchors ul`).append(anchors);
   for (var i = 0; i < list[0].detailList.length; i++) {
     var item = list[0].detailList[i];
     console.log(item.resultType)
@@ -234,13 +229,16 @@ function getcheck() {
     const domName = $(this).attr('name');
     const $radio = $(this);
     const id = $(this).parents('.contentList').data("id");
-    console.log($radio.data('waschecked'))
     if ($radio.data('waschecked') == true) {
       $radio.prop('checked', false);
       $("input:radio[name='" + domName + "']").data('waschecked', false);
       $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
       if (isclick) {
         getchecks()
+        $(".score").html('');
+        $(".result_title").html('');
+        $(".result").css('display', 'none')
+        $(".foot").css('display', 'none')
       }
     } else {
       $radio.prop('checked', true);
@@ -249,6 +247,11 @@ function getcheck() {
       $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
       if (isclick) {
         getchecks()
+        console.log(11)
+        $(".score").html('');
+        $(".result_title").html('');
+        $(".result").css('display', 'none')
+        $(".foot").css('display', 'none')
       }
     }
   });
@@ -259,8 +262,22 @@ function getcheck() {
     $radio.parents('.contentList').each(function (i) {
       if ($(this).find('input[type="checkbox"]:checked').val() == undefined){
         $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
+        if (isclick) {
+          getchecks()
+          $(".score").html('');
+          $(".result_title").html('');
+          $(".result").css('display', 'none')
+          $(".foot").css('display', 'none')
+        }
       }else{
         $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
+        if (isclick) {
+          getchecks()
+          $(".score").html('');
+          $(".result_title").html('');
+          $(".result").css('display', 'none')
+          $(".foot").css('display', 'none')
+        }
       }
     })
   });
@@ -306,7 +323,7 @@ function getResult(pushInfo, textType) {
     let num = 0
     let result
     let key = false
-    isclick = true
+    
     $(".contentList").each(function (i) {
       if ($(this).find('input[type="radio"]:checked').val() == undefined && $(this).find('.radio_type').attr('disabled') == undefined) {
         $(this).find(".item-title").addClass('chColor');
@@ -320,6 +337,7 @@ function getResult(pushInfo, textType) {
       }
     });
     if (!$(".contentList").find(".item-title").hasClass('chColor') && !$(".contentList").find(".item-titles").hasClass('chColor')) {
+      isclick = true
       $('input[type="radio"]:checked').each(function () {
         if (Number($(this).val())) {
           num += parseFloat($(this).val())
@@ -335,11 +353,9 @@ function getResult(pushInfo, textType) {
         }
       });
       tmp = arr.join(";");
-
       if (pushInfo.length > 0) {
         for (var i = 0; i < pushInfo.length; i++) {
           if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min) {
-
             if (tmp) {
               if (num == 0) {
                 result = pushInfo[i].result + ';' + tmp
@@ -353,43 +369,51 @@ function getResult(pushInfo, textType) {
                 result = pushInfo[i].result + '(' + num + '分' + ')'
               }
             }
-            $(".result").css('display', 'block')
-            $(".copy").css('display', 'block')
-          } else {
+          } else{
             if (tmp) {
               result = tmp
-              $(".result").css('display', 'block')
-              $(".copy").css('display', 'block')
-            } else {
-              $(".result").css('display', 'none')
-              $(".copy").css('display', 'none')
-            }
-
-          }
+            } 
+          } 
         }
       } else {
-        if (tmp) {
-          result = tmp
-          $(".result").css('display', 'block')
-          $(".copy").css('display', 'block')
-        } else {
-          $(".result").css('display', 'none')
-          $(".copy").css('display', 'none')
-        }
+        result = tmp
       }
-      $(".result_title").attr({
-        "title": result
-      });
-      $(".hel").attr({
-        "title": result
-      });
-      $(".result_title").html(result);
-      if ($.inArray(13, textType) > 0) {
-        $(".score").html('总分:' + num + '分');
+      if (result == undefined){
+        if ($.inArray(13, textType) > 0) {
+          $(".score").html('总分:' + num + '分');
+        }
+        $(".score").css('display', 'block')
+        $(".copy").css('display', 'none')
+        $(".foot").css('display', 'block')
+      }else{
+        $(".result_title").attr({
+          "title": result
+        });
+        $(".hel").attr({
+          "title": result
+        });
+        $(".result_title").html(result);
+        if ($.inArray(13, textType) > 0) {
+          $(".score").html('总分:' + num + '分');
+        }
+        $(".result").css('display', 'block')
+        $(".score").css('display', 'block')
+        $(".copy").css('display', 'block')
+        $(".foot").css('display', 'block')
       }
-      $(".score").css('display', 'block')
-      $(".result").css('display', 'block')
-      $(".foot").css('display', 'block')
+      // $(".result_title").attr({
+      //   "title": result
+      // });
+      // $(".hel").attr({
+      //   "title": result
+      // });
+      // $(".result_title").html(result);
+      // if ($.inArray(13, textType) > 0) {
+      //   $(".score").html('总分:' + num + '分');
+      // }
+      // $(".result").css('display', 'block')
+      // $(".score").css('display', 'block')
+      // $(".foot").css('display', 'block')
     } else {
       Toast('温馨提示:必填选项不能为空~', 500)
     }
@@ -435,14 +459,13 @@ function renderTab(detailList, scale) {
   }
   let defaultModuleName
 
-  if (getUrlArgObject('page') && getUrlArgObject('page') == 1 && scale) {
+  if ((getUrlArgObject('page') && getUrlArgObject('page') == 1 && scale) || !detailList['静态知识']) {
     $(".tabList .tab").eq(1).addClass("activeTab")
     defaultModuleName = $(".tabList .tab").eq(1).attr("data-module")
   } else {
     $(".tabList .tab").eq(0).addClass("activeTab")
     defaultModuleName = $(".tabList .tab").eq(0).attr("data-module")
   }
-
   $(`.${defaultModuleName}`).css("display", "block")
   bindTabClick()
 }