$(function(){ yincang(); }) //获取版本前缀 var site=''; var pathname=window.location.pathname; var pathArr=pathname.split('/'); if(pathArr[1]=='cn'){ site='/cn' } if(pathArr[1]=='en'){ site='/en' } if(pathArr[1]=='tw'){ site='/tw' } //表单提交 var fieldArr = {}; var formSubmit = function (url,prefix,input = '', select = '', textarea ='',moren='',radio='') { //文本框 if (input) { inputArr = input.split('|'); for(var i in inputArr){ fieldArr[inputArr[i]] = $.trim($('#' +prefix+ inputArr[i]).val()) } } //下拉 if (select) { selectArr = select.split('|'); morenArr=moren.split('|'); for(var i in selectArr){ var curValue=$('#'+prefix+selectArr[i]).html(); if(curValue==morenArr[i]){ curValue=''; } fieldArr[selectArr[i]] = curValue; } } //文本域 if (textarea) { textArr = textarea.split('|'); for(var i in textArr){ fieldArr[textArr[i]] =$.trim($('#' +prefix+ textArr[i]).val()) } } //单选按钮或者协议 if(radio){ var val=$('#'+prefix+radio).hasClass('active'); if(val){ val=1; }else{ val=0; } fieldArr[radio]=val; } $.ajax({ type: "POST", url: url, dataType: "json", data: fieldArr, success: function (data) { if (data.code) { layer.msg(data.data, { icon: 6, time: 1200 }); setTimeout(function () { window.location.reload(); }, 1200); } if (data.code == 0) {layer.msg(data.data, { icon: 5, time: 1200 });} } }); } //Ajax组装 var Ajax=function(url,param,fun){ $.ajax({ type: "POST", url: url, dataType: "json", data:param, success: function(data) { fun(data); } }); } //点击enter搜索时间 function enterkey(url,field){ $(document).on('keydown',function(e){if(e.keyCode==13){ var keyword=$('#'+field).val(); window.location.href=url+'?keyword='+keyword; }}); } //点击搜索时间2 function enterkey2(url,query){ $(document).on('keydown',function(e){if(e.keyCode==13){ window.location.href=url+'?'+query }}); } //通过Ajax获取当前内容 url 获取单个内容接口{pb:siteindex}/ajax/content id 单个内容ID var getContent=function(url,id){ $.ajax({ type: "POST", url: url, data: {'id':id}, dataType: "json", success: function (data) { if(data.code==1){ $('#ajax').html(''); $('#ajax').html(data); } } }); } //给所有a标签加_blank var addBlank=function(){ var all_a = document.getElementsByTagName("a"); for (var i = 0; i < all_a.length; i++) { var value=all_a[i].href; if(value!='javascript:;' && value !="javascript:void(0);"){ all_a[i].target = "_blank"; } } } //通过系统语言版本跳转对应版本 var goLang=function(language,url){ var type=navigator.appName; if (type=="Netscape"){ var lang = navigator.language } else{ var lang = navigator.userLanguage } if(lang==language){ window.location.href=url; } } //通过接口跳转语言版本 var apiLang=function(language,url){ $.ajax({ type: "get", url: "https://ipinfo.io/json", dataType: "json", success: function(data) { // console.log(data.geoplugin_countryCode); var country=data.country; if(country==language){ window.location.href=url; } } }); } //api接口跳转版本 var apiLang2=function(language,url){ $.ajax({ type: "get", url: "http://geoplugin.net/json.gp", dataType: "json", success: function(data) { // console.log(data.geoplugin_countryCode); var country=data.geoplugin_countryCode; if(country==language){ window.location.href=url; } } }); } // 邮箱正则判断 var emailReg=function(email){ var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; if(!reg.test(email)){ layer.msg('邮箱格式不正确'); return false; } } //手机正则判断 var phoneReg=function(phone){ var phoneReg = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/; if (!phoneReg.test(phone)) { layer.msg('请输入有效的号码!'); return false; } } //获取表单单文本值 var input=function(fieldname){ return $.trim($('input[name="'+fieldname+'"]').val()); } //获取表单的值且不能为空 var inputNotEmpty=function(fieldname,desc){ var value=$.trim($('input[name="'+fieldname+'"]').val()); if(!value){ layer.msg(desc+'不能为空!'); return false; } return value; } //获取下拉的值 var select=function(fieldname,start){ var select=$('#'+fieldname).html(); if(select==start){ select=''; } return select; } //获取下拉且不能为空 var selectNotEmpty=function(fieldname,start,desc){ var select=$('#'+fieldname).html(); if(select==start){ select=''; } if(!select){ layer.msg('请选择'+'desc'); return false; } return select; } //获取文本域的值 var text=function(fieldname){ return $.trim($('textarea[name="'+fieldname+'"]').val()); } //获取文本域的值且不能为空 var textNotEmpty=function(fielname,desc){ var value=$.trim($('textarea[name="'+fieldname+'"]').val()); if(!value){ layer.msg(desc+'不能为空!'); return false; } return value; } //_this 点击对象 num 默认数量 liObj li对象 var page=0; var jiazai=function(liObj,start,num,_this){ var total=liObj.length; page=page+1; var count=start+page*num; for(i=0;i=total){ _this.hide(); } } var xianshi=function(liObj,start){ for(i=0;i