$(function() {
    page.init();
    $('#checkDetailBtn').on('click', function() {
        $('.btn-check-detail,.detail-modal').toggleClass('active');
    })

    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) { return pair[1]; }
        }
        return (false);
    }
    if (getQueryVariable('id')) {
        $('.header-elements').removeClass('hid');
    }
})

// 是否pc
function IsPc() {
    if (!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
        // pc
        return true
    }
    return false
}

// 是否微信
function isWeChat() {
    if (typeof WeixinJSBridge !== "undefined") {
        return 1;
    }
    return 0;
}

// 联系qq客服
function onQQService() {
    var jhKfQQ = 3563681140;
    if (isWeChat()) {
        alert("请在浏览器打开页面")
        return;
    }
    var isPc = IsPc();
    var urlMobil = `mqqwpa://im/chat?chat_type=wpa&uin=${jhKfQQ}&version=1&src_type=web&web_src=http:://wpa.b.qq.com`;
    var urlPc = `http://wpa.qq.com/msgrd?v=3&uin=${jhKfQQ}&site=qq&menu=yes`;
    var url = isPc ? urlPc : urlMobil;
    window.open(url, "_brank");
}

var page = {
    appointCodeBase64: '',
    appointTeamCodeBase64: '',
    init: function() {
        // 卖点图
        if ($('.main-swiper .swiper-slide').length > 0) {
            var mainSwiper = new Swiper('.main-swiper', {
                loop: true,
                autoplay: {
                    disableOnInteraction: false
                },
                effect: 'coverflow',
                centeredSlides: true,
                slidesPerView: 'auto',
                followFinger: true,
                slideToClickedSlide: true,
                coverflowEffect: {
                    rotate: 0,
                    stretch: 0,
                    depth: 100,
                    modifier: 2,
                    slideShadows: true
                },
                pagination: {
                    el: '.main-swiper-pagination',
                    clickable: true
                }
            });
        }
    }
};