var shuwon = { percent: 0, timers: "", init: function (e) { util.isTop() util.toastInit() var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 100, mobile: true, live: true }).init(); var $wechat = $('.wechat') $wechat.click(function (e) { var _host = window.location.origin; var _html = ''; _html = '
鈥斺€擖/span>鍏虫敞鍏ㄥ弸鍏ㄥ眿瀹氬埗鈥斺€擖/span>
X
'; $('.layerBox').append(_html); setTimeout(function () { document.getElementById('codeLayer').style.opacity = 1; }, 100) }) $('.layerBox').on('click', '.close_box', function (e) { document.getElementById('codeLayer').style.opacity = 0; setTimeout(function () { document.getElementById('codeLayer').remove(); }, 500) }) //鍏嶈垂棰勭害 var $nameReservation = $('#nameReservation'), $phoneReservation = $('#phoneReservation'), $csrf = $('#_csrf'), reservation = localStorage.getItem('reservation'), $btnOffA = $('.freeAppointment .btnOff'), $advisoryBtn = $('.advisoryBtn'); $('.freeAppointment .btnSubmit').click(function (e) { if ($nameReservation.val() == '') { layer_box("娓╅Θ鎻愮ず", "璇峰~鍐欐偍鐨勫鍚?); return; } else if ($phoneReservation.val() == '') { layer_box("娓╅Θ鎻愮ず", "璇峰~鍐欐偍鐨勮仈绯荤數璇?); return; } else if (!util.regPhone($phoneReservation.val())) { layer_box("娓╅Θ鎻愮ず", "鎮ㄧ殑鑱旂郴鐢佃瘽鏍煎紡涓嶆纭?); return; } else { shuwon.getDataForApi('post', '/apibuy.html', { type: 5, form_name: $nameReservation.val(), form_phone: $phoneReservation.val(), _csrf: $csrf.val() }, function (data) { if (data.result) { $nameReservation.val('') $phoneReservation.val('') layer_box("娓╅Θ鎻愮ず", "鎻愪氦鎴愬姛锛屾垜浠細灏藉揩涓烘偍澶勭悊銆?); return; } else { getErrorMsg(data.msg);//閿欒鎻愮ず } }) } }) $btnOffA.click(function (e) { $('.freeAppointment,.freeMask').removeClass('active') localStorage.setItem('reservation', '1') }) $advisoryBtn.click(function (e) { $('.freeAppointment,.freeMask').addClass('active') }) var p = 0; var b = 0; $(window).scroll(function(e) { p = $(this).scrollTop(); if (b <= p) { $(".m_nav").addClass("active") } else { $(".m_nav").removeClass("active") } setTimeout(function() { b = p; }, 0); }); }, /** * 椤甸潰鍔犺浇瀹屾瘯 */ loaded: function () { }, index: function () { $('.videoBtn').click(function() { if($(this).hasClass("active")){ $('.bannerVideo video')[0].pause(); $('.videoBtn').removeClass("active"); }else{ $('.bannerVideo video')[0].play(); $('.videoBtn').addClass("active"); } }) //骞垮憡 var advertisingBanner = new Swiper('.advertisingBanner', { pagination: { el: '.advertisingBanner .pagination', }, speed: 700, }) tSpeed = 300; var navSwiper = new Swiper(".mpbox", { slidesPerView: 4, spaceBetween: 0, freeMode: true, on: { init: function() { navSlideWidth = this.slides.eq(0).css('width'); //瀵艰埅瀛楁暟闇€瑕佺粺涓€,姣忎釜瀵艰埅瀹藉害涓€鑷 bar = this.$el.find('.bar') bar.transition(tSpeed) navSum = this.slides[this.slides.length - 1].offsetLeft //鏈€鍚庝竴涓猻lide鐨勪綅缃 clientWidth = parseInt(this.$wrapperEl.css('width')) //Nav鐨勫彲瑙嗗搴 navWidth = 0 for (i = 0; i < this.slides.length; i++) { navWidth += parseInt(this.slides.eq(i).css('width')) } }, }, }); navSwiper.slides.eq(0).addClass("active") var pageSwiper = new Swiper(".mp_swiper", { autoplay: { delay: 5000, stopOnLastSlide: false, disableOnInteraction: true, }, effect: "cube", grabCursor: true, cubeEffect: { shadow: true, slideShadows: true, shadowOffset: 20, shadowScale: 1, }, pagination: { el: ".mp_swiper .swiper-pagination", }, on: { slideChange: function() { $(".mpbox .swiper-slide").eq(this.activeIndex).addClass("active").siblings().removeClass("active"); $(".mproduct_box ul li").eq(this.activeIndex).addClass("active").siblings().removeClass("active"); }, touchMove: function() { progress = this.progress bar.transition(0) bar.transform('translate(' + navSum * progress + 'px, -50%)') for (i = 0; i < this.slides.length; i++) { slideProgress = this.slides[i].progress if (Math.abs(slideProgress) < 1) { navSwiper.slides.eq(i).addClass("active") } } }, transitionStart: function() { activeIndex = this.activeIndex activeSlidePosition = navSwiper.slides[activeIndex].offsetLeft bar.transition(tSpeed) bar.transform('translate(' + activeSlidePosition + 'px, -50%)') if (activeIndex > 0) { navSwiper.slides.eq(activeIndex - 1).removeClass("active") } if (activeIndex < this.slides.length) { navSwiper.slides.eq(activeIndex + 1).removeClass("active") } navActiveSlideLeft = navSwiper.slides[activeIndex].offsetLeft //activeSlide璺濆乏杈圭殑璺濈 navSwiper.setTransition(500) if (navActiveSlideLeft < (clientWidth - parseInt(navSlideWidth)) / 2) { $(".mproNav").removeClass("active") navSwiper.setTranslate(0) } else if (navActiveSlideLeft > navWidth - (parseInt(navSlideWidth) + clientWidth) / 2) { navSwiper.setTranslate(clientWidth - navWidth - 5) $(".mproNav").removeClass("active") } else { navSwiper.setTranslate((clientWidth - parseInt(navSlideWidth)) / 2 - navActiveSlideLeft); $(".mproNav").addClass("active") } }, } }); pageSwiper.autoplay.stop(); navSwiper.on('tap', function(e) { clickIndex = this.clickedIndex clickSlide = this.slides.eq(clickIndex) pageSwiper.slideTo(clickIndex, 600, false); this.slides.removeClass("active"); clickSlide.addClass("active"); }) //鏍峰搧闂 var sampleRoom = new Swiper('.sampleRoom', { spaceBetween: 10, pagination: { el: '.sampleRoom .pagination', type: 'progressbar', }, speed: 600, autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, }); // 榛樿寮瑰嚭 $(".freeMask,.freeAppointment").addClass("active"); $(".advisoryBtn").addClass("active") $(window).scroll(function(e) { if ($(this).scrollTop() > 0) { $(".advisoryBtn").removeClass("active") } else { $(".advisoryBtn").addClass("active") } if ($(this).scrollTop() > 300) { pageSwiper.autoplay.start(); } }); }, responsibility: function (e) { var page = 1, pageSize = 6, totalpageSize = 0 apiresponsibility(page, pageSize) function apiresponsibility(page, pageSize) { shuwon.getDataForApi('get', '/mobile/apiresponsibility.html?page=' + page + '&pageSize=' + pageSize, { }, function (data) { if (data.result) { var str = ""; $.each(data.data.news_list, function (i, e) { str += '
  • '; str += ''; str += '
    '; str += '
    '; //str += ' '; str += '
    '; str += '
    '; str += '
    ' + e.title + '
    '; str += '
    ' + e.time + '
    '; str += '
    '; str += '
    '; str += '
    ' str += '
  • '; }); totalpageSize = Math.ceil(data.data.total / pageSize); $("#news1>ul").append(str) } }) } //鍔犺浇 $('#news1_btn').click(function (e) { if (page >= totalpageSize) { $(this).html('娌℃湁鏇村浜?) } else { page++ apiresponsibility(page, pageSize) } }) }, employee: function (e) { var page = 1, pageSize = 6, totalpageSize = 0 apiresponsibility(page, pageSize) function apiresponsibility(page, pageSize) { shuwon.getDataForApi('get', '/mobile/apiemployee.html?page=' + page + '&pageSize=' + pageSize, { }, function (data) { if (data.result) { var str = ""; $.each(data.data.news_list, function (i, e) { str += '
  • '; str += ''; str += '
    '; str += '
    '; //str += ' '; str += '
    '; str += '
    '; str += '
    ' + e.title + '
    '; str += '
    ' + e.time + '
    '; str += '
    '; str += '
    '; str += '
    ' str += '
  • '; }); totalpageSize = Math.ceil(data.data.total / pageSize); $("#news1>ul").append(str) } }) } //鍔犺浇 $('#news1_btn').click(function (e) { if (page >= totalpageSize) { $(this).html('娌℃湁鏇村浜?) } else { page++ apiresponsibility(page, pageSize) } }) }, yoyo: function (e) { // var swiper = new Swiper('.householdSwiper', { // slidesPerView: 'auto', // centeredSlides: true, // spaceBetween: 5, // speed: 600, // autoplay: { // delay: 4000, // stopOnLastSlide: false, // disableOnInteraction: false, // }, // }); //澶т簨璁 var $TabYear = $('.pageMemorabilia .tabList a'), year = 2018, liHtml = ''; $TabYear.click(function (e) { $(this).addClass('active').siblings().removeClass('active') year = $(this).html() apiyoyoApi(year) }) apiyoyoApi($TabYear.eq(0).html()) function apiyoyoApi(year) { shuwon.getDataForApi('get', '/apiyoyo.html?year=' + year, {}, function (data) { if (data.result) { liHtml = '' for (var i = 0; i <= data.news.length - 1; i++) { liHtml += '
  • ' + '
    ' + '' + '
    ' + '' + '

    ' + data.news[i].title + '

    ' + '
    ' + data.news[i].content + '
    ' + '
  • ' } $('.MemorabiliaBox ul').html(liHtml) var MemorabiliaBox = new Swiper('.MemorabiliaBox', { centeredSlides: true, slidesPerView: 'auto', spaceBetween: 10, speed: 600, autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, }); MemorabiliaBox.slideTo(1, 1000, false); MemorabiliaBox.update() $('.MemorabiliaBox li').click(function (e) { var index = $(this).index() MemorabiliaBox.slideTo(index, 1000, false); }) } }) } //鏀荤暐 var $taba = $('.pageRaidersTv .tabList._tab a'), $pageTvMina = $('.pageRaidersTv .coverBox .minTab'); var swiperCoverBox = new Swiper('.swiperCoverBox', { spaceBetween: 10, speed: 600, autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, on: { slideChangeTransitionStart: function () { $taba.eq(this.activeIndex).addClass('active').siblings().removeClass('active') $pageTvMina.eq(this.activeIndex).addClass('active').siblings().removeClass('active') }, }, }); $taba.click(function (e) { var i = $(this).index() $(this).addClass('active').siblings().removeClass('active') $pageTvMina.eq(i).addClass('active').siblings().removeClass('active') swiperCoverBox.slideTo(i, 1000, false); }) //鍛ㄨ竟 var page = 1, $pageSurrounding = $('.pageSurrounding ul'), $moreMobile = $('._moreMobile'), total = 0, pageCont = 0; apizhoubian(page) function apizhoubian(page) { shuwon.getDataForApi('get', '/apizhoubian.html?page=' + page + '&pageSize=8', {}, function (data) { if (data.result) { html = '' total = data.data.total pageCont = Math.ceil(total / 8) for (var i = 0; i <= data.data.zhoubian.length - 1; i++) { html += '
  • ' + '' + '
    ' + '

    ' + data.data.zhoubian[i].title + '

    ' + '
    ' + '
  • '; } $pageSurrounding.append(html) } }) } $moreMobile.click(function (e) { if (page >= pageCont) { page = pageCont $moreMobile.html('娌℃湁鏇村浜?) } else { page++ if (page >= pageCont) { $moreMobile.html('娌℃湁鏇村浜?) } apizhoubian(page) } }) }, product: function (e) { var $productA = $('.product .nav a'), $productList = $('.product .list'), $headerMobile = $('.headerMobile'), type = util.getSearch('type'); var province = '', city = '' $headerMobile.addClass('positionFlex') $productA.click(function (e) { $(this).addClass('active').siblings().removeClass('active') var i = $(this).index() if (i == 0) { $productList.eq(0).addClass('active').siblings().removeClass('active') } else if (i == 6) { $productList.eq(1).addClass('active').siblings().removeClass('active') //瀹氫綅 var lo = 116.331398, la = 39.897445 var map = new BMap.Map("map"); map.centerAndZoom(new BMap.Point(lo, la), 12); var geolocation = new BMap.Geolocation(); var regsn = new RegExp('鐪?) var regsi = new RegExp('甯?) province = '', city = '' geolocation.getCurrentPosition(function (r) { if (this.getStatus() == BMAP_STATUS_SUCCESS) { city = r.address.city province = r.address.province getData() } }) } }) if (type == 4) { $productA.eq(6).addClass('active').siblings().removeClass('active') $productList.eq(1).addClass('active').siblings().removeClass('active') } if (type == 1) { $productA.eq(0).addClass('active').siblings().removeClass('active') } //鍏ㄥ眿鎴愬搧 //闂ㄥ簵 // var _page = 1; // var allPage = 0; // var pageSize = 6; // var searchValue = ''; // $("#btn_more").hide(); // $("#stores").click(function () { // if($('#txtStore').val() == ""){ // alert("璇疯緭鍏ュ叧閿瘝"); // return; // } // getData("","",$('#txtStore').val(),_page); // }) // function getData(province,city,_search,page) { // var _search = _search; // $.ajax({ // type: "POST", // data: { // rows: 30, // page:page, // filtersRaw:'[{"id":"provinceName","property":"provinceName","operator":"like","value":"-"},{"id":"name","property":"name","operator":"like","value":"+_search+"},{"id":"cityName","property":"cityName","operator":"like","value":"-"},{"id":"status","property":"status","operator":"like","value":"1"}] // }, // //url: window.location.protocol + '//' + window.location.host + url, // // url: 'https://openapi.quanyou.com.cn/mdm/open/v1/shop/lbs/page?access_token='+$( ".token" ).html(), // url: 'https://openapi.quanyou.com.cn/mdm/open/v1/shop/lbs/page?access_token='+$( ".token" ).html(), // dataType: 'json', // success: function (data) { // if (data.success == 1) { // var str = ""; // $.each(data.data.records, function (i, e) { // var _phone = e.shopInfoPhone; // if(_phone == undefined){ // _phone = ""; // } // str += '
    '; // str += '
    ' + (i > 9 ? (i + 1) : ('0' + (i + 1))) + '
    '; // str += '
    ' + e.name + '
    '; // str += '
    Tel' + e._phone + '
    '; // str += '
    '; // }); // $(".store_box").html(str); // if(data.data.total> _page * data.data.rows){ // _page++; // apistoreover("", "",words,_page) // } // } else { // getErrorMsg(obj.message); //閿欒鎻愮ず // } // } // }) // } // $("#stores").click(function () { // city = '' // province = '' // type = 1 // getData($('#txtStore').val()); // }) // var pageIndex = 1; // var allPage = 0; // var pageSize = 6; // var type = 2 // var searchValue = ''; // $("#btn_more").hide(); // if (localStorage.getItem('seartitle') !== '') { // if (localStorage.getItem('seartitle')) { // getData(localStorage.getItem('seartitle')) // } else { // } // } // function getData(_search) { // var params = { // keywords: _search, // province: province, // city: city, // }; // searchValue = _search; // $.ajax({ // type: "GET", // data: params, // //url: window.location.protocol + '//' + window.location.host + url, // url: '/apistore.html', // dataType: 'json', // success: function (obj) { // if (obj.result == true) { // var str = ""; // $.each(obj.data.list, function (i, e) { // str += '
    '; // str += '
    ' + (i > 9 ? (i + 1) : ('0' + (i + 1))) + '
    '; // str += '
    ' + e.store_title + '
    '; // str += '
    Tel' + e.store_phone + '
    '; // str += '
    '; // }); // allPage = Math.ceil(obj.count / pageSize); // if ((pageIndex + 1) == allPage) { // getPagerNoMore(); // $("#btn_more").hide(); // } else { // $("#btn_more").show(); // //getPagerMore($('#btn_more'), 'BindNext()') // } // $(".store_box").html(str); // } else { // getErrorMsg(obj.message); //閿欒鎻愮ず // } // } // }) // } // function getPagerNoMore() { // $("#btn_more").hide(); // } // function getPagerMore(el, fu) { // el.addClass("hover").attr("onclick", fu); // } // function BindNext() { // pageIndex++; // getData(searchValue); // } }, productlist: function (e) { var type = util.getSearch('type'), cate1 = '', cate2 = '', $tabLink = $('.tabLink'), tabLinkIndex = 0, $suiteList = $('.suiteList'), $tabLinkBoxOl = $('.tabLinkBox ol li'); apiproductcateApi() $tabLink.on('click', 'li', function (e) { $(this).addClass('active').siblings().removeClass('active') tabLinkIndex = $(this).index() cate1 = $(this).data('cate1') console.log(cate1) apiproductcateApi() }) $tabLinkBoxOl.on('click', 'a', function (e) { //console.log($(this).data('cate2')) $(this).addClass('active').siblings().removeClass('active') cate2 = $(this).data('cate2') apiproductApi() }) function apiproductcateApi() { shuwon.getDataForApi('get', '/mobile/apiproductcate.html?type=' + type + '&cate1=' + cate1, {}, function (data) { if (data.result) { var tabLink = '', tabLinkOl = '' for (var i = 0; i <= data.category.length - 1; i++) { tabLink += '
  • ' + data.category[i].title + '
  • ' } for (var i = 0; i <= data.categorylist.length - 1; i++) { tabLinkOl += '' + data.categorylist[i].title + '' } if (data.category.length >= 4) { $tabLink.css('justify-content', 'left') } $tabLink.html(tabLink) $tabLinkBoxOl.html(tabLinkOl) cate1 = data.category[tabLinkIndex].id if (data.categorylist[0]) { cate2 = data.categorylist[0].id } apiproductApi() } }) } function apiproductApi() { console.log(cate1, cate2) shuwon.getDataForApi('get', '/mobile/apiproduct.html?type=' + type + '&cate1=' + cate1 + '&cate2=' + cate2, {}, function (data) { if (data.result) { var picture = '' for (var i = 0; i <= data.picture.length - 1; i++) { picture += '
  • ' + data.picture[i].title + '
  • ' } $suiteList.html(picture) } }) } }, productother: function (e) { var type = util.getSearch('type'), cate1 = '', tabLinkIndex = 0, $tabLink = $('.tabLink'), $suiteList = $('.suiteList'); apiproductotherApi() function apiproductotherApi() { shuwon.getDataForApi('get', '/mobile/apiproductother.html?type=' + type + '&cate1=' + cate1, {}, function (data) { if (data.result) { var tabLink = '', picture = '' for (var i = 0; i <= data.category.length - 1; i++) { tabLink += '
  • ' + data.category[i].title + '
  • ' } for (var i = 0; i <= data.picture.length - 1; i++) { picture += '
  • ' + data.picture[i].title + '
  • ' } $tabLink.html(tabLink) cate1 = data.category[0].id $suiteList.html(picture) } }) } $tabLink.on('click', 'li', function (e) { $(this).addClass('active').siblings().removeClass('active') tabLinkIndex = $(this).index() cate1 = $(this).data('cate1') apiproductotherApi() }) }, raiders: function (e) { var householdSwiper = new Swiper('.householdSwiper', { slidesPerView: 'auto', centeredSlides: true, spaceBetween: 5, speed: 600, autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, }); }, join: function (e) { var franchiseSwiper = new Swiper('.franchiseSwiper', { pagination: { el: '.franchiseSwiper .pagination', type: 'progressbar', }, slidesPerView: 'auto', spaceBetween: 10, speed: 600, autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, }); var operationSwiper = new Swiper('.operationSwiper', { pagination: { el: '.operationSwiper .pagination', type: 'progressbar', }, slidesPerView: 'auto', spaceBetween: 10, speed: 600, autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, }); $("#distpicker").distpicker({ autoSelect: false, province: '鐪佷唤鍚?, city: '鍩庡競鍚?, district: '鍖哄悕', }); // var $form = document.getElementById('_form') $('.form_submit').click(function (e) { if ($form.name.value == '') { new util.toast({ string: '璇峰~鍐欏鍚?, type: 'error' }) } else if ($form.mobile.value == '') { new util.toast({ string: '璇峰~鍐欐墜鏈哄彿鐮?, type: 'error' }) } else if (!util.regPhone($form.mobile.value)) { new util.toast({ string: '璇峰~鍐欐纭墜鏈哄彿鐮?, type: 'error' }) } else if ($form.address.value == '') { new util.toast({ string: '璇峰~鍐欏湴鍧€', type: 'error' }) } else { shuwon.getDataForApi('POST', '/apibuy.html', { type: 3, _csrf: $('#_csrf').val(), form_name: $form.name.value, form_phone: $form.mobile.value, form_address: $form.province.value + $form.city.value + $form.name.value + $form .edistrictName.value + $form.address.value, }, function (data) { if (data.result) { new util.toast({ string: '鐢宠鎴愬姛鎴戜滑浼氬敖蹇仈绯绘偍', type: 'success' }) $form.name.value = '' $form.mobile.value = '' $form.address.value = '' } }) } }) }, raiderslist: function (e) { }, /** *鑾峰彇鏁版嵁 * * @param {String} url 浼犲叆鐨勬暟鎹帴鍙 * @param {Object} para 浼犲叆鐨勫弬鏁 * @param {Object} callback 杩斿洖 */ getDataForApi: function (type, url, para, callback) { $.ajax({ type: type, data: para, url: window.location.protocol + '//' + window.location.host + url, //url: 'http://quanyoustore.cooyao.cn' + url, dataType: 'json', success: function (data) { callback(data) }, error: function (e) { console.log(e, "鏁版嵁鍔犺浇閿欒") } }) }, } shuwon.init()