document.write(''); $(function () { Page_scrollTo(); $('.navi li ul').each(function(){ var x = $(this).parent().offset().left; x = x - $(this).find('li:eq(0)').width(); $(this).css({'padding-left': x}); }) //杞挱 $('.swipebox').each(function (index) { var obj=$(this).children('.swipe')[0]; var speed = RndNum(5000, 8000); var pageid='pager'+index; var n = $(this).find('.swipeli').length; for (var i = 1; i <= n; i++) { $(this).find('.pager').append('' + i + ''); } $(this).find("em:eq(0)").addClass("on"); $(this).find('.pager').attr('id',pageid) Swipe(obj, { auto: speed, callback: function (index, element) { slideTab(index, pageid); } }); }) $('.dalislide').each(function(){ var obj = $(this); var speed = RndNum(5000, 8000); var direction = typeof($(this).attr("data-direction"))!="undefined" ? $(this).attr('data-direction') : 'left'; obj.daliSlide({ speed: speed, duration: 800, dotname: 'slideb', dottxt: '', aroname: 'slideleft,slideright', direction: direction, callback: function(inidx, outidx) { obj.find('.slidethumb>div').eq(inidx).addClass('on'); obj.find('.slidethumb>div').eq(outidx).removeClass('on'); } }); }) //閾炬帴杞崲 $('.linkd').each(function () { if ($(this).attr('data-link') != '') { $(this).addClass('hand'); } }) $(document).on('click', '.linkd', function () { if ($(this).attr('data-link') != '') { window.open($(this).attr('data-link')); } }) $(document).on('click','.linka',function(){ if ($(this).find('a').length>0){ location.href= $(this).find('a:eq(0)').attr('href'); } }) //澶氳鏂囨湰瀹炵幇婧㈠嚭鐪佺暐鍙凤紝鎴彇闀垮害0鍒欐牴鎹洅瀛愰珮搴﹁嚜閫傚簲 $('.cutstr').each(function () { cutstr($(this), 0); }) //鏂囨湰妗嗘暟瀛楁楠 $(document).on('blur', '.number', function () { if (isNaN($(this).val())) { alert("璇疯緭鍏ユ纭殑鏁板瓧鏍煎紡!"); $(this).val(""); } }); //hidethis 鐖舵爣绛炬坊鍔犳class绫诲悕锛寃ow鍔ㄧ敾绉诲嚭灞忓箷鍚庨噸鏂拌繘鍏ュ睆骞曟椂鍐嶆鎵ц鍔ㄧ敾 var scrolltimer = null; var t1 = 0; var t2 = 0; $(window).scroll(function () { clearTimeout(scrolltimer) scrolltimer = setTimeout(isScrollEnd, 10) t1 = $(this).scrollTop(); }); function isScrollEnd() { t2 = $(window).scrollTop(); if (t2 == t1) { clearTimeout(scrolltimer) var WH = $(window).height(); $('.hidethis').each(function () { var targT = $(this).offset().top; var targH = $(this).height(); $(this).height(targH); if (t1 >= targT + targH || t1 + WH <= targT) { $(this).find(".wow").hide(); } else { $(this).find(".wow").show(); } }) sethead(); } } function sethead() { if (t1 > 400) { $('.head').addClass('out'); } else { $('.head').removeClass('out'); } } //灏唅mg鏍囩鐨剆vg鍥惧儚杞寲涓哄唴宓宻vg渚夸簬CSS鎺у埗 $('img.svg').each(function () { var obj = $(this); formatSVG(obj); }); //绂佹鍥剧墖鎷栨嫿 $('img').attr('draggable', 'false'); }); //ajax鐐瑰嚮 function ajaxclick(id) { $.post('/ajax/click', { id: id }); } //鏍煎紡鍖杝vg鍥惧儚 function formatSVG(obj) { var $img = obj; var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('src'); jQuery.get(imgURL, function (data) { // Get the SVG tag, ignore the rest var $svg = jQuery(data).find('svg'); // Add replaced image's ID to the new SVG if (typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); } // Add replaced image's classes to the new SVG if (typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass + ' replaced-svg'); } // Remove any invalid XML tags as per http://validator.w3.org $svg = $svg.removeAttr('xmlns:a'); // Check if the viewport is set, if the viewport is not set the SVG wont't scale. if (!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) { $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width')) } // Replace image with new SVG $img.replaceWith($svg); $svg.css({'visibility': 'visible'}); }, 'xml'); } function checkkw(){ if ($('#kw').val()==''){ alert('璇疯緭鍏ユ煡璇㈠叧閿瘝锛?); return false; } return true; } //璐村+ function showtips(title) { $("body").append("
" + title + "
"); var tw = -$(".tips").outerWidth() / 2; $(".tips").css({ 'margin-left': tw }).animate({ top: '+=30px', opacity: '90' }, 300); $(".tips").delay(2000).fadeOut(function () { $(this).remove() }); } function showloading() { $("body").append('
'); } function closeloading() { $('.loading').remove(); } //婊戝姩鍒版寚瀹氫綅缃 function Page_scrollTo(ele, speed) { if (!speed) { var ds = $(window).scrollTop(); if (ele) { ds = $(window).scrollTop() - $(ele).offset().top; } speed = ds > 1000 ? ds * 0.2 : 300; speed > 1000 && (speed = 1000); } if (!ele) { $("html,body").animate({ scrollTop: 0 }, speed); } else { if (ele.length > 0) $("html,body").animate({ scrollTop: $(ele).offset().top }, speed); } return false; } //鍖洪棿闅忔満鏁 function RndNum(minnum, maxnum) { var num = Math.floor(Math.random() * (minnum - maxnum) + maxnum); return num; } //灏佽瀛楃鍏ㄩ儴鏇挎崲鏂规硶 //璋冪敤锛歯ewstr=oldstr.replaceAll('涓浗','澶╂湞') String.prototype.replaceAll = function (f, e) {//鎶奻鏇挎崲鎴恊 var reg = new RegExp(f, "g"); //鍒涘缓姝e垯RegExp瀵硅薄 return this.replace(reg, e); } /* 澶氳鏂囨湰鎴彇瀛楃锛屽鏋滄孩鍑哄垯娣诲姞鐪佺暐鍙 濡傛灉涓嶆寚瀹氭埅鍙栭暱搴︼紝鍒欐牴鎹洅瀛愰珮搴﹁嚜閫傚簲鎴彇 obj锛氬厓绱爅query瀵硅薄 len锛氭埅鍙栭暱搴︼紝璁剧疆浜嗘埅鍙栭暱搴︾殑鐩存帴鎸塼xt妯″紡鎴彇 type: 'txt'绾枃鏈埅鍙栵紝'html'淇濈暀鏍峰紡 */ function cutstr(obj, len, type) { obj.css({ 'overflow': 'auto' }); var ellipsis = ''; if (len > 0) { if (obj.text().length > len) { ellipsis = '鈥?; } obj.text(obj.text().substr(0, len) + ellipsis); } else if (obj[0].scrollHeight <= obj[0].offsetHeight) { if (type != 'html') { obj.text(obj.text()); } } else { var arr = obj.text().replace(/\n/g, '').split(''); //鍏堝幓鎺夋枃鏈腑涓嶅彲瑙佺殑鎹㈣绗 var html = obj.html().replace(/\n/g, ''); html = html.replaceAll('
', '
'); var reg = /<([a-z]+?)(?:\s+?[^>]*?)?>\s*?<\/\1>/ig; while (obj[0].scrollHeight > obj[0].offsetHeight && arr.length > 0) { if (type == 'html') { var str = arr.pop(); //html=html.replace(new RegExp("(.*)"+str),'$1'); html = html.substr(0, html.lastIndexOf(str)) + html.substr(html.lastIndexOf(str) + 1) while (reg.test(html)) { //鍒犻櫎绌烘爣绛惧 html = html.replace(reg, ""); } while (html.substring(html.length - 4) == '
') { //鍒犻櫎鏈€鍚庝竴涓崲琛 html = html.substr(0, html.length - 4); } obj.html(html); if (obj.find('p:last').text() == '') { obj.find('p:last').remove(); html = obj.html(); } } else { obj.text(arr.join('')); arr.pop(); } ellipsis = '鈥?; var iscut = true; } if (iscut) { //鏈€鍚庡鍑忎竴涓紝鐣欎釜瀹夊叏璺濈 if (type == 'html') { var str = arr.pop(); html = html.substr(0, html.lastIndexOf(str)) + html.substr(html.lastIndexOf(str) + 1) while (reg.test(html)) { //鍒犻櫎绌烘爣绛惧 html = html.replace(reg, ""); } while (html.substring(html.length - 4) == '
') { //鍒犻櫎鏈€鍚庝竴涓崲琛 html = html.substr(0, html.length - 4); } obj.html(html); if (obj.find('p:last').text() == '') { obj.find('p:last').remove(); html = obj.html(); } } else { obj.text(arr.join('')); arr.pop(); } } if (type == 'html') { //濡傛灉html鎴彇缁撴灉鏄互html鏍囩缁撴潫鐨勶紝灏嗙渷鐣ュ彿娣诲姞鍦ㄦ爣绛鹃噷 var c = obj.html(); if (c.substr(c.length - 1, 1) == '>') { var n = c.lastIndexOf('<'); c = c.slice(0, n) + ellipsis + c.slice(n); obj.html(c); } else { obj.html(c + ellipsis); } } else { obj.text(obj.text() + ellipsis); } } obj.css({ 'overflow': 'hidden' }); } // 瀵笵ate鐨勬墿灞曪紝灏 Date 杞寲涓烘寚瀹氭牸寮忕殑String // 鏈?M)銆佹棩(d)銆佸皬鏃?h)銆佸垎(m)銆佺(s)銆佸搴?q) 鍙互鐢 1-2 涓崰浣嶇锛 // 骞?y)鍙互鐢 1-4 涓崰浣嶇锛屾绉?S)鍙兘鐢 1 涓崰浣嶇(鏄 1-3 浣嶇殑鏁板瓧) // 渚嬪瓙锛 // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, //鏈堜唤 "d+": this.getDate(), //鏃 "h+": this.getHours(), //灏忔椂 "m+": this.getMinutes(), //鍒 "s+": this.getSeconds(), //绉 "q+": Math.floor((this.getMonth() + 3) / 3), //瀛e害 "S": this.getMilliseconds() //姣 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } //璁$畻鏈堜唤宸 function getMonthNumber(date1, date2) { //榛樿鏍煎紡涓?20030303",鏍规嵁鑷繁闇€瑕佹敼鏍煎紡鍜屾柟娉 var year1 = date1.substr(0, 4); var year2 = date2.substr(0, 4); var month1 = date1.substr(4, 2); var month2 = date2.substr(4, 2); var len = (year2 - year1) * 12 + (month2 - month1); return len; }