$(function () { wowInt(); findTel(); search(); nav(); phoneTargetSelf(); $(window).resize(); share() $(window).scroll(function () { if ($(this).scrollTop() > 0) { $('body').addClass('scrollHeader'); } else { $('body').removeClass('scrollHeader'); } }); //商城入口 if($(window).width()>1024){ $(".shopping").hover(function() { $(".shopping-box").stop().slideDown(); }, function() { $(".shopping-box").stop().slideUp(); }); }else{ $(document).on('click','.shopping',function(){ //e.preventDefault() //e.stopPropagation() $(this).toggleClass("show"); $(".shopping-box").slideToggle(); }) /*$(document).click(function () { $(".shopping-box").stop().slideUp(); })*/ } //end if($(window).width()<=1024){ $(document).on('click','.share_common .share_pic',function(e){ $(this).addClass("on").siblings().removeClass("on"); }) } }) function mapInIt(mapTitle, mapAdress, dom) { var data = { x: dom.eq(0).attr('x').split(','), y: dom.eq(0).attr('y').split(','), title: dom.eq(0).attr('title').split(','), address: dom.eq(0).attr('address').split(','), tel: dom.eq(0).attr('tel').split(','), } var markerArr = [] for (var i = 0; i < data.x.length; i++) { markerArr.push({ title: data.title[i], point: [data.x[i], data.y[i]], address: data.address[i], tel: data.tel[i] }) } var map = new BMap.Map("map"); for (var i = 0; i < markerArr.length; i++) { var point = new BMap.Point(markerArr[i].point[0], markerArr[i].point[1]); var point2 = new BMap.Point(markerArr[i].point[0], markerArr[i].point[1]); var marker2 = new BMap.Marker(point2); map.addOverlay(marker2); } if ($(window).width() >= 1024) { map.centerAndZoom(point, 10); var myIcon = new BMap.Icon("../images/dot24.png", new BMap.Size(80, 120)); // var marker2 = new BMap.Marker(point2,{icon:myIcon}); } else { map.centerAndZoom(point2, 9); var myIcon = new BMap.Icon("../images/dot24_phone.png", new BMap.Size(40, 60)); // var marker2 = new BMap.Marker(point2,{icon:myIcon}); var marker2 = new BMap.Marker(point2); map.addOverlay(marker2); } // map.enableScrollWheelZoom(); map.enableContinuousZoom(); } function nav(){ if($(window).width()>1024){ $(".nav>ul>li").hover(function() { $(this).find(".navlist").stop().slideDown(); }, function() { $(this).find(".navlist").stop().slideUp(); }); }else{ $(".nav_phone_btn").click(function(e){ e.preventDefault(); e.stopPropagation(); $(this).toggleClass("visible_nav"); $("body").toggleClass("navbody"); $(".nav>ul>li").find(".navlist").slideUp(); $(".nav>ul>li").find("span").removeClass("on"); }) $(document).on('click','.nav>ul>li>span',function(e){ $(this).parent("li").siblings().find("span").removeClass("on"); $(this).parent("li").siblings().find(".navlist").slideUp(); $(this).toggleClass("on"); $(this).siblings(".navlist").slideToggle(); }) } if($(window).width()<1025){ $(".header_box").on('touchmove',function(event){ event.preventDefault(); event.stopPropagation(); }) } } function search() { $(document).on("click",".search_btn",function(e){ e.preventDefault() e.stopPropagation() $(this).toggleClass('on') $(this).siblings('.search_box').toggleClass('on'); if($(window).width()>1024){ $(".language dd").stop().slideUp(); } }) $(document).on("click",".search_box",function(e){ e.preventDefault() e.stopPropagation() }) $(document).click(function () { $('.search_btn').removeClass('on'); $('.search_box').removeClass('on'); if($(window).width()>1024){ $(".language dd").stop().slideUp(); } }) if($(window).width()>1024){ $(document).on("click",".language dt",function(e){ e.preventDefault() e.stopPropagation() $(this).siblings().stop().slideToggle(); $('.search_btn').removeClass('on'); $('.search_box').removeClass('on'); }) } } function wowInt(){ if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){ var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 100, mobile: true, live: true }); wow.init(); }; } /*手机端链接改为本窗口打开*/ function phoneTargetSelf(context){ if ($(window).width()<1024) { if(context==undefined){ context=$(document); } $('a',context).each(function(){ var target=$(this); var link=target.attr('target'); target.attr('target','_self'); }) } } /*电话链接取消默认事件并添加样式*/ function findTel(context){ if ($(window).width()>1024) { var condition = /^tel\:([0-9\-]+)|tel\:\+([0-9\-]+)$/; if(context==undefined){ context=$(document); } $('a',context).each(function(index, el) { var target=$(this); var href=target.attr('href'); if (condition.test(href)) { target.addClass('tel_link'); target.on('click',function(event){ event.preventDefault(); }) } }); } } /*ie9的placeholder包含密码框的兼容*/ $(function() { // 如果不支持placeholder,用jQuery来完成 if(!isSupportPlaceholder()) { // 遍历所有input对象, 除了密码框 $('input').not("input[type='password']").each( function() { var self = $(this); var val = self.attr("placeholder"); input(self, val); } ); /**//* 对password框的特殊处理 * 1.创建一个text框 * 2.获取焦点和失去焦点的时候切换 */ $('input[type="password"]').each( function(i) { var pwdField = $(this); var pwdVal = pwdField.attr('placeholder'); var pwdId = pwdField.attr('id'); // 重命名该input的id为原id后跟1 pwdField.after(''); var pwdPlaceholder = $('#' + pwdId + ''+i+''); pwdPlaceholder.show(); pwdField.hide(); pwdPlaceholder.focus(function(){ pwdPlaceholder.hide(); pwdField.show(); pwdField.focus(); }); pwdField.blur(function(){ if(pwdField.val() == '') { pwdPlaceholder.show(); pwdField.hide(); } }); } ); } }); // 判断浏览器是否支持placeholder属性 function isSupportPlaceholder() { var input = document.createElement('input'); return 'placeholder' in input; } // jQuery替换placeholder的处理 function input(obj, val) { var $input = obj; var val = val; $input.attr({value:val}); $input.focus(function() { if ($input.val() == val) { $(this).attr({value:""}); } }).blur(function() { if ($input.val() == "") { $(this).attr({value:val}); } }); } //end function ScollText(obj){ if($(obj).length>0){ $(obj).mCustomScrollbar({ mouseWheelPixels:500, autoDraggerLength:false, advanced: { autoScrollOnFocus: "" } }); } } //--------------点击分享 function share(){ $(".share_facebook").click(function () {//Facebook var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "https://www.facebook.com/sharer.php?s=100&p[title]=" + title + "&p[summary]=!&p[url]=" + encodeURIComponent(url) + "" window.open(op) }) $(".share_twitter").click(function () {//Twitter var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "https://www.tumblr.com/login?redirect_to=https://www.tumblr.com/widgets/share/tool?shareSource=legacy&canonicalUrl=&url=" + encodeURIComponent(url) + "&title=" + title + ""; window.open(op) }) $(".share_wb").click(function () {//微博 var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "http://service.weibo.com/share/share.php?title=" + title + "&url=" + encodeURIComponent(url) + ""; window.open(op) }) $(".share_qqkj").click(function () {//腾讯微博 var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title=" + title + "&url=" + encodeURIComponent(url) + ""; window.open(op) }) $(".share_qq").click(function () {//QQ var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "http://connect.qq.com/widget/shareqq/index.html?url=" + encodeURIComponent(url) + ""; window.open(op); }) $(".share_douban").click(function () {//豆瓣 var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "https://www.douban.com/share/service?title=" + title + "&url=" + encodeURIComponent(url) + ""; window.open(op); }) $(".share_bd").click(function () {//百度贴吧 var url = $(this).data("txt"); var url = window.location.href; var title = document.title; var op = "http://s.share.baidu.com/mshare?url=" + title + "&url=" + encodeURIComponent(url) + ""; window.open(op); }) //微信 $(".share_wx").attr("data-qrcode","http://www.xinhongru.com/qrcode/qrcode.php?content="+window.location.href); $(".share_wx").click(function () {//微信 //var url = "/qrCode/Index.aspx?url=" + window.location.href; var url = $(this).attr("data-qrcode") console.log(url) var title = "" title += "
" title += "x" title += "

二维码

" title += "
" title += "

扫一扫

" title += "
" $("body").remove(".weixin"); $("body").append(title) }) $(document).on("click", ".weixin .c", function () { $(".weixin").remove(); }) }