|
@@ -181,9 +181,10 @@ 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"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName + i +
|
|
|
+ str = '<div class="infoBox scaleBox" data-id="' + item.id + '"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName + i +
|
|
|
'">'
|
|
|
str += item.content
|
|
|
str += '</h2></div>'
|
|
@@ -194,21 +195,36 @@ function renderContentscale(list, contentWrapClassName, name) {
|
|
|
for (var k = 0; k < items.detailList.length; k++) {
|
|
|
var it = items.detailList[k];
|
|
|
it.content = it.content && it.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
|
|
|
- str = '<div class="contentList"><div class="item-list">';
|
|
|
- str += '<p class="item-title">' + it.content + '</p>'
|
|
|
+ str = '<div class="contentList" data-id="' + it.parentId + '"><div class="item-list">';
|
|
|
+ if (it.selectType == 1) {
|
|
|
+ str += '<p class="item-title">' + it.content + '</p>'
|
|
|
+ } else if (it.selectType == 2) {
|
|
|
+ str += '<p class="item-titles">' + it.content + '</p>'
|
|
|
+ }
|
|
|
+
|
|
|
str += '<div class="item-content" data-id="' + it.id + '">'
|
|
|
str += '</div></div></div>'
|
|
|
- $(`.${contentWrapClassName} .infos .infos-box .infoWrapper .infoBox`).append(str);
|
|
|
+ $(".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];
|
|
|
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 && item.resultType == 1) {
|
|
|
+ str += '<label><input class="radio_type" type="checkbox" name="scale' + its.parentId + '" value="' + its.score + '"/>'
|
|
|
+ } else if (it.selectType == 2 && item.resultType == 1) {
|
|
|
+ str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.score + '" />'
|
|
|
+ } else if (it.selectType == 1 && item.resultType == 2) {
|
|
|
+ str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.result + '" data_obj="' + its.result + '"/>'
|
|
|
+ } else if (it.selectType == 2 && item.resultType == 2) {
|
|
|
+ str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.result + '" data_obj="' + its.result + '"/>'
|
|
|
+ }
|
|
|
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>`
|
|
|
- $(".scale .infos .infos-box .infoWrapper .infoBox .contentList .item-content[data-id=" + its.parentId + "]").append(str);
|
|
|
+ $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "] .contentList .item-content[data-id=" + its.parentId + "]").append(str);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -236,7 +252,6 @@ function renderContentscale(list, contentWrapClassName, name) {
|
|
|
// $(`.${contentWrapClassName} .infos`).after(str);
|
|
|
function addScrollEvent() {
|
|
|
var scrollTop = $(`.${contentWrapClassName} .infos .infos-box`).scrollTop()
|
|
|
-
|
|
|
var divHeight = 0;
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
divHeight = divHeight + parseInt($('#' + contentWrapClassName + i).css('height')) + parseInt($('#' + contentWrapClassName + i).parent().next().css('height')) + 20
|
|
@@ -291,6 +306,9 @@ function getcheck() {
|
|
|
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(); // 选中文本
|
|
@@ -305,33 +323,68 @@ function copy() {
|
|
|
}
|
|
|
|
|
|
function getResult(pushInfo) {
|
|
|
-
|
|
|
$(".but").click(function () {
|
|
|
let arr = [];
|
|
|
let num = 0
|
|
|
+ let result
|
|
|
+ let key = false
|
|
|
$(".contentList").each(function (i) {
|
|
|
- if (Number(parseFloat($(this).find('input[type="radio"]:checked').val()))) {
|
|
|
- num += parseFloat($(this).find('input[type="radio"]:checked').val())
|
|
|
+ if ($(this).find('input[type="radio"]:checked').val() == undefined) {
|
|
|
+ $(this).find(".item-titles").addClass('chColor');
|
|
|
+ } else {
|
|
|
+ $(this).find(".item-titles").removeClass('chColor');
|
|
|
}
|
|
|
- })
|
|
|
- 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 ($(this).find('input[type="checkbox"]:checked').val() == undefined) {
|
|
|
+ $(this).find(".item-title").addClass('chColor');
|
|
|
+ } else {
|
|
|
+ $(this).find(".item-title").removeClass('chColor');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!$(".contentList").find(".item-title").hasClass('chColor')) {
|
|
|
+ $('input[type="radio"]:checked').each(function () {
|
|
|
+ if (Number($(this).val())) {
|
|
|
+ num += parseFloat($(this).val())
|
|
|
+ } else {
|
|
|
+ arr.push($(this).attr("data_obj"))
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('input[type="checkbox"]:checkbox:checked').each(function () {
|
|
|
+ if (Number($(this).val())) {
|
|
|
+ num += parseFloat($(this).val())
|
|
|
+ } else {
|
|
|
+ arr.push($(this).attr("data_obj"))
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tmp = arr.join(",");
|
|
|
+ if (pushInfo.length > 0) {
|
|
|
+ for (var i = 0; i < pushInfo.length; i++) {
|
|
|
+ if (pushInfo[i].content.max >= num >= pushInfo[i].content.min) {
|
|
|
+ if (tmp) {
|
|
|
+ result = pushInfo[i].result + ',' + tmp
|
|
|
+ } else {
|
|
|
+ result = pushInfo[i].result
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log(11)
|
|
|
+ result = tmp
|
|
|
}
|
|
|
- }
|
|
|
- $(".score").html('总分:' + num + '分');
|
|
|
- $(".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);
|
|
|
+ $(".score").html('总分:' + num + '分');
|
|
|
+ $(".score").css('display', 'block')
|
|
|
+ $(".result").css('display', 'block')
|
|
|
+ $(".foot").css('display', 'block')
|
|
|
+ } else {
|
|
|
+ Toast('温馨提示:必填选项不能为空~', 5000000000)
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
$(".printing").hover(
|