$href = location.href.replace(location.protocol+'//'+location.host,''); /* * 閫€鍑虹櫥褰 * **/ $(document).on('click', '[logout]', function() { $.post('/api/member/logout', {}, function(data) { if (data.ret == 1) { location.href = '/'; } else { $.alert(data.msg, 1); } }, 'json'); }); $(document).ready(function () { /* * 鎻愪氦鐣欒█ * **/ $('[feedback]').form({ url: '/api/web/feedback', end: function(data, f) { if (data.ret == 1) { f[0].reset(); } jQ.alert(data.msg, 1); } }); /* * 鎻愪氦鐣欒█ * **/ $('[newsletter]').form({ url: '/api/web/newsletter', end: function(data, f) { if (data.ret == 1) { f[0].reset(); } jQ.alert({ str: data.msg, init: function (a) { a.close.remove(); }, btn: 1 }); } }); }); // 棣栭〉璇佷功杞挱 $.extend({ // 鍒ゆ柇绉诲姩绔 mobile: function() { var a = navigator.userAgent.toLowerCase(), b = a.match(/ipad/) == 'ipad', c = a.match(/iphone os/) == 'iphone os', d = a.match(/midp/) == 'midp', e = a.match(/rv:1.2.3.4/) == 'rv:1.2.3.4', f = a.match(/ucweb/) == 'ucweb', g = a.match(/android/) == 'android', h = a.match(/windows ce/) == 'windows ce', i = a.match(/windows mobile/) == 'windows mobile'; return b || c || d || e || f || g || h || i; } }); $.fn.extend({ // 榧犳爣绉荤殑璺濈 // $('.title').move('.div',{}); move: function(a, v) { var thi = this; if ($.isFunction($.fn.moveDIV)) { thi.each(function(){ $(this).moveDIV(a, v); }); } else { $.jxinclude(jextpath + 'web/move.js', 1); setTimeout(function() { thi.move(a, v); }, 200); } return thi; }, // 榧犳爣绉荤殑璺濈 // $('.title').move('.div',{}); moveDIV: function(a, v) { var thi = this; var a = a || thi; var mubiao = $(a); var x, y, xx, yy, x0, y0, x1, y1, t0, w, h, l, t, start, end, left, top; var down = $.mobile() ? 'touchstart' : 'mousedown'; var move = $.mobile() ? 'touchmove' : 'mousemove'; var up = $.mobile() ? 'touchend' : 'mouseup'; var v = $.extend({ not: 0 }, v); thi.v = v; this.find('input,textarea,[notmove]').on(down, function(e) { e.stopPropagation(); }); this.addClass('notcopy').on(down, function(e0) { if (v.box) { var box = v.box==1?thi.parent():$(v.box); v.boxs = { left: 0, top: 0, width: box.width() - mubiao.width(), height: box.height() - mubiao.height() }; } if (e0.which == 3) { //鍙抽敭 return; } e0.preventDefault(); x = x0 = e0.pageX ? e0.pageX : e0.originalEvent.changedTouches[0].pageX; y = y0 = e0.pageY ? e0.pageY : e0.originalEvent.changedTouches[0].pageY; if ($.mobile() && e0.originalEvent.touches.length > 1) { t0 = 1; start = e0.originalEvent.touches; var hy0 = 0, hy1 = 0; } else { t0 = 0; } w = $(window).width(); h = $(window).height(); var mx = $(a).css('transform').match(/matrix\(([^\)]*)\)/); //transform:matrix if (mx) { mx = mx[1].replace(/ /g,'').split(','); l = parseInt(mx[4]); t = parseInt(mx[5]); } else { l = 0; t = 0; } $('body').addClass('notcopy'); if (typeof(v.down) == 'function') { var down_status = v.down.call(thi,{x: 0, y: 0, left: l, top: t}); } $(window).on(move, function(e1) { //window 杩橀渶瑕佺户缁紭鍖 if ($(a).is(':hidden')) { return; } if ($.mobile() && e1.originalEvent.touches.length > 1) { function distance(p1, p2) { var x = p2.pageX - p1.pageX, y = p2.pageY - p1.pageY; return Math.sqrt((x*x) + (y*y)); } end = e1.originalEvent.touches; if (!hy0) hy0 = distance(start[0], start[1]); hy1 = distance(end[0], end[1]); var scale = hy0 > hy1 ? -0.05 : 0.05; if (hy0!=hy1 && typeof(v.scale) == 'function') { hy0 = hy1; v.scale(hy0 > hy1 ? -scale : scale); } } if (t0 || v.not) { return; } //x1 = e1.pageX ? e1.pageX : e1.originalEvent.changedTouches[0].pageX; //y1 = e1.pageY ? e1.pageY : e1.originalEvent.changedTouches[0].pageY; x1 = e1.pageX; y1 = e1.pageY; var xx0 = x > x1 ? -1 : (x == x1 ? 0 : 1); var yy0 = y > y1 ? -1 : (y == y1 ? 0 : 1); x = x1; y = y1; if (v.x && xx0 == 0) { return; } else if (v.y && yy0 == 0) { return; } else if (xx0 == 0 && yy0 == 0) { return; } xx = xx0; yy = yy0; if (v.boxs) { left = (l+x1-x0) < v.boxs.left ? v.boxs.left : (l+x1-x0); left = left > v.boxs.width ? v.boxs.width : left; top = (t+y1-y0) < v.boxs.top ? v.boxs.top : (t+y1-y0); top = top > v.boxs.height ? v.boxs.height : top; } else { left = l + x1 - x0; top = t + y1 - y0; } if (typeof(v.move) == 'function') { var move_ = v.move.call(thi,{x: xx, y: yy, left: left, top: top}); if (move_){ top = move_.top || top; left = move_.left || left; } } if (v.x) { mx = 'matrix(1,0,0,1,'+left+',0)'; } else if (v.y) { mx = 'matrix(1,0,0,1,0,'+top+')'; } else { mx = 'matrix(1,0,0,1,'+left+','+top+')'; } $(a).css({transform:mx}); }).off(up).on(up, function(e2) { $(window).off(move); $(window).off(down); $(window).off(up); if ($(a).is(':hidden')) { return; } t0 = 1; $('body').removeClass('notcopy'); if (typeof(v.up) == 'function') { v.up.call(thi, {x: xx, y: yy, left: left, top: top}); } }); }); } }); // scroll /* var scroll = { init: function(){ var a = this; a.car_o = $('.carousel'); a.item = $('.carousel .item'); a.scr_o = $('.scroll-outer'); a.bar = $('.scroll-outer .scroll-btn'); a.item_length = a.item.length; a.bar.move('',{ x: 1, box: $('.scroll-outer'), down: function(){ clearInterval(a.time); }, move: function(s){ a.move(s); }, up: function(s){ var thi = this; //榧犳爣绉诲紑鍥炶皟 var bar_box_w = a.scr_o.width() / a.item_length; //鑾峰彇婊氬姩鏉$洅瀛愬搴 var j = Math.round(s.left / bar_box_w); var w = j * bar_box_w; a.time = setInterval(function(){ if(s.left < w){ s.left+=2; if(s.left > w){ s.left = w; } }else if(s.left > w){ s.left-=2; if(s.left < w){ s.left = w; } }else{ clearInterval(a.time); } console.log(a.time); thi.v.move(s); mx = 'matrix(1,0,0,1,'+s.left+',0)'; a.bar.css({transform : mx}); }, 10); } }); //婊氬姩鏉″搴 a.bar_width(); //鏃犻檺寰幆 a.copy(); //鏃犻檺寰幆 a.move({left:0}); }, bar_width: function(){ var a = this; var mw1 = a.item.width(); var sw1 = a.item_length * mw1; var mw2 = a.scr_o.width() / sw1 * mw1; a.bar.css({'width': mw2}); }, copy: function(){ var a = this; var cop = []; //澶嶅埗涓€浠 a.item.each(function(){ cop.push($(this).clone()); a.car_o.append($(this).clone()); }); //澶嶅埗涓や唤 for(var i = 0; i < cop.length; i++){ a.car_o.append(cop[i]); } var width = a.car_o.width() - a.item.width(); var mw1 = a.item.width() * a.item_length; a.car_o.css({'left': -mw1 + parseFloat(width / 2)}); }, move: function(s){ var a = this; //婊氬姩璺濈 var w = a.item.width(); var w1 = a.item_length * a.item.width(); var w2 = a.scr_o.width(); //var w3 = a.item.width(); var x2 = s.left; //婊氬姩鏉′綅缃 var x1 = x2*(w1/w2); var bar_w = a.bar.width(); var bar_j = x2 / bar_w; mx = 'matrix(1,0,0,1,-'+x1+',0)'; a.car_o.css({transform : mx}); var modify2 = 0, modify = 0; for(var i = 0; i < (a.item_length*3); i++){ var j = i - a.item_length; var slideProgress = j - bar_j; var negative = slideProgress>0?1:-1; // transform:scale(0.8) rotateY(-30deg); var rotate = -slideProgress * 30; // modify2 = slideProgress * w * (0.1 + (j - 2) * 0.05); modify = slideProgress * w * 0.67; //+ slideProgress * w; var translate = -modify + 'px'; var zIndex = 999 - Math.abs(Math.round(10 * slideProgress)); var scale = 1 - Math.abs(slideProgress) * 0.4; if(scale < 0.7){ scale = 0.7; } if(rotate > 30){ rotate = 30; }else if(rotate < -30){ rotate = -30; } $('.carousel .item').eq(i).css({transform:' translateX(' + translate + ')', zIndex:zIndex}).find('div').css({transform:'scale(' + scale + ') rotateY('+rotate+'deg)'}); if(Math.abs(Math.round(slideProgress)) >= 4){ $('.carousel .item').eq(i).css({opacity: 0}); }else{ $('.carousel .item').eq(i).css({opacity: 1}); } } } }; */ //浜у搧鏍峰紡鏁堟灉 $(function(){ $('.lang .btn').on('click', function(){ if($('.lang .list').hasClass('hide')){ $('.lang .list').removeClass('hide'); }else{ $('.lang .list').addClass('hide'); } }); if($('#pro-detail').length>0){ console.log(1); var galleryTop = new Swiper('.detail-img-top', { pagination: '.swiper-pagination', paginationClickable: true, spaceBetween: 16, navigation: { nextEl: '.pro-detail-next', prevEl: '.pro-detail-prev', }, on: { slideChangeTransitionStart: function () { galleryThumbs.slideTo(this.activeIndex); $(galleryThumbs.slides[this.activeIndex]).addClass('swiper-slide-active').siblings().removeClass('swiper-slide-active'); } } }); var galleryThumbs = new Swiper('.detail-img-thumbs', { spaceBetween: 16, slidesPerView: '3', touchRatio: 0.2, direction: 'vertical', slideToClickedSlide: true, breakpoints: { 750:{ direction: 'horizontal', slidesPerView: 3, }, }, on: { init: function () { this.slides.on('click', function (e) { var i = $(this).index(); galleryTop.slideTo(i); $(this).addClass('swiper-slide-active').siblings().removeClass('swiper-slide-active'); }); } } }); } });