function layeralert(title, text) { layui.use('layer', function () { var layer = layui.layer; layer.open({ title: title, content: text }) }) } function layeralert2(title, text, url) { layui.use('layer', function () { var layer = layui.layer; layer.open({ title: title, content: text, yes: function () { linkto(url); } }) }) } function layeralerte(title, text) { layui.use('layer', function () { var layer = layui.layer; layer.open({ title: title, content: text, btn: ['OK'] }) }) } var emailRule = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; var phoneRule = /^(13|14|15|16|17|18|19)[0-9]{9}$/; var telRule = /^0\d{2,3}-?\d{7,8}$/; function linkto(url) { location.href = url; } function buildding() { layeralert("提示", "此项暂未上传附件!"); } function buildding1() { layeralert("提示", "正在完善中!"); } function ebuildding1() { layeralert("Tips", "Under improvement!"); } //产品弹窗留言咨询 function adprodmsg(sourec,names) { var name = $("#name").val(); var company = $("#company").val(); var bm = $("#bm").val(); var zhiwei = $("#zhiwei").val(); var yjfx = $("#yjfx").val(); var youxi = $("#youxi").val(); var tels = $("#tels").val(); var nums = $("#nums").val(); var lynr = $("#lynr").val(); if (name == "") { document.getElementById("name").setAttribute("placeholder", "请输入姓名"); return } if (company == "") { document.getElementById("company").setAttribute("placeholder", "请输入公司名称"); return } if (bm == "") { document.getElementById("bm").setAttribute("placeholder", "请输入部门"); return } if (zhiwei == "") { document.getElementById("zhiwei").setAttribute("placeholder", "请输入职位"); return } if (yjfx == "") { document.getElementById("yjfx").setAttribute("placeholder", "请输入研究方向"); return } if (youxi == "") { document.getElementById("youxi").setAttribute("placeholder", "请输入邮箱"); return } if (!emailRule.test(youxi)) { document.getElementById('youxi').placeholder = ''; document.getElementById("youxi").value = ""; document.getElementById("youxi").setAttribute("placeholder", "您输入的邮箱格式有误"); return } if (tels == "") { document.getElementById("tels").setAttribute("placeholder", "请输入电话"); return } if (!phoneRule.test(tels) && !telRule.test(tels)) { document.getElementById('tels').placeholder = ''; document.getElementById("tels").value = ""; document.getElementById("tels").setAttribute("placeholder", "您输入的电话格式有误"); return } if (nums == "") { document.getElementById("nums").setAttribute("placeholder", "请输入货号"); return } $.ajax({ type: "post", url: "/AjaxAction/tj.ashx?action=prolyb&m=" + names + "&sourec=" + sourec + "&name=" + name + "&company=" + company + "&bm=" + bm + "&zhiwei=" + zhiwei + "&yjfx=" + yjfx + "&youxi=" + youxi + "&tels=" + tels + "&nums=" + nums + "&lynr=" + lynr, data: "", success: function (data) { if (data == "1") { layeralert("提示", "恭喜,您的留言已提交成功,我们会尽快联系您"); // setTimeout(function () { window.location.href = document.URL; }, 3000);//延时3秒 setTimeout("location.href = document.URL", 3000);//延时3秒 } else { layeralert("提示", "抱歉,您的留言提交失败,请重新尝试!"); } } }); } //产品联系信箱 function adproinfomsg(strm) { var shuoming = $("#shuoming").val(); var name = $("#name").val(); var tels = $("#tels").val(); var youxi = $("#youxi").val(); var gsname = $("#gsname").val(); var dizhi = $("#dizhi").val(); var code = $("#code").val(); if (shuoming == "") { document.getElementById("shuoming").setAttribute("placeholder", "询价说明不能为空"); return } if (name == "") { document.getElementById("name").setAttribute("placeholder", "请输入联系人"); return } if (tels == "") { document.getElementById("tels").setAttribute("placeholder", "请输入手机号码"); return } if (!phoneRule.test(tels) && !telRule.test(tels)) { document.getElementById('tels').placeholder = ''; document.getElementById("tels").value = ""; document.getElementById("tels").setAttribute("placeholder", "您输入的手机号码格式有误"); return } if (youxi == "") { document.getElementById("youxi").setAttribute("placeholder", "请输入邮箱号码"); return } if (!emailRule.test(youxi)) { document.getElementById('youxi').placeholder = ''; document.getElementById("youxi").value = ""; document.getElementById("youxi").setAttribute("placeholder", "您输入的邮箱格式有误"); return } if (gsname == "") { document.getElementById("gsname").setAttribute("placeholder", "请输入企业名称"); return } if (dizhi == "") { document.getElementById("dizhi").setAttribute("placeholder", "请输入详细地址"); return } if (code == "") { document.getElementById("zhiwei").setAttribute("placeholder", "请输入验证码"); return } if (code == "" || code == "验证码不正确") { document.getElementById("zhiwei").setAttribute("placeholder", "请输入验证码"); return } if (!(code == getCookie("CheckCode"))) { document.getElementById('code').placeholder = ''; document.getElementById("code").value = ""; document.getElementById("code").setAttribute("placeholder", "验证码不正确"); return false; } //$.ajax({ // type: "post", // url: "/AjaxAction/tj.ashx?action=prolyb&m=" + names + "&sourec=" + sourec + "&name=" + name + "&company=" + company + "&bm=" + bm + "&zhiwei=" + zhiwei + "&yjfx=" + yjfx + "&youxi=" + youxi + "&tels=" + tels + "&nums=" + nums + "&lynr=" + lynr, // data: "", // success: function (data) { // if (data == "1") { // layeralert("提示", "恭喜,您的留言已提交成功,我们会尽快联系您"); // // setTimeout(function () { window.location.href = document.URL; }, 3000);//延时3秒 // setTimeout("location.href = document.URL", 3000);//延时3秒 // } // else { // layeralert("提示", "抱歉,您的留言提交失败,请重新尝试!"); // } // } //}); } //留言咨询 function addmsg(strname) { var name = $("#name").val(); var jigou = $("#institution").val(); var bm = $("#department").val(); var yjfx = $("#direction").val(); var tels = $("#Tel").val(); var youxi = $("#EMail").val(); var ly = $('#lytypes option:selected').text(); var lynr = $("#Intro").val(); if (name == "") { layeralert("提示", "请输入您的姓名"); return } if (ly == "" || ly == "请选择留言类别") { layeralert("提示", "请选择留言类别"); return } if (tels != "") { if (!phoneRule.test(tels) && !telRule.test(tels)) { layeralert("提示", "您输入的电话号码有误"); return } } if (youxi != "") { if (!emailRule.test(youxi)) { layeralert("提示", "您输入的的邮箱格式有误"); return } } if (lynr == "") { layeralert("提示", "请输入您的留言内容"); return } $.ajax({ type: "post", url: "/AjaxAction/tj.ashx?action=lyb&sourec=" + strname + "&name=" + name + "&jigou=" + jigou + "&bm=" + bm + "&yjfx=" + yjfx + "&tels=" + tels + "&youxi=" + youxi + "&ly=" + ly + "&lynr=" + lynr, data: "", success: function (data) { if (data == "1") { layeralert("提示", "恭喜,您的留言已提交成功,我们会尽快联系您"); // setTimeout(function () { window.location.href = document.URL; }, 3000);//延时3秒 setTimeout("location.href = document.URL", 3000);//延时3秒 } else { layeralert("提示", "抱歉,您的留言提交失败,请重新尝试!"); } } }); } //底部留言咨询 function addmsgfoot(strname) { var name = $("#namef").val(); var jigou = $("#institutionf").val(); var bm = $("#departmentf").val(); var yjfx = $("#directionf").val(); var tels = $("#Telf").val(); var youxi = $("#EMailf").val(); var ly = $('#lytypestwo option:selected').text(); var lynr = $("#Introf").val(); if (name == "") { layeralert("提示", "请输入您的姓名"); return } if (ly == "" || ly == "请选择留言类别") { layeralert("提示", "请选择留言类别"); return } if (tels != "") { if (!phoneRule.test(tels) && !telRule.test(tels)) { layeralert("提示", "您输入的电话号码有误"); return } } if (youxi != "") { if (!emailRule.test(youxi)) { layeralert("提示", "您输入的的邮箱格式有误"); return } } if (lynr == "") { layeralert("提示", "请输入您的留言内容"); return } $.ajax({ type: "post", url: "/AjaxAction/tj.ashx?action=lyb&sourec=" + strname + "&name=" + name + "&jigou=" + jigou + "&bm=" + bm + "&yjfx=" + yjfx + "&tels=" + tels + "&youxi=" + youxi + "&ly=" + ly + "&lynr=" + lynr, data: "", success: function (data) { if (data == "1") { layeralert("提示", "恭喜,您的留言已提交成功,我们会尽快联系您"); // setTimeout(function () { window.location.href = document.URL; }, 3000);//延时3秒 setTimeout("location.href = document.URL", 3000);//延时3秒 } else { layeralert("提示", "抱歉,您的留言提交失败,请重新尝试!"); } } }); } //COA查询 //function serchernum(m) { // var huonum = $("#huonum").val(); // var picinum = $("#picinum").val(); // //if (huonum == "" ) { // // layeralert("提示", "请输入产品货号"); // // return // //} // //if (layeralert == "") { // // layeralert("提示", "请输入产品批次号"); // // return // //} // if (huonum == "" && picinum == "") { // layeralert("提示", "请输入产品货号或者产品批次号"); // return // } // $.ajax({ // url: "/AjaxAction/jz.ashx?action=coa&m=" + m + "&huonum=" + huonum + "&picinum=" + picinum, // type: "get", // data: "", // dataType: "json", // success: function (data) { // if (data.code == "1") { // //var hreflj = data.f; // //window.open(hreflj, '_blank') // var hreflj = data.f; // var timestamp = new Date().getTime(); // var index = hreflj.lastIndexOf("\."); // var hzm = hreflj.substring(index + 1, hreflj.length); // //download("COA下载" + "." + hzm, hreflj); // download("" + data.mingchen + "" + "." + hzm, hreflj); // } // else if (data.code == "2") { // layeralert("提示", "该产品货号和批次号未上传相关附件"); // } // else if (data.code == "3") { // layeralert("提示", "未查询到该产品货号和批次号相关内容!"); // } // else { // layeralert("提示", "查询失败!"); // } // }, // error: function (xhr, type) { // layeralert("提示", "数据操作异常!"); // } // }); //} function download(name, href) { var a = document.createElement("a"), //创建a标签 e = document.createEvent("MouseEvents"); //创建鼠标事件对象 e.initEvent("click", false, false); //初始化事件对象 //window.open(a.href, '_blank') a.href = href; //设置下载地址 a.download = name; //设置下载文件名 a.dispatchEvent(e); //给指定的元素,执行事件click事件 } //搜索 function search1() { if (document.getElementById("searchkey").value.replace(/(^\s*)|(\s*$)/g, "") == "") { layeralert("提示", "请输入关键字"); return; } else { window.location.href = "/search.html?k=" + $("#searchkey").val(); } } $(function () { $("#searchkey").keyup(function (event) { if (event.keyCode == 13) { //点击回车要执行的事件 if (document.getElementById("searchkey").value.replace(/(^\s*)|(\s*$)/g, "") == "") { layeralert("提示", "请输入关键字"); return; } else { window.location.href = "/search.html?k=" + $("#searchkey").val(); } } }) })