$(function () { var windowWidth = $(window).width(); function setRem () { var windowWidth = $(window).width(); if (windowWidth <= 750) { var fs = windowWidth/750 * 6.25 * 100; $('html').css('font-size', fs + '%'); // 1rem = 100px; } }; setRem(); $(window).resize(setRem); // 举报 单选 $("#reportModal .report ul li").click(function () { $("#reportModal .report ul li").find(".icon").removeClass("icon-radio-checked").siblings("input[type=radio]").prop("checked", false); $(this).find(".icon").addClass("icon-radio-checked").siblings("input[type=radio]").prop("checked", true); // console.log($("#reportModal :checked").val()); }); // 举报保存 $("#reportModal .report .save").click(function () { var checkedRadio = $("#reportModal .report ul"); var textarea = $("#reportModal .report textarea"); var email = $("#reportModal .report input[name=email]"); var emailValidation = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/; if (checkedRadio.find(":checked").length > 0) { checkedRadio.parents(".form-group").removeClass("form-error"); } else { checkedRadio.parents(".form-group").addClass("form-error"); } if (textarea.val().length > 0) { textarea.parents(".form-group").removeClass("form-error"); } else { textarea.parents(".form-group").addClass("form-error"); } if (emailValidation.test(email.val())) { email.parents(".form-group").removeClass("form-error"); } else { email.parents(".form-group").addClass("form-error"); } var errorLength = $("#reportModal .report .form-error").length; if (errorLength > 0) { $("#reportModal").modal("show"); $("#reportSuccess").modal("hide"); } else { $("#reportModal").modal("hide"); $("#reportSuccess").modal("show"); } }); $("body").css("padding-top", 0); }); function screenWidthFun() { // 截图宽度 var screenWidth = 0; $(".template-common .app-screen ul li").each(function () { var $img = $(this).find("img"); var ml = parseInt($(this).css("margin-right")); var imgWidth = 0; if ($img.get(0).complete) { // $img.css("width", $img.width()); // imgWidth = parseInt($img.css("width")) + 20; imgWidth = $img.width() + ml; screenWidth += imgWidth; $(".template-common .app-screen ul").width(screenWidth + 5); // console.log("图片已加载"); // console.log("imgWidth: " + imgWidth); // console.log("screenWidth " + screenWidth); } else { $img.load(function () { // $(this).css("width", this.width); // imgWidth = parseInt($img.css("width")) + 20; imgWidth = $(this).width() + ml; screenWidth += imgWidth; $(".template-common .app-screen ul").width(screenWidth + 5); // console.log("图片未加载"); // console.log("imgWidth: " + imgWidth); // console.log("screenWidth " + screenWidth); }); } }); }; screenWidthFun(); // 弹窗 var Modal = function() { // Modal为匿名函数执行完的返回值 function templateModal(obj) { $("#templateModal").remove(); var templateModalHtml = '