$(function () { $("#getLeadsForWhitePaper-modal-title-mobile-assist2").css("display", "none"); $("#getLeadsForWhitePaper-modal-title-mobile-assist1s").css( "display", "block" ); var mobile = window.isMobile(); var prefix = mobile ? ".getLeadsForWhitePaper-modal.mobile-flag " : ".getLeadsForWhitePaper-modal "; $(prefix + ".getLeadsForWhitePaper-modal-check").click(function () { $(prefix + ".getLeadsForWhitePaperCheck").removeClass("error"); if ($(this).hasClass("active")) { $(this).removeClass("active"); } else { $(this).addClass("active"); } }); $(prefix + ".getLeadsForWhitePaperName input").on("input", function () { $(prefix + ".getLeadsForWhitePaperName").removeClass("error"); }); $(prefix + ".getLeadsForWhitePaperCorpName input").on("input", function () { $(prefix + ".getLeadsForWhitePaperCorpName").removeClass("error"); }); $(prefix + ".getLeadsForWhitePaperPhone input").on("input", function () { $(prefix + ".getLeadsForWhitePaperPhone").removeClass("error"); }); function checkName() { const userName = $(prefix + ".getLeadsForWhitePaperName input").val(); if (!userName) { $(prefix + ".getLeadsForWhitePaperName").addClass("error"); $( prefix + ".getLeadsForWhitePaperName .getLeadsForWhitePaper-item-error" ).html("请输入姓名"); return false; } return userName; } function checkCorp() { const corpName = $(prefix + ".getLeadsForWhitePaperCorpName input").val(); if (!corpName) { $(prefix + ".getLeadsForWhitePaperCorpName").addClass("error"); $( prefix + ".getLeadsForWhitePaperCorpName .getLeadsForWhitePaper-item-error" ).html("请输入企业全称"); return false; } return corpName; } function checkPhone() { const mobileNumber = $(prefix + ".getLeadsForWhitePaperPhone input").val(); if (!mobileNumber) { $(prefix + ".getLeadsForWhitePaperPhone").addClass("error"); $( prefix + ".getLeadsForWhitePaperPhone .getLeadsForWhitePaper-item-error" ).html("请输入手机号"); return false; } else if (!/^1[23456789]\d{9}$/.test(mobileNumber)) { $(prefix + ".getLeadsForWhitePaperPhone").addClass("error"); $( prefix + ".getLeadsForWhitePaperPhone .getLeadsForWhitePaper-item-error" ).html("请输入正确的手机号"); return false; } return mobileNumber; } $(prefix + ".getLeadsForWhitePaperName input").blur(checkName); $(prefix + ".getLeadsForWhitePaperCorpName input").blur(checkCorp); $(prefix + ".getLeadsForWhitePaperPhone input").blur(checkPhone); $(prefix + ".getLeadsForWhitePaperModalBtn").click(function () { const userName = checkName(); const corpName = checkCorp(); const mobileNumber = checkPhone(); let errorFlag = [userName, corpName, mobileNumber].some((v) => v === false); // 没有问题,通过 if (!errorFlag) { let spmPoint = window.location.href.includes("customer-case") ? "288.1.0.2" : "288.0.0.1"; if (isMobile()) { spmPoint = "288.0.0.3"; } window.spm(spmPoint); var params = { userName, mobileNumber, corpName, type: 0, flowCrm: true, originType: "制造白皮书_ddw", }; $.ajax({ type: "POST", url: window.reqHost + "/home/open/saveVipInfo", data: JSON.stringify(params), contentType: "application/json", success: function (res) { if (mobile) { try { document.documentElement.scrollTop = 0; } catch (error) {} $(prefix).addClass("success"); $(prefix + ".getLeadsForWhitePaper-modal-right").css( "display", "none" ); $(prefix + ".getLeadsForWhitePaper-modal-right-ok").css( "display", "block" ); } else { $(prefix + ".getLeadsForWhitePaper-modal-right").css( "display", "none" ); $(prefix + ".getLeadsForWhitePaper-modal-right-ok").css( "display", "block" ); } window.spm("288.0.0.4"); if (mobile){ const link = document.createElement('a'); link.href = 'https://rlj-cdn.oss-cn-hangzhou.aliyuncs.com/files/%E7%99%BD%E7%9A%AE%E4%B9%A62.20.pdf'; link.download = '%E7%99%BD%E7%9A%AE%E4%B9%A62.20.pdf'; document.body.appendChild(link); link.click(); document.body.removeChild(link); }else { setTimeout(()=>{ window.open("https://rlj-cdn.oss-cn-hangzhou.aliyuncs.com/files/%E7%99%BD%E7%9A%AE%E4%B9%A62.20.pdf") },2000) } }, }); } }); });