var platform = navigator.userAgent.match(/mobile/i) ? 'mobile' : 'pc'; var renderText = function(ele, speed, delay, duration){ if(!$(ele).length || $(ele).data('rendered')) return; speed = speed || 10; delay = delay || 0.5; duration = duration || 1; var textArr = $.trim($(ele).text()).split(''), textHTML = ''; for (var i = 0; i < textArr.length; i++) { textHTML += '' + textArr[i] + ''; }; $(ele).data('rendered', 1).html(textHTML); } var hint = function(text){ if(!text) return; if($('#hint').length == 0) $('
').appendTo('body'); var box = $('#hint'); box.html(text).show(); if(box[0].timer) clearTimeout(box[0].timer); box[0].timer = setTimeout(function () { box.hide(); }, 1500); } $(function(){ $('html').addClass(platform); $('.tabList .item').on('click', function(){ var index = $(this).index(); $(this).addClass('active').siblings('.item').removeClass('active'); $(this).parents('.tabs').next('.contents').find('.content').eq(index).addClass('active').siblings('.content').removeClass('active'); }); $('.btnGoTop').on('click', function(){ $('html, body').animate({ scrollTop: '0px' }, 300); }); $('#btnFeedbackSubmit').on('click', function(){ var _this = $(this); if(_this.hasClass('disabled')) return; var f_name = $('#f_name').val(), f_email = $('#f_email').val(), f_company = $('#f_company').val(), f_mobile = $('#f_mobile').val(), f_city = $('#f_city').val(), f_content = $('#f_content').val(); if(!f_name){ hint('请输入姓名'); return; }else if(!f_email){ hint('请输入邮箱'); return; }else if(!f_company){ hint('请输入公司名称'); return; }else if(!f_mobile){ hint('请输入电话'); return; }else if(!f_content){ hint('请输入你的需求'); return; } _this.addClass('disabled'); $.post('/feedback/submit', { f_name: f_name, f_email: f_email, f_company: f_company, f_mobile: f_mobile, f_city: f_city, f_content: f_content, }, function(res){ if(res.code == 1){ hint(res.msg); setTimeout(function(){ location.reload(); }, 1000) }else{ hint(res.msg); } setTimeout(function(){ _this.removeClass('disabled'); }, 1000) }) }); });