Browse Source

Merge branch 'dynamicScale0609' into testNew

wyq 4 years ago
parent
commit
d02ba03cc0
1 changed files with 63 additions and 45 deletions
  1. 63 45
      src/js/staticInfo.js

+ 63 - 45
src/js/staticInfo.js

@@ -111,7 +111,7 @@ function renderContent(list, contentWrapClassName) {
 }
 
 function renderContentscale(list, contentWrapClassName, name) {
-  var pushInfo=[]
+  var pushInfo = []
   anchors = '<li><i></i><a href="#' + contentWrapClassName +
     '">' + name + '</a></li><li class="anchor-line"></li>';
   str = '<p class="scaletitle">' + name + '</p>'
@@ -119,6 +119,7 @@ function renderContentscale(list, contentWrapClassName, name) {
   $(`.${contentWrapClassName} .anchors ul`).append(anchors);
   for (var i = 0; i < list[0].detailList.length; i++) {
     var item = list[0].detailList[i];
+    console.log(item)
     if (item.textType == 11) {
       item.content = item.content && item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
       str = '<div class="infoBox scaleBox" data-id="' + item.id + '"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName + i +
@@ -139,22 +140,27 @@ function renderContentscale(list, contentWrapClassName, name) {
           $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "]").append(str);
           for (var l = 0; l < it.subList[0].detailList.length; l++) {
             var its = it.subList[0].detailList[l];
-            console.log(its.parentId)
             its.content = its.content && its.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
             str = '<div class="radio" name="scale' + its.parentId + '" value="' + its.score + '">';
-            str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.score + '" />'
+            if (it.selectType == 1) {
+              str += '<label><input class="radio_type" type="checkbox" name="scale' + its.parentId + '" type="radio" value="' + its.score + '" />'
+            } else if (it.selectType == 2) {
+              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.score + '" />'
+            }
             str += its.content
-            str += '<span class="num">' + '(' + its.score + ')' + '</span>'
+            if (item.resultType == 1) {
+              str += '<span class="num">' + '(' + its.score + ')' + '</span>'
+            }
             str += '</label>'
-            str += `${item.match ? `<img class="recommend" src=${recommend} />` : `` }</div>`
+            str += `${item.match ? `<img class="recommend" src=${recommend} />` : ``}</div>`
             $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "] .contentList .item-content[data-id=" + its.parentId + "]").append(str);
           }
         }
       }
-      
+
     }
-    if (item.textType == 13){
-      for (var m = 0; m < item.subList[0].detailList[0].subList[0].detailList.length; m++ ){
+    if (item.textType == 13) {
+      for (var m = 0; m < item.subList[0].detailList[0].subList[0].detailList.length; m++) {
         var itl = item.subList[0].detailList[0].subList[0].detailList[m]
         let arr = {
           content: JSON.parse(itl.content),
@@ -205,15 +211,13 @@ function getprinting() {
     }).jqprint();
     $('.foot').show()
     $('.hel').show()
-    
   })
-
 }
 
 function getcheck() {
   $('input:radio').click(function () {
-    var domName = $(this).attr('name');
-    var $radio = $(this);
+    const domName = $(this).attr('name');
+    const $radio = $(this);
     if ($radio.data('waschecked') == true) {
       $radio.prop('checked', false);
       $("input:radio[name='" + domName + "']").data('waschecked', false);
@@ -222,29 +226,41 @@ function getcheck() {
       $("input:radio[name='" + domName + "']").data('waschecked', false);
       $radio.data('waschecked', true);
     }
-    console.log("选中状态:", $(this).prop("checked"));
-    console.log($("input:radio[name='" + domName + "']:checked").val());
+  });
+  $('input:checkbox').click(function () {
+    const domName = $(this).attr('name');
+    const $radio = $(this);
+    if ($radio.data('waschecked') == true) {
+      $radio.prop('checked', false);
+      $("input:checkbox[name='" + domName + "']").data('waschecked', false);
+    } else {
+      $radio.prop('checked', true);
+      $("input:checkbox[name='" + domName + "']").data('waschecked', false);
+      $radio.data('waschecked', true);
+    }
   });
 }
 
 function copy() {
   $(".copy").click(function () {
     var texts = document.getElementById("result_title").innerText;
+    if (texts == '') {
+      return
+    }
     var inputs = document.getElementById("inputs");
     inputs.value = texts; // 修改文本框的内容(赋值内容)
     inputs.select(); // 选中文本
     document.execCommand("copy"); // 执行浏览器复制命令
     Toast('复制成功', 500)
-    setTimeout(()=>{
+    setTimeout(() => {
       window.close()
-    },500)
-    
+    }, 500)
+
   })
-  
+
 }
 
 function getResult(pushInfo) {
-
   $(".but").click(function () {
     let arr = [];
     let num = 0
@@ -253,33 +269,35 @@ function getResult(pushInfo) {
         num += parseFloat($(this).find('input[type="radio"]:checked').val())
       }
     })
+    $('input[type="checkbox"]:checkbox:checked').each(function () {
+      num += parseFloat($(this).val())
+    });
     for (var i = 0; i < pushInfo.length; i++) {
-      console.log(pushInfo[i])
-      if (pushInfo[i].content.max >= num >= pushInfo[i].content.min) {
-        $(".result_title").attr({
-          "title": pushInfo[i].result
-        });
-        $(".hel").attr({
-          "title": pushInfo[i].pushInfo
-        });
-        
-        $(".result_title").html(pushInfo[i].result);
-      }
+    if (pushInfo[i].content.max >= num >= pushInfo[i].content.min) {
+      $(".result_title").attr({
+        "title": pushInfo[i].result
+      });
+      $(".hel").attr({
+        "title": pushInfo[i].pushInfo
+      });
+
+      $(".result_title").html(pushInfo[i].result);
     }
-    $(".score").html('总分:' + num + '分');
-    $(".score").css('display', 'block')
-    $(".result").css('display', 'block')
-    $(".foot").css('display', 'block')
+  }
+  $(".score").html('总分:' + num + '分');
+  $(".score").css('display', 'block')
+  $(".result").css('display', 'block')
+  $(".foot").css('display', 'block')
 
-  })
+})
 
-  $(".printing").hover(
-    function () {
-      $(".slideImg").attr("src", printing2);
-    }, function () {
-      $(".slideImg").attr("src", printing);
+$(".printing").hover(
+  function () {
+    $(".slideImg").attr("src", printing2);
+  }, function () {
+    $(".slideImg").attr("src", printing);
 
-    });
+  });
 
 }
 
@@ -313,15 +331,15 @@ function renderTab(detailList, scale) {
     //$(".tabBox .title").html(noticeName);
   }
   let defaultModuleName
-  
-  if (getUrlArgObject('page') && getUrlArgObject('page') == 1 && scale){
+
+  if (getUrlArgObject('page') && getUrlArgObject('page') == 1 && scale) {
     $(".tabList .tab").eq(1).addClass("activeTab")
     defaultModuleName = $(".tabList .tab").eq(1).attr("data-module")
-  }else{
+  } else {
     $(".tabList .tab").eq(0).addClass("activeTab")
     defaultModuleName = $(".tabList .tab").eq(0).attr("data-module")
   }
-  
+
   $(`.${defaultModuleName}`).css("display", "block")
   bindTabClick()
 }