layui.use(['form'], function () { var form = layui.form(); form.on('select(layFields)', function (data) { OtherLingYuChange(data); }); //监听提交 form.on('submit(ProductQuery)', function (data) { SubmitProduct(data.field); return false; }); Get_localStorage(); form.render(); GetInitData(); GetProtocolsByProductID(1, 3); $('#ProductName').val(ClearHtml('.ProductTitle', 1)); }); //去除html标签 type=0 取val(), =1 取 html() function ClearHtml(IDOrClass, type) { var str = type == 1 ? $.trim($(IDOrClass).html()) : $.trim($(IDOrClass).val()); var data = str.replace(/<.*?>/ig, ''); return data; } function OtherLingYuChange(data) { if (data.value == '99') { $('.ddlleft').css('width', '50%'); $('.ddlright').show(); } else { $('.ddlleft').css('width', '100%'); $('.ddlright').hide(); $('.txtOthers').val(''); } } function SelectImage(temp) { var url = $(temp).data('imgurl'); $('.imgTopBig').attr('src', url); $('.span_TopSLT').removeClass('active'); $(temp).addClass('active'); } function GetInitData() { $.ajax({ url: '/bio101/pc.aspx?action=GetInitData', type: 'post', data: { ProductID: $.getUrlVar('id') }, dataType: 'json', success: function (res) { if (res.Result) { if (!$.trim($('#LinkerName').val())) { $('#LinkerName').val(res.Fullname); } if (!$.trim($('#LinkerEmail').val())) { $('#LinkerEmail').val(res.Email); } if (!$.trim($('#LinkerJobName').val())) { $('#LinkerJobName').val(res.job); } if (!$.trim($('#LinkerJobAddress').val())) { $('#LinkerJobAddress').val(res.Address); } if (!$.trim($('#ddlFields').val())) { $('#ddlFields').val(res.field); if (!$.trim($('#txtOthers').val())) { $('#txtOthers').val(res.fieldOthers); } if (res.field == '99') { $('.ddlleft').css('width', '50%'); $('.ddlright').show(); } else { $('.ddlleft').css('width', '100%'); $('.ddlright').hide(); $('.txtOthers').val(''); } } layui.form().render(); } }, error: function () { } }); } function SubmitProduct(data) { var queryType = ''; var count = 0; $('input[name="select"]').each(function (index, data) { if ($(data).is(':checked')) { if (count > 0) { queryType += ','; } queryType += $(data).val(); count++; } }); if (queryType == '') { layer.msg('请至少选择一个咨询类型', { icon: 5, shift: 6 }); return; } if (data.ddlFields == '99') { if ($.trim(data.others) == '') { layer.msg('研究方向-其他不能为空', { icon: 5, shift: 6 }); $('#txtOthers').focus(); return; } } var ii = layer.load(2, { shade: [0.1, '#000'] }); $.ajax({ url: '/bio101/pc.aspx?action=SubmitProduct', type: 'post', data: { QueryType: encodeURIComponent(queryType), ProductName: encodeURIComponent(data.ProductName), LinkerName: encodeURIComponent(data.LinkerName), LinkerEmail: encodeURIComponent(data.LinkerEmail), LinkerPhone: encodeURIComponent(data.LinkerPhone), LinkerJobName: encodeURIComponent(data.LinkerJobName), LinkerJobAddress: encodeURIComponent(data.LinkerJobAddress), ddlFields: data.ddlFields, others: encodeURIComponent(data.others), txtTWFW: encodeURIComponent(data.txtTWFW), ProductID: $.getUrlVar('id') }, dataType: 'json', success: function (res) { layer.close(ii); if (res.Result) { //发送邮件 SendEmail(queryType, data); Set_localStorage();//添加缓存 layer.alert('我们已经把您的请求发给厂家, 请耐心等候厂商与您联系。', { title: '提示', closeBtn: 0 }, function () { layer.closeAll(); $('#btnSubmit').attr('disabled', 'disabled'); }); } else { } }, error: function () { layer.close(ii); } }); } function SendEmail(queryType, data) { $.ajax({ url: '/bio101/pc.aspx?action=sendemail', type: 'post', data: { QueryType: encodeURIComponent(queryType), ProductName: encodeURIComponent(data.ProductName), LinkerName: encodeURIComponent(data.LinkerName), LinkerEmail: encodeURIComponent(data.LinkerEmail), LinkerPhone: encodeURIComponent(data.LinkerPhone), LinkerJobName: encodeURIComponent(data.LinkerJobName), LinkerJobAddress: encodeURIComponent(data.LinkerJobAddress), ddlFields: data.ddlFields, others: encodeURIComponent(data.others), txtTWFW: encodeURIComponent(data.txtTWFW), ProductID: $.getUrlVar('id') }, success: function (res) { }, error: function () { } }); } //wechat登录 function login_wechat() { window.open("/smlog/wechatlogin.aspx"); } function login_wechat_close() { if ($("#openid").val() == "ok") { location.reload(); } else if ($("#openid").val() != "") { layer.open({ type: 2, title: false, closeBtn: 0, skin: 'demo-skin-radius', //scrollbar: false, shadeClose: true, area: ['520px', '540px'], content: "/cn/ifrlogin_bind_cue.aspx?opentype=2&openid=" + $("#openid").val(), end: function () { location.reload(); } }); } } function GetProtocolsByProductID(page, pagesize) { $.ajax({ url: '/bio101/pc.aspx?action=GetProtocolsByProductID', type: 'post', data: { id: $.getUrlVar('id'), page: page, pagesize: pagesize }, dataType: "json", success: function (res) { layer.closeAll(); if (res.Result) { if (res.total == 0) { $('#mainprotocollist').hide(); } else { $('#mainprotocollist').show(); } var html = ''; $(res.data).each(function (index, data) { html += '
'; html += ' '; html += ' '; html += ' '; html += ' | '; html += '