define("index", ["jquery","hammer","swiper","lazyload","mlellipsis","iscroll-probe","index"], function(require, exports, module){
var yohobuy;

require("js/common");

require("js/category/entry");
require("js/guang/entry");
require("js/home/entry");
require("js/index/entry");
require("js/passport/entry");
require("js/product/entry");

module.exports = yohobuy;

});
define("js/common", ["jquery"], function(require, exports, module){
/**
 * 页面公共逻辑
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/21
 */
var $ = require("jquery");

var $footer = $('#yoho-footer');

function cookie(name) {
    var cookies = document.cookie,
        cookieVal,
        offset;

    if (document.cookie && document.cookie !== '') {
        offset = cookies.indexOf(name + '=');
        if (offset > -1) {
            offset += name.length + 1;

            cookieVal = decodeURIComponent($.trim(cookies.substring(offset, cookies.indexOf(';', offset))));
        }
    }

    return cookieVal;
}

function setCookie(name, value, options) {
    var expires = '',
        path,
        domain,
        secure,
        date;

    if (typeof value !== 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }

        if (options.expires &&
            (typeof options.expires === 'number' || options.expires.toUTCString)) {
            if (typeof options.expires === 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        path = options.path ? '; path=' + options.path : '';
        domain = options.domain ? '; domain=' + options.domain : '';
        secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    }
}

function getUser() {
    var c = cookie('_UID'),
        user;

    if (typeof c === 'undefined') {
        return 0;
    }

    user = c.split('::');

    if (typeof user === 'undefined' || user.length < 4) {
        return 0;
    }

    return user;
}

function getUid() {
    var user = getUser();

    if (user === 0) {
        return 0;
    }

    return user[1];
}

function getShoppingKey() {
    var c = cookie('_g');

    if (typeof c === 'undefined') {
        return '';
    }

    return JSON.parse(c).k;
}

//根据页面内容重新设置通用底部的显示
function rePosFooter() {
    if ($footer.length === 0) {
        return;
    }

    if ($('body').height() <= $(window).height()) {
        $footer.addClass('bottom');
    } else {
        $footer.removeClass('bottom');
    }
}

//页面通用底部位置及status设置
(function() {
    var $op = $footer.children('.op-row');

    var user = getUser();

    if ($('body').height() <= $(window).height()) {
        $footer.addClass('bottom');
    }

    if (user === 0) {

        //未登录
        $op.prepend(
            '<a href="/signin.html">登录</a>' +
            '<span class="sep-line">|</span>' +
            '<a href="/reg.html">注册</a>'
        );
    } else {

        //已登录
        $op.prepend(
            'Hi,' +
            '<a class="user-name" href="/home?tmp=' + Math.random() + '">' + user[0] + '</a>' +
            '<a href="/passport/signout/index?token=' + user[3] + '">退出</a>'
        );
    }

    $op.find('.back-to-top').on('touchend', function() {
        $(window).scrollTop(0);
        return false;
    });
    $footer.removeClass('hide');
}());

(function() {
    var uid = getUid();

    uid = uid === 0 ? '' : uid;

    window._ozuid = uid;//暴露ozuid

    if (window._yas) {
        window._yas(1 * new Date(), '1.0.8', 'yohobuy_m', uid, '');
    }
}());


//暴露公共接口
window.cookie = cookie;

window.setCookie = setCookie;

window.getUser = getUser;

window.getUid = getUid;

window.getShoppingKey = getShoppingKey;

window.rePosFooter = rePosFooter;

});
define("js/category/entry", ["jquery","hammer","swiper","lazyload","index"], function(require, exports, module){
/**
 * 品类打包入口
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/28
 */

require("js/category/index");
require("js/category/brand");
});
define("js/category/index", ["jquery","hammer"], function(require, exports, module){
/**
 * 分类
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/14
 */

var $ = require("jquery"),
    Hammer = require("hammer");

var $nav = $('.category-nav'),
    $categoryContainer = $('.category-container'),
    $contents = $categoryContainer.children('.content');

var $curContent = $contents.not('.hide');

var navHammer, ccHammer;

$('#search-input').focus(function() {
    $(this).blur();
});

navHammer = new Hammer($nav[0]);
navHammer.on('tap', function(e) {
    var $this = $(e.target).closest('li'),
        index = $this.index();

    if ($this.hasClass('focus')) {
        return;
    }

    $nav.find('li.focus').removeClass('focus');
    $this.addClass('focus');

    $curContent.addClass('hide');
    $curContent = $contents.eq(index).removeClass('hide');
});

ccHammer = new Hammer($categoryContainer[0]);
ccHammer.on('tap', function(e) {
    var $this = $(e.target),
        $subLevel,
        $cur, index;

    $cur = $this.closest('.p-level-item');
    if ($cur.length > 0) {
        index = $cur.index();
        $subLevel = $this.closest('.content').find('.sub-level');

        if ($this.hasClass('focus')) {
            return;
        }

        $this.closest('.primary-level').children('.focus').removeClass('focus');
        $this.addClass('focus');

        $subLevel.not('.hide').addClass('hide');
        $subLevel.eq(index).removeClass('hide');
    }
});
});
define("js/category/brand", ["jquery","hammer","swiper","lazyload","index"], function(require, exports, module){
/**
 *  品牌一览
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/23
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    Swiper = require("swiper"),
    lazyLoad = require("lazyload");

var swiper,
    $fixTitleBar,
    $brandText,
    $brandHref,
    $brandList = $('.brand-list');

var searchH = $('.newbrand-search').outerHeight(),
    headerH = $('.yoho-header').outerHeight(),
    brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
    searchArray = [];

var brandsData,
    $keyword,
    clearTextHammer,
    removeHistory,
    searchList,
    yohoHistory;

swiper = new Swiper('.swiper-container', {
    lazyLoading: true,
    loop: true,
    autoplay: 3000,
    pagination: '.swiper-pagination .pagination-inner'
});

lazyLoad($('img.lazy'));
$('.yoho-header').css({
    'z-index': 2,
    position: 'fixed',
    top: 0
});

$fixTitleBar = $('<div class="title-bar fixed-title-bar"><h2></h2></div>');
$fixTitleBar.hide();
$('.brand-list').last().append($fixTitleBar);

$(window).scroll(function() {
    var scrTop = $(window).scrollTop(),
        minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() +
        $('.banner-top').outerHeight();

    if ($brandList.eq(0).offset().top < minBrandListTop) {
        $fixTitleBar.hide();
    }

    $brandList.each(function() {
        var offTop = $(this).offset().top - brandSwipe;

        if (scrTop >= offTop) {
            $fixTitleBar.css({
                display: 'block',
                position: 'fixed',
                top: brandSwipe
            }).find('h2').html($(this).find('.title-bar').text());
        }

    });
});

function rightBarBindClick() {
    $('#right-bar .con').find('b').unbind().on('touchstart', function(e) {
        var index = $(this).index();

        if ($('.bar-' + index).size() > 0) {
            document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);
        }
        e.stopPropagation();
    });
}

rightBarBindClick();

function searchResult() {
    var keyword = ($keyword.val() + '').toLowerCase();
    var result = {},
        i = 0,
        rightBarHtml,
        html = '';

    // 遍历首字母搜索
    $.each(brandsData, function(k, v) {
        if ($.isArray(v)) {

            // 遍历品牌,进行匹配
            $.each(v, function(i, brand) {
                if (brand.name.toLowerCase().indexOf(keyword) > -1) {
                    result[k] = result[k] || [];
                    result[k].push(brand);
                }
            });
        }
    });

    // 根据搜索结果生成 HTML
    rightBarHtml = '<div id="right-bar" class="right-bar"><div class="con" id="con">';
    $.each(result, function(k, v) {
        var brandHtml = ['<div class="brand-list bar-', i, '">'];

        i++;
        brandHtml.push('<div class="title-bar"><h2>');
        brandHtml.push(k);
        brandHtml.push('</h2></div>');
        $.each(v, function(i, brand) {

            brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);

            // brandHtml.push('<p><span>' + brand.name);
            if (brand.isNew) {
                brandHtml.push('<i class="icon-hot">HOT</i>');
            }
            if (brand.isHot) {
                brandHtml.push('<i class="icon-new">NEW</i>');
            }
            brandHtml.push('</a></p>');
        });
        brandHtml.push('</div>');
        html += brandHtml.join('');

        if (k.indexOf(0) > -1) {
            k = '#';
        }

        rightBarHtml = rightBarHtml + '<b>' + k + '</b>';
    });

    rightBarHtml += '</div>';

    if (Object.keys(result).length > 0) {
        html += rightBarHtml;
    }

    // 插入 dom,绑定事件
    $('.search-result').html(html);

    if (Object.keys(result).length > 0) {
        rightBarBindClick();
    }
    $('.search-result .brand-list p').each(function (index) {
        searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]);
        searchList.on('tap', function() {
            $brandText = $('.search-result .brand-list p').eq(index).find('a').html();
            $brandHref = $('.search-result .brand-list p').eq(index).find('a').attr('href');
            if (localStorage.getItem('yohoHistory')) {
                yohoHistory = localStorage.getItem('yohoHistory');
                searchArray.push(yohoHistory);
            }
            if (searchArray.toString().split($brandText).length < 2) {
                searchArray.push('{"searchName":"' + $brandText + '","searchHref":"' + $brandText + '"}');
            }
            localStorage.setItem('yohoHistory', searchArray);
        });
    });
}

if ($('.brand-search-page').length) {
    brandsData = $.parseJSON($('#brands-data').html());
    $keyword = $('#keyword');

    $keyword.on('input', function() {
        $('.history').css('display', 'none');
        if ($keyword.val().length) {
            searchResult();
            $(this).closest('.search-box').css('width', '11.25rem');
            $('.search-action').show();
        } else {
            $(this).closest('.search-box').css('width', '12.5rem');
            $('.search-action').hide();
        }
    }).focus();

    clearTextHammer = new Hammer($('.clear-text')[0]);
    clearTextHammer.on('tap', function(e) {
        e.preventDefault();
        $('#keyword').val('').trigger('input');
        e.srcEvent.stopPropagation();
    });

    $('form.search-box').on('submit', function() {
        return false;
    });
    if (localStorage && localStorage.getItem('yohoHistory')) {
        yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
        if (yohoHistory) {
            $.each(yohoHistory, function(index, content) {
                $('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList');
            });
        }
    }

    removeHistory = new Hammer($('.removeHistory')[0]);
    removeHistory.on('tap', function(e) {
        $('.historyList').html(' ');
        localStorage.clear();
    });
}

});
define("js/guang/entry", ["jquery","hammer","lazyload","swiper","mlellipsis","iscroll-probe","index"], function(require, exports, module){
/**
 * 逛打包入口
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/9
 */

require("js/guang/plus-star/list");
require("js/guang/plus-star/detail");

require("js/guang/home");
require("js/guang/list");
require("js/guang/detail");
});
define("js/guang/plus-star/list", ["jquery","hammer","lazyload","swiper","index"], function(require, exports, module){
/**
 * PLUS+STAR列表页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    lazyLoad = require("lazyload"),
    Swiper = require("swiper");

var $navs = $('#nav-tab > li'),
    $contents = $('#ps-content > .content');

var mySwiper, navHammer;

lazyLoad($('img.lazy'));

mySwiper = new Swiper('.swiper-container', {
    lazyLoading: true,
    pagination: '.swiper-pagination'
});

navHammer = new Hammer(document.getElementById('nav-tab'));
navHammer.on('tap', function(e) {
    var $this = $(e.target).closest('li');

    if ($this.hasClass('focus')) {
        return;
    }

    $navs.toggleClass('focus');
    $contents.toggleClass('hide');

    $(document).trigger('scroll'); //Trigger lazyLoad
});
});
define("js/guang/plus-star/detail", ["jquery","hammer","mlellipsis","lazyload"], function(require, exports, module){
/**
 * PLUS+STAR详情页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    ellipsis = require("mlellipsis"),
    lazyLoad = require("lazyload");

var $intro = $('#intro'),
    $imt = $('#intro-more-txt'),
    $infosContainer = $('#related-infos-container');

var info = require("js/guang/info");

var tip = require("js/plugin/tip");

var brandId = $('#brand-info').data('id');

var mIntro, aIntro;

var moreHammer, likeHammer;

ellipsis.init();

//Init LazyLoad
lazyLoad($('img.lazy'));

//文字介绍文字截取
$intro[0].mlellipsis(3);

//获取截取文字和完整文字
setTimeout(function() {
    mIntro = $intro.text();
    aIntro = $intro.attr('title');
});

info.initInfosEvt($infosContainer);

//文字介绍收起与展开
moreHammer = new Hammer(document.getElementById('more-intro'));
moreHammer.on('tap', function(e) {
    var $this = $(e.target).closest('#more-intro');

    $this.toggleClass('spread');

    if ($this.hasClass('spread')) {

        //显示
        $intro.text(aIntro);
        $imt.text('收起');
    } else {

        //隐藏
        $intro.text(mIntro);
        $imt.text('more');

        $(window).scrollTop(0, 400); //滑动到顶部
    }

    e.preventDefault(); //防止收缩后误点到商品产生跳转
});

//品牌收藏
likeHammer = new Hammer(document.getElementById('brand-like'));
likeHammer.on('tap', function(e) {
    var opt = 'ok',
        $this = $(e.target);

    e.preventDefault();

    if ($this.hasClass('like')) {
        opt = 'cancel';
    }

    $.ajax({
        type: 'POST',
        url: '/guang/opt/favoriteBrand',
        data: {
            id: brandId,
            opt: opt
        },
        success: function(data) {
            if (data.code === 200) {
                $this.toggleClass('like');
            } else if (data.code === 400 || data.code === 412) {
                location.href = data.data; //未登录跳转登录页面
            } else {
                tip.show(data.message);
            }
        },
        error: function() {
            tip.show('网络断开连接了~');
        }
    });
});
});
define("js/guang/info", ["jquery","hammer","mlellipsis","lazyload"], function(require, exports, module){
/**
 * 资讯相关API
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    ellipsis = require("mlellipsis"),
    lazyLoad = require("lazyload");

var tip = require("js/plugin/tip");
var loading = require("js/plugin/loading");

var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
    $noMore = $('');

var searching = false;

ellipsis.init();

if ($loadMoreInfo.length > 0) {
    $loading = $loadMoreInfo.children('.loading');
    $noMore = $loadMoreInfo.children('.no-more');
}

/**
 * 设置指定资讯项的Lazyload和文字截取
 * @params $infos 资讯项
 */
function setLazyLoadAndMellipsis($infos) {
    lazyLoad($infos.find('img.lazy'));

    $infos.each(function() {
        var $this = $(this),
            $title = $this.find('.info-title'),
            $text = $this.find('.info-text');

        $title[0].mlellipsis(2);
        $text[0].mlellipsis(2);
    });
}

/**
 * 初始化资讯列表事件绑定
 * @params $container 逛资讯列表容器
 */
function initInfosEvt($container) {
    var cHammer = new Hammer($container[0]);

    cHammer.on('tap', function(e) {
        var $this = $(e.target),
            opt = 'ok',
            $likeBtn,
            $info;

        $likeBtn = $this.closest('.like-btn');
        if ($likeBtn.length > 0) {
            if ($likeBtn.hasClass('like')) {
                opt = 'cancel';
            }

            $info = $this.closest('.guang-info');
            $.ajax({
                type: 'POST',
                url: '/guang/opt/praiseArticle',
                data: {
                    id: $info.data('id'),
                    opt: opt
                },
                success: function(data) {
                    var code = data.code;

                    if (code === 200) {
                        $likeBtn.next('.like-count').text(data.data);

                        //切换点赞状态
                        $likeBtn.toggleClass('like');
                    }
                },
                error: function() {
                    tip.show('网络断开连接了~');
                }
            });
        }
    });

    setLazyLoadAndMellipsis($container.find('.guang-info'));
}

/**
 * 资讯LoadMore
 */
function loadMore($container, opt) {
    var num;

    if (searching) {
        return;
    }

    if (opt.end) {
        return;
    }

    if (opt.page === 1) {

        //显示loading
        loading.showLoadingMask();
    }

    num = $container.find('.guang-info').length;
    searching = true;
    $.ajax({
        type: 'GET',
        url: ' /guang/index/page',
        data: opt,
        success: function(data) {
            var $newItems;

            if (data === ' ') {
                opt.end = true;
                searching = false;

                //
                $loading.addClass('hide');
                $noMore.removeClass('hide');

                return;
            }

            $container.append(data);

            if (num > 0) {
                $newItems = $container.find('.guang-info:gt(' + (num - 1) + ')');
            } else {
                $newItems = $container.find('.guang-info');
            }

            setLazyLoadAndMellipsis($newItems);

            if (opt.page === 1) {
                loading.hideLoadingMask();

                $loading.removeClass('hide');//显示空屏加载时hide的隐藏

                window.rePosFooter();//插入内容后重新计算底部位置
            }

            opt.page++;

            searching = false;
        },
        error: function() {
            tip.show('网络断开连接了~');
            searching = false;
        }
    });
}

exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
});
define("js/plugin/tip", ["jquery"], function(require, exports, module){
/**
 * 弹框提示
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */
var $ = require("jquery");

var $tip, tipItime;

/**
 * 初始化提示框
 */
(function() {
    var tipHtml = '<div id="yoho-tip" class="yoho-tip"></div>';

    //插入提示HTML
    $('.yoho-page').append(tipHtml);

    $tip = $('#yoho-tip');
    $tip.on('tap', function() {
        $tip.hide();

        //清除Timeout
        clearTimeout(tipItime);
    });
}());

/**
 * 显示提示
 */
function show(con, dur) {
    var content, duration;

    if (typeof con === 'undefined') {
        return;
    }

    content = con.toString();
    duration = (dur && dur > 0) ? dur : 2000;

    $tip.text(content).show();

    tipItime = setTimeout(function() {
        if ($tip.css('display') === 'block') {
            $tip.hide();
        }
    }, duration);
}

exports.show = show;
});
define("js/plugin/loading", ["jquery"], function(require, exports, module){
/**
 * Loading mask
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/29
 */

var $ = require("jquery");

var $page = $('.yoho-page');

var $loading,
    hasInit = false;

/** modify by liangzhifeng at 2015.11.2 */

// 初始化
function init($container) {
    var html = '<div class="loading-mask hide"><div class="loading"></div></div>';

    hasInit = true;
    if ($container === undefined) {
        $container = $page;
    }

    $container.append(html);

    $loading = $container.children('.loading-mask');
}

//显示loading
function showLoadingMask() {
    if (!hasInit) {
        init();
        hasInit = true;
    }
    $loading.removeClass('hide');
}

//隐藏loading
function hideLoadingMask() {
    $loading.addClass('hide');
}

exports.init = init;
exports.showLoadingMask = showLoadingMask;
exports.hideLoadingMask = hideLoadingMask;
});
define("js/guang/home", ["jquery","hammer","swiper","mlellipsis","lazyload","index"], function(require, exports, module){
/**
 * 逛首页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    Swiper = require("swiper");

var info = require("js/guang/info"),
    loadMore = info.loadMore;

var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
    $noMore = $('');

var winH = $(window).height();

var $infoList = $('#info-list'),
    $infos = $infoList.children('.info-list'),
    $nav = $('#guang-nav'),
    $curNav = $nav.children('.focus'),
    curType = $curNav.data('type');

var state = {};

var mySwiper, navHammer;

if ($loadMoreInfo.length > 0) {
    $loading = $loadMoreInfo.children('.loading');
    $noMore = $loadMoreInfo.children('.no-more');
}

mySwiper = new Swiper('.swiper-container', {
    lazyLoading: true,
    pagination: '.swiper-pagination',
    autoplay: 3000
});

info.initInfosEvt($infoList);

//初始化各Nav下资讯加载的状态
(function() {
    var gender = $('#gender').val();

    $nav.children('.guang-nav-item').each(function() {
        var type = $(this).data('type'),
            focus = $(this).hasClass('focus');

        state[type] = {
            page: focus ? 2 : 1,
            gender: gender,
            type: type,
            end: false
        };
    });
}());

navHammer = new Hammer($nav[0]);
navHammer.on('tap', function(e) {
    var $this = $(e.target).closest('.guang-nav-item'),
        $content,
        index;

    if ($this.hasClass('focus')) {
        return;
    }


    index = $this.index();

    $this.addClass('focus');
    $curNav.removeClass('focus');

    $content = $infos.eq(index);

    $curNav = $this;
    curType = $this.data('type');

    //当未加载数据时去请求数据
    if (state[curType].page === 1) {

        //无数据时隐藏正在加载和没有更多字样
        $loading.addClass('hide');
        $noMore.addClass('hide');

        loadMore($content, state[curType]);
    } else {

        //重置当前Tab的load-more
        if (state[curType].end) {
            $loading.addClass('hide');
            $noMore.removeClass('hide');
        } else {
            $loading.removeClass('hide');
            $noMore.addClass('hide');
        }
    }

    $infos.not('.hide').addClass('hide');
    $content.removeClass('hide');

    if (state[curType].page === 1) {
        window.rePosFooter();//进入空内容时重新定位footer位置
    }
});

$(document).scroll(function() {
    var $c = $infos.not('.hide');

    if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $c.height()) {
        loadMore($c, state[curType]);
    }
});
});
define("js/guang/list", ["jquery","hammer","mlellipsis","lazyload"], function(require, exports, module){
/**
 * 列表页,编辑页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require("jquery");

var info = require("js/guang/info"),
    loadMore = info.loadMore;

var winH = $(window).height();

var $author = $('#author-infos');
var $tag = $('#tag');
var $gender = $('#gender');
var $isApp = $('#isApp');

var setting = {
    page: 2,
    end: false
};

var $infos = $('#info-list');

info.initInfosEvt($infos);

if ($author.length > 0) {
    $.extend(setting, {
        authorId: $author.data('id')
    });
}

if ($tag.length > 0) {
    $.extend(setting, {
        tag: $tag.val(),
        gender: $gender.val(),
        isApp: $isApp.val()
    });
}

$(document).scroll(function() {
    if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $infos.height()) {
        loadMore($infos, setting);
    }
});
});
define("js/guang/detail", ["jquery","mlellipsis","lazyload","iscroll-probe"], function(require, exports, module){
/**
 * 逛详情页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/13
 */

var $ = require("jquery"),
    ellipsis = require("mlellipsis"),
    lazyLoad = require("lazyload"),
    IScroll = require("iscroll-probe");

var $authorIntro = $('.author .intro');

var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false;

var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false;

//collocation block variable
var thumbWidth = 0,
    $fixedThumbContainer = $(''),
    $coBlock, $thumbContainer, $thumbs, $prods,
    scrollToEl;

var scrollToEl = document.querySelector('#wrapper .collocation-block');

var winW = $(window).width();

var myScroll;

require("js/plugin/wx-share")();

/**
 * 计算搭配的箭头的位置
 * @param $curPos 当前focus的搭配项
 */
function posCollocationArrow($curCo) {
    var left = $curCo.offset().left,
        bgPos = -winW + left + (thumbWidth / 2) + 'px';

    $thumbContainer.css({
        backgroundPosition: bgPos + ' bottom'
    });

    if (isIphone) {
        $fixedThumbContainer.css({
            backgroundPosition: bgPos + ' bottom'
        });
    }
}

//搭配thumb的touch事件句柄
function thumbTouchEvt(e) {
    var $curCo = $(e.currentTarget),
        index = $curCo.index(),
        $brother, $brotherCo,
        $curProds;

    if ($curCo.hasClass('focus')) {
        return;
    }

    $thumbs.filter('.focus').removeClass('focus');

    if (isIphone) {
        if ($curCo.closest('.fixed-thumb-container').length > 0) {
            $brother = $thumbContainer;
        } else {
            $brother = $fixedThumbContainer;
        }

        $brotherCo = $brother.find('.thumb').eq(index);
        $fixedThumbContainer.find('.thumb.focus').removeClass('focus');
        $brotherCo.addClass('focus');
    }

    $curCo.addClass('focus');

    //定位arrow
    posCollocationArrow($curCo);

    $prods.not('.hide').addClass('hide');
    $curProds = $prods.eq(index);
    $curProds.removeClass('hide');

    //
    lazyLoad($curProds.find('.lazy'));

    if (isIphone) {
        if (myScroll) {
            myScroll.scrollToElement(scrollToEl, 400);
        }
    } else {
        $('body').animate({
            scrollTop: $coBlock.offset().top
        }, 400);
    }
}

if (isIphone) {
    $('#wrapper').addClass('ios');
}

ellipsis.init();

lazyLoad($('.lazy'));

//title mlellipsis
$('.info-list .title, .one-good .reco-name').each(function() {
    this.mlellipsis(2);
});

//offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名
if (parseInt($authorIntro.offset().left, 10) === parseInt($authorIntro.css('margin-left'), 10)) {
    $authorIntro.css('padding-top', 0);
}

//有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有
if (hasCollocationBlock) {
    $coBlock = $('.collocation-block');
    $thumbContainer = $coBlock.children('.thumb-container');
    $thumbs = $thumbContainer.find('li');
    $prods = $coBlock.find('.prod');

    thumbWidth = $thumbs.width();

    if (isIphone) {
        $fixedThumbContainer = $('#wrapper')
            .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom'))
            .next('.thumb-container');

        //load img of fixed thumb container
        lazyLoad($fixedThumbContainer.find('.lazy'), {
            event: 'sporty'
        });
    }

    //Init Arrow Position
    posCollocationArrow($thumbs.filter('.focus'));

    $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);

    if (isIphone) {
        $fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);
    }
}

// 初始化iscroll
window.onload = function() {
    var $scroller = $('#scroller');

    var winH, tcH, cbH, cbTop, fixedThumbDom;

    if (!isIphone) {
        return;
    }

    myScroll = new IScroll('#wrapper', {
        probeType: 3,
        mouseWheel: true,
        click: true
    });

    document.addEventListener('touchmove', function (e) {
        e.preventDefault();
    }, false);

    if (!hasCollocationBlock) {
        myScroll.on('scroll', function() {
            $scroller.trigger('scroll');
        });
        return;
    }

    winH = $(window).height();
    fixedThumbDom = $fixedThumbContainer[0];

    tcH = $thumbContainer.height();
    cbH = $coBlock.height();
    cbTop = $coBlock.offset().top;

    myScroll.on('scroll', function() {
        var sTop = -this.y;
        var classList = fixedThumbDom.className;

        if (sTop <= cbTop - winH + tcH) {
            if (classList.indexOf('fixed-bottom') === -1) {
                $fixedThumbContainer
                    .addClass('fixed-bottom')
                    .removeClass('hide');
            }
        } else if (sTop <= cbTop) {
            if (classList.indexOf('hide') === -1) {
                $fixedThumbContainer
                    .addClass('hide')
                    .removeClass('fixed-bottom fixed-top');
            }
        } else if (sTop <= cbTop + cbH - tcH) {
            if (classList.indexOf('fixed-top') === -1) {
                $fixedThumbContainer
                    .addClass('fixed-top')
                    .removeClass('hide absolute')
                    .css('top', '');
            }
        } else if (sTop <= cbTop + cbH) {
            if (classList.indexOf('absolute') === -1) {
                $fixedThumbContainer
                    .addClass('absolute')
                    .removeClass('fixed-top hide');
            }
            fixedThumbDom.style.top = cbTop + cbH - tcH - sTop + 'px';
        } else if (sTop > cbTop + cbH) {
            if (classList.indexOf('hide') === -1) {
                $fixedThumbContainer
                    .addClass('hide')
                    .removeClass('absolute');
            }
        }
        $scroller.trigger('scroll');
    });
};
});
define("js/plugin/wx-share", ["jquery"], function(require, exports, module){
/**
 * 微信分享
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/30
 */

var $ = require("jquery");

module.exports = function() {
    var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';

    $.getJSON(_weChatInterface + '?pageurl=' +
        encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function (json) {
        var _appId, _timestamp, _nonceStr, _signature;

        if (json !== undefined && json !== '') {
            _appId = json.appId.toString();
            _timestamp = json.timestamp;
            _nonceStr = json.nonceStr.toString();
            _signature = json.signature.toString();

            wx.config({
                debug: false,
                appId: _appId,
                timestamp: _timestamp,
                nonceStr: _nonceStr,
                signature: _signature,
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'hideMenuItems',
                    'showMenuItems',
                    'hideAllNonBaseMenuItem',
                    'showAllNonBaseMenuItem',
                    'translateVoice',
                    'startRecord',
                    'stopRecord',
                    'onRecordEnd',
                    'playVoice',
                    'pauseVoice',
                    'stopVoice',
                    'uploadVoice',
                    'downloadVoice',
                    'chooseImage',
                    'previewImage',
                    'uploadImage',
                    'downloadImage',
                    'getNetworkType',
                    'openLocation',
                    'getLocation',
                    'hideOptionMenu',
                    'showOptionMenu',
                    'closeWindow',
                    'scanQRCode',
                    'chooseWXPay',
                    'openProductSpecificView',
                    'addCard',
                    'chooseCard',
                    'openCard'
                ]
            });
        }
    });

    wx.ready(function () {
        var shareTitle = $('#shareTitle').val();
        var shareImg = $('#shareImg').val();
        var shareDesc = $('#shareDesc').val();
        var shareLink = $('#shareLink').val();
        var shareData = {
            title: shareTitle,
            desc: shareDesc,
            imgUrl: shareImg,
            link: shareLink
        };

        wx.onMenuShareAppMessage(shareData);
        wx.onMenuShareTimeline(shareData);
        wx.onMenuShareQQ(shareData);
        wx.onMenuShareWeibo(shareData);
    });
};
});
define("js/home/entry", ["jquery","hammer","swiper","lazyload","index"], function(require, exports, module){
/**
 *  首页打包入口
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/12
 */

require("js/home/home");
require("js/home/maybe-like");
});
define("js/home/home", ["jquery","hammer","swiper","lazyload","index"], function(require, exports, module){
/**
 *  首页
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/12
 */
var $ = require("jquery"),
    Hammer = require("hammer"),
    Swiper = require("swiper"),
    lazyLoad = require("lazyload"),
    $mobileWrap = $('.mobile-wrap'),
    $overlay = $('.overlay'),
    $sideNav = $('.side-nav'),
    $subNav = $('.sub-nav'),
    bannerSwiper,
    recommendSwiper,
    hotBrandsSwiper,
    trendTopicSwiper,
    goodsSwiper;

var requestFrame,
    thisFunc,
    start = 0,
    i,
    swiperClass,
    supportCss3,
    $logotrans = $('.home-header .logo'),
    isen = true;

var navHammer, mobileWrapHammer;

require("js/home/maybe-like");

lazyLoad($('img.lazy'));

navHammer = new Hammer($('.nav-btn')[0]);
navHammer.on('tap', function(event) {
    event.preventDefault();
    $mobileWrap.addClass('menu-open');
    $overlay.show().css('opacity', 0.3);
    $sideNav.addClass('on');

    //设置boy高宽,页面不能上下滑动
    $('body').css({
        height: $(window).height(),
        width: $(window).width(),
        overflow: 'hidden'
    });

    event.srcEvent.stopPropagation();
    return false;
});

function hideSideBar() {
    if ($mobileWrap.hasClass('menu-open')) {
        $mobileWrap.removeClass('menu-open');
        $overlay.css('opacity', 0);
        $('.sub-nav').removeClass('show');
        $sideNav.removeClass('on');
        $('body').css({
            height: 'auto',
            overflow: 'auto'
        });
        setTimeout(function() {
            $('.overlay').hide();
        }, 300);
    }
}

mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
mobileWrapHammer.on('tap', function(e) {
    hideSideBar();
    e.srcEvent.stopPropagation();
    return false;
});

//点击一级导航,弹出二级导航
$sideNav.on('touchend', 'li', function (e) {
    if ($(this).find('.sub-nav').size() > 0) {
        $('.sub-nav').removeClass('show');
        $(this).find('.sub-nav').addClass('show');
    }
    e.stopPropagation();
    if (e.target.pathname === location.pathname) {
        hideSideBar();
        return false;
    }
});

//返回一级导航,收起二级导航
$subNav.each(function () {
    $(this).find('li').eq(0).on('touchend', function (e) {
        $('.sub-nav').removeClass('show');
        e.stopPropagation();
        return false;
    });
}).on('touchend', function(e) {
    if (e.currentTarget !== e.target) {
        $subNav.find('li').removeClass('current');
    }
});

//头部banner轮播
if ($('.banner-swiper').find('li').size() > 1) {
    bannerSwiper = new Swiper('.banner-swiper', {
        lazyLoading: true,
        lazyLoadingInPrevNext: true,
        loop: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        paginationClickable: true,
        slideElement: 'li',
        pagination: '.banner-top .pagination-inner'
    });
}

//热门品牌滑动
hotBrandsSwiper = new Swiper('.brands-swiper', {
    grabCursor: true,
    slidesPerView: 'auto',
    wrapperClass: 'brands-list',
    slideElement: 'li'
});

//推荐搭配滑动
recommendSwiper = new Swiper('.recommend-swiper', {
    grabCursor: true,
    slidesPerView: 'auto',
    wrapperClass: 'recommend-list',
    slideElement: 'li'
});

//潮品话题轮播
if ($('.trend-topic-swiper').find('li').size() > 1) {
    trendTopicSwiper = new Swiper('.trend-topic-swiper', {
        loop: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        paginationClickable: true,
        slideElement: 'li',
        pagination: '.trend-topic-content .pagination-inner'
    });
}

//潮流上装/经典裤装等轮播
$('.category-swiper').each(function (i, index) {
    swiperClass = 'category-swiper' + i;
    $(this).addClass(swiperClass);
    if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
        goodsSwiper = new Swiper('.' + swiperClass, {
            loop: true,
            autoplay: 3000,
            autoplayDisableOnInteraction: false,
            paginationClickable: true,
            slideElement: 'li',
            pagination: '.' + swiperClass + ' .pagination-inner'
        });
    }
});

//logo动画
requestFrame = (function () {
    var tempFunc = null,
        prefixList = ['webkit', 'moz', 'ms'];

    for (i = 0; i < prefixList.length; i++) {
        thisFunc = prefixList[i] + 'RequestAnimationFrame';
        if (window[thisFunc]) {
            supportCss3 = true;
            tempFunc = thisFunc;
        }
    }

    if (supportCss3) {
        return function (callback) {
            window[tempFunc](callback);
        };
    }
    return function (callback) {
        window.setTimeout(callback, 67);
    };
})();

function tsAnimate() {
    start = start + 10;
    $logotrans.css({
        transform: 'rotateX(' + start + 'deg)',
        '-webkit-transform': 'rotateX(' + start + 'deg)',
        '-moz-transform': 'rotateX(' + start + 'deg)'
    });
    if (start / 90 % 2 === 1) {
        if (isen) {
            $logotrans.addClass('animate');
            isen = false;
        } else {
            $logotrans.removeClass('animate');
            isen = true;
        }
    }
    if (start / 90 % 2 === 0 && start % 360 !== 0) {
        window.setTimeout(tsAnimate, 3000);
    } else {
        if (start % 360 === 0) {
            window.setTimeout(tsAnimate, 60 * 1000);
        } else {
            requestFrame(function () {
                tsAnimate();
            });
        }
    }
}

setTimeout(tsAnimate, 3000);

});
define("js/home/maybe-like", ["jquery","hammer","lazyload"], function(require, exports, module){
/**
 * “你可能喜欢”模块JS
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/12
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    tip = require("js/plugin/tip"),
    loading = require("js/plugin/loading"),
    lazyLoad = require("lazyload");

var navHammer,
    winH = $(window).height(),
    loadMoreH = $('#load-more').height(),
    $goodList = $('#goods-list'),
    searching = false,
    page = 0,
    gender = null,
    kidsType = $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
    lifestyleType = $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
    num,
    url;

var $curNav,
    index,
    $navList = $('#maybe-like-nav');

//ajax url
if (kidsType) {
    url = '/product/recom/maylikekids';
} else if (lifestyleType) {
    url = '/product/recom/maylikelife';
} else {
    gender = $('.mobile-wrap').hasClass('boys-wrap') ? '1,3' : '2,3',
    url = '/product/recom/maylike?gender=' + gender;
}

$curNav = $navList.children('.focus');

if (lifestyleType) {
    navHammer = new Hammer($navList[0]);
    navHammer.on('tap', function(e) {
        var $this = $(e.target).closest('li'),
            $goods = $('.goods-list'),
            $content;

        e.preventDefault();
        if ($this.hasClass('focus')) {
            return;
        }

        index = $this.index();

        $this.addClass('focus');
        $curNav.removeClass('focus');

        $goods.not('.hide').addClass('hide');
        $content = $goods.eq(index);
        $content.removeClass('hide');

        $curNav = $this;

        $(document).trigger('scroll'); //Trigger lazyLoad
        e.srcEvent.stopPropagation();
    });
}

loading.init($('.maybe-like'));

function search() {
    if (searching) {
        return;
    }
    searching = true;

    loading.showLoadingMask();

    //num = $goodList.find('.good-info').length;
    $.ajax({
        type: 'GET',
        url: url,
        data: {
            page: page + 1
        },
        success: function(data) {
            if (data === ' ') {
                searching = false;
                loading.hideLoadingMask();
                if (gender) {
                    if (gender === '1,3') {
                        url = '/boys/bottomBanner';
                    } else {
                        url = '/girls/bottomBanner';
                    }
                    $.ajax({
                        type: 'GET',
                        url: url,
                        success: function(data) {
                            if (data && data.img) {
                                $('#load-more-img').show();
                                $('#load-more-img a').attr('href', data.url);
                                $('#load-more-img a > img').attr('src', data.img);
                            }
                        },
                        error: function() {
                        }
                    });

                }
                return;
            }

            num = $goodList.find('.good-info').length;

            $goodList.append(data);

            // 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
            if (num === 0) {
                lazyLoad($goodList.find('.good-info').find('img.lazy'));
            } else {
                lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
            }

            searching = false;
            loading.hideLoadingMask();
            page++;
        },
        error: function() {
            tip.show('网络断开连接了~');
            searching = false;
            loading.hideLoadingMask();
        }
    });
}

$('.maybe-like p').on('touchstart', function (e) {
    search();
});

//srcoll to load more
$(window).scroll(function () {
    if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH - 50) {
        search();
    }
});
});
define("js/index/entry", ["jquery","hammer"], function(require, exports, module){
/**
 * Index打包入口
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/19
 */

require("js/index/search");
require("js/index/footer");
require("js/index/channel");
});
define("js/index/search", ["jquery","hammer"], function(require, exports, module){
/**
 * 搜索JS
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/19
 */

var $ = require("jquery"),
    Hammer = require("hammer");

var $input = $('#search-input input');

var $clear = $('#search-input .clear-input');

var $form = $('#search-form');

var $history = $('.history');

var $clearHistory = $('#clear-history');

var writeSearch = require("js/index/write-search");

var ranToken = writeSearch.getRanToken();

var chHammer, cHammer;

chHammer = new Hammer($clearHistory[0]);
chHammer.on('tap', function() {
    localStorage.removeItem('historys');

    $history.html('');
});

$input.on('input', function() {
    if ($input.val() === '') {
        $clear.addClass('hide');
    } else {
        $clear.removeClass('hide');
    }
});

cHammer = new Hammer($clear[0]);
cHammer.on('tap', function() {
    $input.val('').trigger('input');
});

//初始化历史搜索的内容
(function() {
    var html = '',
        history,
        historys, i;

    if (localStorage) {
        historys = localStorage.getItem('historys');

        if (historys && historys.length > 0) {
            historys = historys.split(ranToken);
            for (i = 0; i < historys.length; i++) {
                history = historys[i];

                if (history === '') {
                    continue;
                }

                html += '<li><a href="/?query=' + history + '">' + history + '</li>';
            }

            $history.html(html);
            $clearHistory.removeClass('hide');
        }
    }
}());

writeSearch.bindWirteLocal($form);
});
define("js/index/write-search", [], function(require, exports, module){
/**
 * 将搜索结果存localStorage
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/29
 */

var ranToken = ' ??++ ';

//获取分隔符
function getRanToken() {
    return ranToken;
}

//绑定提交前的存local操作
function bindWirteLocal($form) {
    $form.on('submit', function() {
        var query = this.query.value,
            historys;

        if (localStorage) {
            historys = localStorage.getItem('historys');

            historys = historys ? historys : '';

            if (historys.indexOf(ranToken + query + ranToken) > -1) {
                return;
            }

            if (historys === '') {
                query = ranToken + query;
            }

            historys += query + ranToken;

            localStorage.setItem('historys', historys);
        }
    });
}

exports.getRanToken = getRanToken;

exports.bindWirteLocal = bindWirteLocal;
});
define("js/index/footer", ["jquery","hammer"], function(require, exports, module){
/**
 * 底部JS
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/26
 */

var $ = require("jquery"),
    Hammer = require("hammer");

var floatLayerBtnHammer;

function downLoadApp() {
    var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
    var clickedAt = new Date();

    setTimeout(function () {
        if ((new Date()) - clickedAt < 2000) {
            window.location = appUrl;
        }
    }, 500);
}

$('#float-layer-close').on('touchend', function(e) {
    $('#float-layer-app').hide();
    window.setCookie('_float-layer-app', 'id490655927',
        {
            domain: '.yohobuy.com'
        });
    window.setCookie('_float-layer-app-close', 1,
        {
            domain: '.yohobuy.com',
            expires: 1
        });
    return false;
});

if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
    floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
    floatLayerBtnHammer.on('tap', function(e) {
        downLoadApp('bottom');
        e.srcEvent.stopPropagation();
    });

    if (!window.cookie('_float-layer-app')) {
        $('#float-layer-app').show();
    } else {
        $('#float-layer-app').hide();
    }
}

});
define("js/index/channel", ["jquery"], function(require, exports, module){
/**
 * 频道选择页面顶部搜索
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/10/28
 */
var $ = require("jquery");

var $searchBox = $('.search-box'),
    $indexSearch = $('.index-search'),
    $indexLogo = $('.index-logo');

require("js/common");

function showBigSearch() {
    $indexLogo.css({
        opacity: 0
    });
    $searchBox.css({
        width: '12.8rem'
    });
    $indexSearch.css({
        width: '15.5rem'
    });
    $('.clear-text, .no-search').show();
}

function hideBigSearch() {
    $indexLogo.css({
        opacity: 1
    });
    $searchBox.css({
        width: '8.8rem'
    });
    $indexSearch.css({
        width: '9.6rem'
    });
    $('.clear-text, .no-search').hide();
}

$searchBox.find('input').on('focus', function() {
    showBigSearch();
});

$searchBox.find('.clear-text').on('touchend', function() {
    $searchBox.find('input').val('');
});
$searchBox.find('.search-icon').on('touchend', function() {
    $indexSearch.submit();
});

$('.no-search').on('touchend', function() {
    $searchBox.find('input').val('');
    hideBigSearch();
});

window.rePosFooter && window.rePosFooter();

});
define("js/passport/entry", ["jquery"], function(require, exports, module){
/**
 * 注册、登录、密码找回打包入口
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */

//注册
require("js/passport/register/register");
require("js/passport/register/code");
require("js/passport/register/password");

//登录
require("js/passport/login/login");
require("js/passport/login/international");

//密码找回
require("js/passport/back/mobile");
require("js/passport/back/code");
require("js/passport/back/email");
require("js/passport/back/email-success");
require("js/passport/back/new-password");
});
define("js/passport/register/register", ["jquery"], function(require, exports, module){
/**
 * 注册
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var $phoneNum = $('#phone-num'),
    $countrySelect = $('#country-select'),
    $areaCode = $('#area-code'),
    $btnNext = $('#btn-next');

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

api.selectCssHack($('#country-select'));

api.bindClearEvt();

$phoneNum.bind('input', function() {
    if (trim($phoneNum.val()) === '') {
        $btnNext.addClass('disable');
    } else {
        $btnNext.removeClass('disable');
    }
});

$countrySelect.change(function() {
    $areaCode.text($countrySelect.val());
});

$btnNext.on('touchstart', function() {
    var pn = trim($phoneNum.val()),
        areaCode = $countrySelect.val();

    if ($btnNext.hasClass('disable')) {
        return;
    }

    if (api.phoneRegx[areaCode].test(pn)) {
        $.ajax({
            url: '/passport/reg/verifymobile',
            type: 'POST',
            data: {
                areaCode: areaCode.replace('+', ''),
                phoneNum: pn
            },
            success: function(data) {
                if (data.code === 200) {
                    location.href = data.data;
                } else {
                    showErrTip(data.message);
                }
            }
        });
    } else {
        showErrTip('手机号格式不正确,请重新输入');
    }
});
});
define("js/passport/api", ["jquery"], function(require, exports, module){
/**
 * 登录注册公用API
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var trim = $.trim;

//邮箱验证规则
var emailRegx = /^([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;

//手机号码验证规则
var phoneRegx = {
    '+86': /^1[35847]{1}[0-9]{9}$/,
    '+852': /^[965]{1}[0-9]{7}$/,
    '+853': /^[0-9]{8}$/,
    '+886': /^[0-9]{10}$/,
    '+65': /^[98]{1}[0-9]{7}$/,
    '+60': /^1[1234679]{1}[0-9]{8}$/,
    '+1': /^[0-9]{10}$/,
    '+82': /^01[0-9]{9}$/,
    '+44': /^7[789][0-9]{8}$/,
    '+81': /^0[9|8|7][0-9]{9}$/,
    '+61': /^[0-9]{11}$/
};

/**
 * 密码显示隐藏
 * @params opt 初始化参数
 */
function bindEyesEvt(opt) {
    var $hasEye = $('.has-eye'),
        $eye;

    if (opt && opt.status === 'open') {
        $hasEye.append('<div class="eye"></div>');
    } else {
        $hasEye.append('<div class="eye close"></div>');
    }
    $eye = $hasEye.children('.eye');

    $eye.on('touchstart', function(e) {
        var $this = $(this),
            $pwd = $this.siblings('.pwd');

        e.preventDefault();
        $this.toggleClass('close');

        //切换密码显示和文本显示
        if ($this.hasClass('close')) {
            $pwd.attr('type', 'password');
        } else {
            $pwd.attr('type', 'text');
        }
        $pwd.focus();
    });
}

// 清空账号显示
function bindClearEvt() {
    var $hasClear = $('.has-clear'),
        $clear;

    $hasClear.append('<div class="clear-input"></div>');
    $clear = $hasClear.children('.clear-input');

    $clear.on('touchstart', function(e) {
        var $input = $clear.siblings('.input');

        $input.val('').trigger('input').focus();
        e.preventDefault();
    });

    //反向逻辑
    $hasClear.children('.input').bind('input', function() {
        var $this = $(this),
            $thisClear = $this.siblings('.clear-input'),
            val = trim($this.val());

        if (val === '') {
            $thisClear.hide();
        } else {
            $thisClear.show();
        }
    });
}

// 密码长度验证
function pwdValidate(pwd) {
    if (pwd.length >= 6 && pwd.length <= 20) {
        return true;
    }
    return false;
}

// hack for resolving direction:rtl didn't work in android uc
function selectCssHack($countrySelect) {
    var u = navigator.userAgent;

    function autoSelectWidth() {
        var wordCount = $countrySelect.find('option:selected').text().length;

        switch (wordCount) {

            //分别有2,3,4个汉字的情况
            case 2:
                $countrySelect.outerWidth(90);
                break;
            case 3:
                $countrySelect.outerWidth(110);
                break;
            default:
                $countrySelect.outerWidth(130);
        }
    }

    if (u.match(/uc/i) && u.match(/android/i)) {
        $countrySelect.change(function() {
            autoSelectWidth();
        });
    } else {
        $countrySelect.removeClass('in-android-uc');
    }
}

//Exports APIs
module.exports = {
    emailRegx: emailRegx,
    phoneRegx: phoneRegx,
    bindEyesEvt: bindEyesEvt,
    bindClearEvt: bindClearEvt,
    pwdValidate: pwdValidate,
    selectCssHack: selectCssHack
};
});
define("js/passport/register/code", ["jquery"], function(require, exports, module){
/**
 * 注册-验证码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */

require("js/passport/code")(true);
});
define("js/passport/code", ["jquery"], function(require, exports, module){
/**
 * 注册/找回密码-验证码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

module.exports = function(useInRegister) {
    var $captcha = $('#captcha'),
        $btnNext = $('#btn-next'),
        $captchaTip = $('#captcha-tip'),
        phoneNum = $('#phone-num').val(),
        areaCode = $('#area-code').val().replace('+', '');

    var api = require("js/passport/api");
    var tip = require("js/plugin/tip");

    var trim = $.trim;
    var showErrTip = tip.show;

    var urlMid = useInRegister ? 'reg' : 'back';

    function countDown() {
        var count = 59,
            itime;

        itime = setInterval(function() {
            if (count === 0) {
                $captchaTip.text('重发验证码').removeClass('disable');
                clearInterval(itime);
            } else {
                $captchaTip.text('重发验证码 (' + count-- + '秒)');
            }
        }, 1000);
    }

    api.bindClearEvt();

    $captcha.bind('input', function() {
        if (trim($captcha.val()) !== '') {
            $btnNext.removeClass('disable');
        } else {
            $btnNext.addClass('disable');
        }
    });

    //重新发送验证码
    $captchaTip.on('touchstart', function() {
        if ($captchaTip.hasClass('disable')) {
            return;
        }

        $.ajax({
            type: 'POST',
            url: '/passport/' + urlMid + '/sendcode',
            data: {
                phoneNum: phoneNum,
                areaCode: areaCode
            },
            success: function(data) {
                if (data.code === 200) {
                    $captchaTip.text('重发验证码 (60秒)').addClass('disable');
                    countDown();
                } else {

                    //验证码不正确,显示提示
                    showErrTip(data.message);
                }
            }
        });
    });

    $btnNext.on('touchstart', function() {
        if ($btnNext.hasClass('disable')) {
            return;
        }

        $.ajax({
            type: 'POST',
            url: '/passport/' + urlMid + '/verifycode',
            data: {
                phoneNum: phoneNum,
                areaCode: areaCode,
                code: trim($captcha.val()),
                token: $('#token').val()
            },
            success: function(data) {
                if (data.code === 200) {
                    location.href = data.data;
                } else {

                    //验证码不正确,显示提示
                    showErrTip(data.message);
                }
            }
        });
    });

    countDown();
};
});
define("js/passport/register/password", ["jquery"], function(require, exports, module){
/**
 * 注册-密码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var $pwd = $('#pwd'),
    $btnSure = $('#btn-sure');

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

api.bindEyesEvt({
    status: 'open' //默认眼睛打开
});

$pwd.bind('input', function() {
    if (trim($pwd.val()) === '') {
        $btnSure.addClass('disable');
    } else {
        $btnSure.removeClass('disable');
    }
});

$btnSure.on('touchstart', function() {
    var pwd = trim($pwd.val());

    if ($btnSure.hasClass('disable')) {
        return;
    }

    if (api.pwdValidate(pwd) === false) {
        showErrTip('密码6-20位,请重新输入');
    } else {
        $.ajax({
            type: 'POST',
            url: '/passport/reg/setpassword',
            data: {
                password: pwd,
                phoneNum: $('#phone-num').val(),
                areaCode: $('#area-code').val(),
                token: $('#token').val()
            },
            success: function(data) {
                if (data.code === 200) {
                    showErrTip('注册成功');

                    //1000ms后跳转页面
                    setTimeout(function() {
                        location.href = data.data;
                    }, 1000);
                } else {
                    if (data.code === 401 || data.code === 404 || data.code === 505) {
                        showErrTip(data.message);
                    } else {
                        showErrTip(data.message);
                        setTimeout(function() {
                            location.href = data.data;
                        }, 1000);
                    }
                }
            }
        });
    }
});
});
define("js/passport/login/login", ["jquery"], function(require, exports, module){
/**
 * 登录
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/9/30
 */
var $ = require("jquery");

var $account = $('#account'),
    $pwd = $('#pwd'),
    $loginBtn = $('#btn-login'),

    $mask = $('#retrive-pwd-mask'),
    $ways = $('#retrive-pwd-ways'),

    accPass = false,
    pwdPass = false;

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

//登录按钮状态切换
function switchLoginBtnStatus() {
    if (accPass && pwdPass) {
        $loginBtn.removeClass('disable');
    } else {
        $loginBtn.addClass('disable');
    }
}

//显示找回密码面板
function showRetrivePanel() {
    $mask.show();
    $ways.show();
}

//隐藏找回密码面板
function hideRetrivePanel() {
    $mask.hide();
    $ways.hide();
}

//密码显示与隐藏
api.bindEyesEvt();

//清空账号输入框
api.bindClearEvt();

$account.bind('input', function() {
    if (trim($account.val()) !== '') {
        accPass = true;
    } else {
        accPass = false;
    }
    switchLoginBtnStatus();
});

$pwd.bind('input', function() {
    if (trim($pwd.val()) === '') {
        pwdPass = false;
    } else {
        pwdPass = true;
    }
    switchLoginBtnStatus();
});


// Login
$loginBtn.on('touchstart', function() {
    var acc = trim($account.val()),
        pwd = trim($pwd.val());

    if ($loginBtn.hasClass('disable')) {
        return;
    }

    //验证账号(数字或者邮箱)和密码合理性
    if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
        $.ajax({
            type: 'POST',
            url: '/passport/login/auth',
            data: {
                account: acc,
                password: pwd
            },
            success: function(data) {
                if (data.code === 200) {
                    showErrTip('登录成功');

                    //1s后跳转页面
                    setTimeout(function() {
                        location.href = data.data;
                    }, 1000);
                } else {
                    showErrTip(data.message);
                }
            },
            error: function() {
                showErrTip('网络断开连接啦~');
            }
        });
    } else {
        showErrTip('账号或密码有错误,请重新输入');
    }
});


$('#forget-pwd').on('touchstart', function() {
    showRetrivePanel();
});

$mask.on('touchstart', function() {
    hideRetrivePanel();
});

$('#cancel-retrive').on('touchstart', function(e) {
    e.preventDefault();
    hideRetrivePanel();
});

//对初始有默认值的情况去初始化登录按钮状态
$account.trigger('input');
$pwd.trigger('input');
});
define("js/passport/login/international", ["jquery"], function(require, exports, module){
/**
 * 国际账号登录
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var $phoneNum = $('#phone-num'),
    $countrySelect = $('#country-select'),
    $areaCode = $('#area-code'),
    $pwd = $('#pwd'),
    $loginBtn = $('#btn-login'),

    pnPass = false,
    pwdPass = false;

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

//登录按钮状态切换
function switchLoginBtnStatus() {
    if (pnPass && pwdPass) {
        $loginBtn.removeClass('disable');
    } else {
        $loginBtn.addClass('disable');
    }
}

//Android-UC下显示select的direction:rtl无效的临时解决办法
api.selectCssHack($countrySelect);

//显示隐藏密码
api.bindEyesEvt();

//清空手机号码
api.bindClearEvt();

$phoneNum.bind('input', function() {
    if (trim($phoneNum.val()) === '') {
        pnPass = false;
    } else {
        pnPass = true;
    }

    switchLoginBtnStatus();
});

$pwd.bind('input', function() {
    var pwd = trim($pwd.val());

    if (pwd === '') {
        pwdPass = false;
    } else {
        pwdPass = true;
    }

    switchLoginBtnStatus();
});

$countrySelect.change(function() {
    $areaCode.text($countrySelect.val());
});

$loginBtn.on('touchstart', function() {
    var pn = trim($phoneNum.val()),
        areaCode = $countrySelect.val(),
        pwd = trim($pwd.val());

    if ($loginBtn.hasClass('disable')) {
        return;
    }

    if (api.phoneRegx[areaCode].test(pn) && api.pwdValidate(pwd)) {
        $.ajax({
            type: 'POST',
            url: '/passport/login/auth',
            data: {
                areaCode: areaCode.replace('+', ''),
                account: pn,
                password: pwd
            },
            success: function(data) {
                if (data.code === 200) {
                    showErrTip('登录成功');

                    //1000ms后跳转页面
                    setTimeout(function() {
                        location.href = data.data;
                    }, 1000);
                } else {
                    showErrTip(data.message);
                }
            },
            error: function() {
                showErrTip('网络断开连接啦~');
            }
        });
    } else {
        showErrTip('账号或密码有错误,请重新输入');
    }
});

//对初始有默认值的情况去初始化登录按钮状态
$phoneNum.trigger('input');
$pwd.trigger('input');
});
define("js/passport/back/mobile", ["jquery"], function(require, exports, module){
/**
 * 找回密码-手机
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var $phoneNum = $('#phone-num'),
    $countrySelect = $('#country-select'),
    $areaCode = $('#area-code'),
    $btnNext = $('#btn-next');

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

api.selectCssHack($('#country-select'));

api.bindClearEvt();

$phoneNum.bind('input', function() {
    if (trim($phoneNum.val()) === '') {
        $btnNext.addClass('disable');
    } else {
        $btnNext.removeClass('disable');
    }
});

$countrySelect.change(function() {
    $areaCode.text($countrySelect.val());
});

$btnNext.on('touchstart', function() {
    var pn = trim($phoneNum.val()),
        area = $countrySelect.val();

    if ($btnNext.hasClass('disable')) {
        return;
    }

    if (api.phoneRegx[area].test(pn)) {
        $.ajax({
            url: '/passport/back/sendcode',
            type: 'POST',
            data: {
                areaCode: area.replace('+', ''),
                phoneNum: pn
            },
            success: function(data) {
                if (data.code === 200) {
                    location.href = data.data;
                } else {
                    showErrTip(data.message);
                }
            }
        });
    } else {
        showErrTip('手机号格式不正确,请重新输入');
    }
});
});
define("js/passport/back/code", ["jquery"], function(require, exports, module){
/**
 * 找回密码-验证码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */

require("js/passport/code")(false);
});
define("js/passport/back/email", ["jquery"], function(require, exports, module){
/**
 * 找回密码-邮箱找回
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var $email = $('#email'),
    $btnSure = $('#btn-sure');

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

api.bindClearEvt();

$email.bind('input', function() {
    if (trim($email.val()) === '') {
        $btnSure.addClass('disable');
    } else {
        $btnSure.removeClass('disable');
    }
});

$btnSure.on('touchstart', function() {
    var email = trim($email.val());

    if ($btnSure.hasClass('disable')) {
        return;
    }

    if (api.emailRegx.test(email)) {
        $.ajax({
            url: '/passport/back/sendemail',
            type: 'POST',
            data: {
                email: email
            },
            success: function(data) {
                if (data.code === 200) {
                    location.href = data.data;
                } else {
                    showErrTip(data.message);
                }
            }
        });
    } else {
        showErrTip('邮箱格式不正确,请重新输入');
    }
});
});
define("js/passport/back/email-success", ["jquery"], function(require, exports, module){
/**
 * 找回密码-邮箱找回成功
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */

var $ = require("jquery");

var $resend = $('#resend');

var tip = require("js/plugin/tip"),
    showErrTip = tip.show;

$resend.on('touchstart', function(e) {
    e.preventDefault();

    $.ajax({
        url: $resend.data('url'),
        type: 'GET',
        success: function(data) {
            if (data.code === 200) {
                showErrTip(data.message);
            } else {
                showErrTip(data.message);
            }
        }
    });
});
});
define("js/passport/back/new-password", ["jquery"], function(require, exports, module){
/**
 * 密码找回-新密码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/8
 */
var $ = require("jquery");

var $pwd = $('#pwd'),
    $btnOk = $('#btn-ok');

var api = require("js/passport/api");
var tip = require("js/plugin/tip");

var trim = $.trim;
var showErrTip = tip.show;

var $phoneNum = $('#phone-num');

api.bindEyesEvt();

$pwd.bind('input', function() {
    if (trim($pwd.val()) === '') {
        $btnOk.addClass('disable');
    } else {
        $btnOk.removeClass('disable');
    }
});

$btnOk.on('touchstart', function() {
    var pwd = trim($pwd.val()),
        mobileBack = true,
        setting,
        url;

    if ($btnOk.hasClass('disable')) {
        return;
    }

    setting = {
        password: pwd
    };

    if ($phoneNum.length === 0) {
        mobileBack = false;
    }

    if (mobileBack) {
        $.extend(setting, {
            phoneNum: $phoneNum.val(),
            areaCode: $('#areaCode').val(),
            token: $('#token').val()
        });

        url = '/passport/back/passwordByMobile';
    } else {
        $.extend(setting, {
            code: $('#email-code').val()
        });

        url = '/passport/back/passwordByEmail';
    }


    if (api.pwdValidate(pwd)) {
        $.ajax({
            type: 'POST',
            url: url,
            data: setting,
            success: function(data) {
                if (data.code === 200) {
                    showErrTip('密码修改成功');

                    //1000ms后跳转页面
                    setTimeout(function() {
                        location.href = data.data;
                    }, 1000);
                } else {
                    showErrTip(data.message);
                }
            }
        });
    } else {
        showErrTip('密码6-20位,请重新输入');
    }
});
});
define("js/product/entry", ["jquery","swiper","hammer","lazyload","index"], function(require, exports, module){
/**
 *  产品打包入口
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/12
 */

require("js/product/newsale/newarrival");
require("js/product/newsale/discount");
require("js/product/list");
require("js/product/detail/detail");
});
define("js/product/newsale/newarrival", ["jquery","swiper","hammer","lazyload","index"], function(require, exports, module){
/**
 *  新品到着
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/24
 */

var $ = require("jquery"),
    Swiper = require("swiper"),
    Hammer = require("hammer"),
    lazyLoad = require("lazyload");

var swiper,
    $ngc,
    $pgc,
    $dgc;

var tip = require("js/plugin/tip"),
    filter = require("js/plugin/filter"),
    loading = require("js/plugin/loading");

var $goodsContainer = $('#goods-container'),
    $goodsChildren = $goodsContainer.children(),
    $ngc = $($goodsChildren.get(0)),
    $pgc = $($goodsChildren.get(1)).addClass('hide'),
    $dgc = $($goodsChildren.get(2)).addClass('hide');

var winH = $(window).height(),
    noResult = '<p class="no-result">未找到相关搜索结果</p>';

//默认筛选条件
var defaultOpt = {
    gender: $('#gender').val(),
    brand: $('#brand').val(),
    sort: $('#sort').val(),
    color: $('#color').val(),
    size: $('#size').val(),
    price: $('#price').val(),
    discount: $('#discount').val(),
    limit: $('#limit').val(),
    channel: $('#channel').val(),
    p_d: $('#p_d').val(),
    dayLimit: 1
};

var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置

var now = new Date(),
    month = now.getMonth() + 1,
    date = now.getDate();

var $listNav = $('#list-nav'),

    //导航数据信息
    navInfo = {
        today: {
            reload: true,
            page: 0,
            end: false
        },
        week: {
            reload: true,
            page: 0,
            end: false
        },
        sale: {
            reload: true,
            page: 0,
            end: false
        }
    },
    $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
    navHammer,
    searching;

require("js/product/suspend-cart"); //悬浮购物车

$('#today a').text(month + '月' + date + '号');

if ($('.swiper-container .swiper-slide').length > 1) {
    swiper = new Swiper('.swiper-container', {
        lazyLoading: true,
        lazyLoadingInPrevNext: true,
        loop: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        paginationClickable: true,
        pagination: '.swiper-pagination'
    });
}

/**
 * 筛选注册的回调,筛选子项点击后逻辑
 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
 * @param opt {type, id}
 */
function search(opt) {
    var setting = {},
        ext,
        att,
        nav, navType,
        dayLimit,
        page;

    if (searching) {
        return;
    }

    if (opt) {

        //筛选项变更则重置reload为true
        for (att in navInfo) {
            if (navInfo.hasOwnProperty(att)) {
                navInfo[att].reload = true;
            }
        }

        //处理active状态
        $listNav.children('.active').removeClass('active');
        $pre.addClass('active');

        switch (opt.type) {
            case 'gender':
                ext = {
                    gender: opt.id
                };
                break;
            case 'brand':
                ext = {
                    brand: opt.id
                };
                break;
            case 'sort':
                ext = {
                    sort: opt.id
                };
                break;
            case 'color':
                ext = {
                    color: opt.id
                };
                break;
            case 'size':
                ext = {
                    size: opt.id
                };
                break;
            case 'price':
                ext = {
                    price: opt.id
                };
                break;
            case 'discount':
                ext = {
                    discount: opt.id
                };
                break;
            case 'limit':
                ext = {
                    limit: opt.id
                };
                break;
            case 'channel':
                ext = {
                    channel: opt.id
                };
                break;
            case 'p_d':
                ext = {
                    p_d: opt.id
                };
                break;
        }

        $.extend(defaultOpt, ext); //扩展筛选项
    }

    //导航类别
    if ($pre.hasClass('today')) {
        navType = 'today';
        dayLimit = 1;
    } else if ($pre.hasClass('week')) {
        navType = 'week';
        dayLimit = 2;
    } else if ($pre.hasClass('sale')) {
        navType = 'sale';
        dayLimit = 3;
    }

    nav = navInfo[navType];

    page = nav.page + 1;
    if (nav.reload) {
        page = 1;
    } else if (nav.end) {

        //不需要重新加载并且数据请求结束
        return;
    }

    $.extend(setting, defaultOpt, {
        dayLimit: dayLimit,
        page: page
    });

    searching = true;
    loading.showLoadingMask();

    $.ajax({
        type: 'GET',
        url: '/product/newsale/selectNewSale',
        data: setting,
        success: function(data) {
            var $container,
                num;

            switch (navType) {
                case 'today':
                    $container = $ngc;
                    break;
                case 'week':
                    $container = $pgc;
                    break;
                case 'sale':
                    $container = $dgc;
                    break;
            }

            if (data === ' ') {
                nav.end = true;
                if (nav.reload) {
                    $container.html(noResult);
                }
            } else {
                if (nav.reload) {
                    $container.html(data);
                    lazyLoad($container.find('.lazy'));
                } else {
                    num = $container.find('.good-info').length;
                    $container.append(data);

                    //lazy good-infos who append in
                    lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
                }

            }

            nav.reload = false;
            nav.page = page;

            searching = false;
            loading.hideLoadingMask();

            window.rePosFooter();
        },
        error: function() {
            tip.show('网络断开连接了~');
            searching = false;
            loading.hideLoadingMask();
        }
    });

}

$.ajax({
    type: 'GET',
    url: '/product/newsale/filter',
    data: defaultOpt,
    success: function(data) {
        $goodsContainer.append(data);

        //初始化filter&注册filter回调
        filter.initFilter({
            fCbFn: search,
            hCbFn: function() {

                //切换active状态到$pre上
                $pre.addClass('active');
                $pre.siblings('.filter').removeClass('active');
            }
        });
    }
});
lazyLoad($('.lazy'));

//导航栏点击逻辑说明:
//1.点击非active项时切换active状态
//2.价格和折扣active状态时继续点击切换排序
//3.筛选无active时点击展开筛选面板
//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
//5.当前active为筛选并且点击其他项时,隐藏筛选面板
navHammer = new Hammer($listNav[0]);
navHammer.on('tap', function(e) {
    var $this = $(e.target).closest('li'),
        nav,
        navType,
        $active;

    e.preventDefault();
    if ($this.hasClass('filter')) {

        //筛选面板切换状态
        if ($this.hasClass('active')) {
            filter.hideFilter();

            //点击筛选钱的active项回复active
            $pre.addClass('active');
            $this.removeClass('active');
        } else {
            $pre = $this.siblings('.active');

            $pre.removeClass('active');
            $this.addClass('active');
            filter.showFilter();
        }
    } else {

        if ($this.hasClass('today')) {
            navType = 'today';
        } else if ($this.hasClass('week')) {
            navType = 'week';
        } else if ($this.hasClass('sale')) {
            navType = 'sale';
        }

        nav = navInfo[navType];

        if (!($this.hasClass('active'))) {

            $active = $this.siblings('.active');

            $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项

            if ($active.hasClass('filter')) {

                //若之前active项为筛选,则隐藏筛选面板
                filter.hideFilter();
            } else {

                //切换container显示
                $goodsContainer.children('.container:not(.hide)').addClass('hide');

                switch (navType) {
                    case 'today':
                        $ngc.removeClass('hide');
                        break;

                    case 'week':
                        $pgc.removeClass('hide');
                        break;

                    case 'sale':
                        $dgc.removeClass('hide');
                        break;
                }

                //重置筛选项
                filter.resetFilter();
                defaultOpt = $.extend({}, storeOpt);
            }

            $active.removeClass('active');
            $this.addClass('active');
        }

        if (nav.reload) {
            search();
        }
    }
    e.srcEvent.stopPropagation();
});

$(window).scroll(function() {

    //当scroll到1/4$goodsContainer高度后继续请求下一页数据
    if ($(window).scrollTop() + winH >
        $(document).height() - 0.25 * $goodsContainer.height() - 50) {
        if ($pre !== undefined) {
            search();
        }
    }
});

//初始请求最新第一页数据
search();

});
define("js/plugin/filter", ["jquery","hammer"], function(require, exports, module){
/**
 * 筛选JS
 * 暴露三个接口:注册回调、显示filter、隐藏filter
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/19
 */

var $ = require("jquery"),
    Hammer = require("hammer");

var $filter;

var fCbFn, hCbFn; //筛选和关闭的回调

var missStatus; //是否忽略选中状态

//隐藏筛选界面
function hideFilter() {
    $filter.addClass('hide');
}

//显示筛选界面
function showFilter() {
    $filter.removeClass('hide');
}

//主筛选项Tap事件句柄
function classifyTapEvt($this) {
    if ($this.hasClass('active')) {
        return;
    }

    $this.siblings('.active').removeClass('active');

    $this.addClass('active');
}

//子筛选项选中处理
function setSubClassify($this) {
    var $sub = $this.closest('.sub-classify');

    var $shower = $sub.siblings('.shower');

    var html, shower;

    if ($this.hasClass('chosed')) {
        return $sub;
    }

    $sub.children('.chosed').removeClass('chosed');
    $this.addClass('chosed');

    html = $.trim($this.html());

    shower = $.trim($shower.html());

    $shower.html(
        shower.substring(0, shower.indexOf('</span>') + 7) + //拆分出shower的title
        html.substring(0, html.indexOf('<i')) //拆分选中筛选值
    );

    if ($this.index() === 0) {
        $shower.addClass('default');
    } else {
        $shower.removeClass('default');
    }

    return $sub;
}

//子筛选项Tap句柄
function subClassifyTapEvt($this) {
    var id = $this.data('id');

    var $sub;

    $sub = setSubClassify($this);

    if (fCbFn) {
        fCbFn({
            type: $sub.data('type'),
            id: id
        });
    }

    hideFilter();
}

//初始化筛选
function initFilter(opt) {
    var filterHammer;

    //注册回调
    fCbFn = opt.fCbFn;
    hCbFn = opt.hCbFn;

    missStatus = opt.missStatus;


    $filter = $('.filter-mask');

    filterHammer = new Hammer($filter[0]);
    filterHammer.on('tap', function(e) {
        var $this = $(e.target),
            $cur;

        e.preventDefault();//防止透点

        if ($this.closest('.filter-body').length > 0) {
            $cur = $this.closest('.sub-item');
            if ($cur.length > 0) {

                //tap subclassify
                $cur = $this.closest('li');

                subClassifyTapEvt($cur);
            } else {

                //tap classify
                $cur = $this.closest('.classify-item');

                e.srcEvent.stopPropagation();

                classifyTapEvt($cur);
            }
        } else {
            hideFilter();

            if (hCbFn) {
                hCbFn();
            }
        }
    });
}

//重置筛选面板
function resetFilter() {
    if (typeof $filter === 'undefined') {
        return;
    }

    //重置子筛选项
    $('.sub-classify').each(function() {
        setSubClassify($(this).children(':first-child'));
    });

    //重置主筛选项
    classifyTapEvt($('.classify > :first-child'));
}

exports.initFilter = initFilter;

exports.showFilter = showFilter;

exports.hideFilter = hideFilter;

exports.resetFilter = resetFilter;
});
define("js/product/suspend-cart", ["jquery"], function(require, exports, module){
/**
 * 悬浮购物车
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/1
 */

var $ = require("jquery");

var $cart = $('#suspend-cart');

$.ajax({
    type: 'GET',
    url: '/cart/index/count',
    success: function(data) {
        if (data.code === 200) {
            $cart.find('.cart-count').html(data.data.cart_good_count).removeClass('hide');
        }
    }
});
});
define("js/product/newsale/discount", ["jquery","swiper","hammer","lazyload","index"], function(require, exports, module){
/**
 * 商品列表页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/20
 */

var $ = require("jquery"),
    Swiper = require("swiper"),
    Hammer = require("hammer"),
    lazyLoad = require("lazyload");

var swiper;

var tip = require("js/plugin/tip"),
    filter = require("js/plugin/filter"),
    loading = require("js/plugin/loading");

var $goodsContainer = $('#goods-container'),
    $goodsChildren = $goodsContainer.children(),
    $ngc = $($goodsChildren.get(0)),
    $pgc = $($goodsChildren.get(1)),
    $dgc = $($goodsChildren.get(2));

var winH = $(window).height(),
    noResult = '<p class="no-result">未找到相关搜索结果</p>';

//默认筛选条件
var defaultOpt = {
    gender: $('#gender').val(),
    brand: $('#brand').val(),
    sort: $('#sort').val(),
    color: $('#color').val(),
    size: $('#size').val(),
    price: $('#price').val(),
    discount: $('#discount').val()
};

var $listNav = $('#list-nav'),

    //导航数据信息
    navInfo = {
        newest: {
            order: 1,
            reload: true,
            page: 0,
            end: false
        },
        price: {
            order: 0,
            reload: true,
            page: 0,
            end: false
        },
        discount: {
            order: 0,
            reload: true,
            page: 0,
            end: false
        }
    },
    $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
    navHammer,
    searching;

require("js/product/suspend-cart"); //悬浮购物车

if ($('.swiper-container .swiper-slide').length > 1) {
    swiper = new Swiper('.swiper-container', {
        lazyLoading: true,
        lazyLoadingInPrevNext: true,
        loop: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        paginationClickable: true,
        pagination: '.swiper-pagination'
    });
}

/**
 * 筛选注册的回调,筛选子项点击后逻辑
 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
 * @param opt {type, id}
 */
function search(opt) {
    var setting = {},
        ext,
        att,
        nav, navType,
        page;

    if (searching) {
        return;
    }

    if (opt) {

        //筛选项变更则重置reload为true
        for (att in navInfo) {
            if (navInfo.hasOwnProperty(att)) {
                navInfo[att].reload = true;
            }
        }

        //处理active状态
        $listNav.children('.active').removeClass('active');
        $pre.addClass('active');

        switch (opt.type) {
            case 'gender':
                ext = {
                    gender: opt.id
                };
                break;
            case 'brand':
                ext = {
                    brand: opt.id
                };
                break;
            case 'sort':
                ext = {
                    sort: opt.id
                };
                break;
            case 'color':
                ext = {
                    color: opt.id
                };
                break;
            case 'size':
                ext = {
                    size: opt.id
                };
                break;
            case 'price':
                ext = {
                    price: opt.id
                };
                break;
            case 'discount':
                ext = {
                    discount: opt.id
                };
                break;
        }

        $.extend(defaultOpt, ext); //扩展筛选项
    }


    //导航类别
    if ($pre.hasClass('new')) {
        navType = 'newest';
    } else if ($pre.hasClass('price')) {
        navType = 'price';
    } else if ($pre.hasClass('discount')) {
        navType = 'discount';
    }

    nav = navInfo[navType];

    page = nav.page + 1;
    if (nav.reload) {
        page = 1;
    } else if (nav.end) {

        //不需要重新加载并且数据请求结束
        return;
    }

    $.extend(setting, defaultOpt, {
        type: navType,
        order: nav.order,
        page: page
    });

    searching = true;
    loading.showLoadingMask();

    $.ajax({
        type: 'GET',
        url: '/product/newsale/selectNewSale',
        data: setting,
        success: function(data) {
            var $container,
                num;

            switch (navType) {
                case 'newest':
                    $container = $ngc;
                    break;
                case 'price':
                    $container = $pgc;
                    break;
                case 'discount':
                    $container = $dgc;
                    break;
            }

            if (data === ' ') {
                nav.end = true;

                if (nav.reload) {
                    $container.html(noResult);
                }
            } else {
                if (nav.reload) {
                    $container.html(data);
                    lazyLoad($container.find('.lazy'));
                } else {
                    num = $container.find('.good-info').length;
                    $container.append(data);

                    //lazy good-infos who append in
                    lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
                }
            }

            nav.reload = false;
            nav.page = page;

            searching = false;
            loading.hideLoadingMask();

            window.rePosFooter();
        },
        error: function() {
            tip.show('网络断开连接了~');
            searching = false;
            loading.hideLoadingMask();
        }
    });

}

$.ajax({
    type: 'GET',
    url: '/product/newsale/filter',
    data: defaultOpt,
    success: function(data) {
        $goodsContainer.append(data);

        //初始化filter&注册filter回调
        filter.initFilter({
            fCbFn: search,
            hCbFn: function() {

                //切换active状态到$pre上
                $pre.addClass('active');
                $pre.siblings('.filter').removeClass('active');
            },
            missStatus: true
        });
    }
});
lazyLoad($('.lazy'));

//导航栏点击逻辑说明:
//1.点击非active项时切换active状态
//2.价格和折扣active状态时继续点击切换排序
//3.筛选无active时点击展开筛选面板
//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
//5.当前active为筛选并且点击其他项时,隐藏筛选面板
navHammer = new Hammer($listNav[0]);
navHammer.on('tap', function(e) {
    var $this = $(e.target).closest('li'),
        nav,
        navType,
        $active;

    e.preventDefault();

    if (typeof $this === 'undefined' || $this.length === 0) {
        return;
    }

    if ($this.hasClass('filter')) {

        //筛选面板切换状态
        if ($this.hasClass('active')) {
            filter.hideFilter();

            //点击筛选钱的active项回复active
            $pre.addClass('active');
            $this.removeClass('active');
        } else {
            $pre = $this.siblings('.active');

            $pre.removeClass('active');
            $this.addClass('active');

            filter.showFilter();
        }
    } else {

        if ($this.hasClass('new')) {
            navType = 'newest';
        } else if ($this.hasClass('price')) {
            navType = 'price';
        } else if ($this.hasClass('discount')) {
            navType = 'discount';
        }

        nav = navInfo[navType];

        if ($this.hasClass('active')) {

            //最新无排序切换
            if ($this.hasClass('new')) {
                return;
            }

            if ($this.hasClass('price') || $this.hasClass('discount')) {

                // 价格/折扣切换排序状态
                $this.find('.icon > .iconfont').toggleClass('cur');
                $pre = $this; //更新pre为当前项
                nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
                nav.order = nav.order === 0 ? 1 : 0; //切换排序
            }
        } else {
            $active = $this.siblings('.active');

            $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项

            if ($active.hasClass('filter')) {

                //若之前active项为筛选,则隐藏筛选面板
                filter.hideFilter();
            } else {

                //切换container显示
                $goodsContainer.children('.container:not(.hide)').addClass('hide');

                switch (navType) {
                    case 'newest':
                        $ngc.removeClass('hide');
                        break;

                    case 'price':
                        $pgc.removeClass('hide');
                        break;

                    case 'discount':
                        $dgc.removeClass('hide');
                        break;
                }
            }

            $active.removeClass('active');
            $this.addClass('active');
        }

        if (nav.reload) {
            search();
        }
    }
    e.srcEvent.stopPropagation();
});

$(window).scroll(function() {

    //当scroll到1/4$goodsContainer高度后继续请求下一页数据
    if ($(window).scrollTop() + winH >
        $(document).height() - 0.25 * $goodsContainer.height() - 50) {
        if ($pre !== undefined) {
            search();
        }
    }
});

//初始请求最新第一页数据
search();

});
define("js/product/list", ["jquery","hammer","lazyload"], function(require, exports, module){
/**
 * 商品列表页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/20
 */

var $ = require("jquery"),
    Hammer = require("hammer"),
    lazyLoad = require("lazyload");

//品牌页参数
var $brandHeader = $('#brand-header'),
    $introBox = $('#intro-box');

var filter = require("js/plugin/filter");

var writeSearch = require("js/index/write-search");

var tip = require("js/plugin/tip");
var loading = require("js/plugin/loading");

var $goodsContainer = $('#goods-container'),
    $ngc = $goodsContainer.children('.new-goods'),
    $pgc = $goodsContainer.children('.price-goods'),
    $dgc = $goodsContainer.children('.discount-goods');

var winH = $(window).height();

//默认筛选条件
var defaultOpt = {
    gender: $('#gender').val(),
    brand: $('#brand').val(),
    sort: $('#sort').val(),
    color: $('#color').val(),
    size: $('#size').val(),
    price: $('#price').val(),
    discount: $('#discount').val(),
    query: $('#query').val()
};

var $listNav = $('#list-nav'),

    //导航数据信息
    navInfo = {
        newest: {
            order: 1,
            reload: true,
            page: 0,
            end: false
        },
        price: {
            order: 0,
            reload: true,
            page: 0,
            end: false
        },
        discount: {
            order: 0,
            reload: true,
            page: 0,
            end: false
        }
    },
    $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
    searching,
    navHammer,
    btnIntroHammer,
    introHammer,
    brandColHammer;

/**
 * 筛选注册的回调,筛选子项点击后逻辑
 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
 * @param opt {type, id}
 */
function search(opt) {
    var setting = {},
        ext,
        att,
        nav, navType,
        page;

    if (searching) {
        return;
    }

    if (opt) {

        //筛选项变更则重置reload为true
        for (att in navInfo) {
            if (navInfo.hasOwnProperty(att)) {
                navInfo[att].reload = true;
            }
        }

        //处理active状态
        $listNav.children('.active').removeClass('active');
        $pre.addClass('active');

        switch (opt.type) {
            case 'gender':
                ext = {
                    gender: opt.id
                };
                break;
            case 'brand':
                ext = {
                    brand: opt.id
                };
                break;
            case 'sort':
                ext = {
                    sort: opt.id
                };
                break;
            case 'color':
                ext = {
                    color: opt.id
                };
                break;
            case 'size':
                ext = {
                    size: opt.id
                };
                break;
            case 'price':
                ext = {
                    price: opt.id
                };
                break;
            case 'discount':
                ext = {
                    discount: opt.id
                };
                break;
        }

        $.extend(defaultOpt, ext); //扩展筛选项
    }

    //导航类别
    if ($pre.hasClass('new')) {
        navType = 'newest';
    } else if ($pre.hasClass('price')) {
        navType = 'price';
    } else if ($pre.hasClass('discount')) {
        navType = 'discount';
    }

    nav = navInfo[navType];

    page = nav.page + 1;
    if (nav.reload) {
        page = 1;
    } else if (nav.end) {

        //不需要重新加载并且数据请求结束
        return;
    }

    $.extend(setting, defaultOpt, {
        type: navType,
        order: nav.order,
        page: page
    });

    searching = true;
    loading.showLoadingMask();

    $.ajax({
        type: 'GET',
        url: '/index/search/search',
        data: setting,
        success: function(data) {
            var noResult = '<p class="no-result">未找到相关搜索结果</p>',
                num,
                $container;

            switch (navType) {
                case 'newest':
                    $container = $ngc;
                    break;
                case 'price':
                    $container = $pgc;
                    break;
                case 'discount':
                    $container = $dgc;
                    break;
            }

            if (data === ' ') {
                nav.end = true;

                if (nav.reload) {
                    $container.html(noResult);
                }
            } else {
                if (nav.reload) {
                    $container.html(data);
                    lazyLoad($container.find('.lazy'));
                } else {
                    num = $container.find('.good-info').length;
                    $container.append(data);

                    //lazy good-infos who append in
                    lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
                }

            }

            nav.reload = false;
            nav.page = page;

            searching = false;
            loading.hideLoadingMask();

            window.rePosFooter();
        }
    });

}

require("js/product/suspend-cart"); //悬浮购物车

$.ajax({
    type: 'GET',
    url: '/search/filter',
    data: defaultOpt,
    success: function(data) {
        $goodsContainer.append(data);

        //初始化filter&注册filter回调
        filter.initFilter({
            fCbFn: search,
            hCbFn: function() {

                //切换active状态到$pre上
                $pre.addClass('active');
                $pre.siblings('.filter').removeClass('active');
            }
        });
    }
});

lazyLoad($('.lazy'));

writeSearch.bindWirteLocal($('#search-form'));

//导航栏点击逻辑说明:
//1.点击非active项时切换active状态
//2.价格和折扣active状态时继续点击切换排序
//3.筛选无active时点击展开筛选面板
//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
//5.当前active为筛选并且点击其他项时,隐藏筛选面板
navHammer = new Hammer($listNav[0]);
navHammer.on('tap', function(e) {
    var $this = $(e.target).closest('li'),
        nav,
        navType,
        $active;

    if ($this.hasClass('filter')) {

        //筛选面板切换状态
        if ($this.hasClass('active')) {
            filter.hideFilter();

            //点击筛选钱的active项回复active
            $pre.addClass('active');
            $this.removeClass('active');
        } else {
            $pre = $this.siblings('.active');

            $pre.removeClass('active');
            $this.addClass('active');

            filter.showFilter();
        }
    } else {

        if ($this.hasClass('new')) {
            navType = 'newest';
        } else if ($this.hasClass('price')) {
            navType = 'price';
        } else if ($this.hasClass('discount')) {
            navType = 'discount';
        }

        nav = navInfo[navType];

        if ($this.hasClass('active')) {

            //最新无排序切换
            if ($this.hasClass('new')) {
                return;
            }

            if ($this.hasClass('price') || $this.hasClass('discount')) {

                // 价格/折扣切换排序状态
                $this.find('.icon > .iconfont').toggleClass('cur');
                $pre = $this; //更新pre为当前项
                nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
                nav.order = nav.order === 0 ? 1 : 0; //切换排序
            }
        } else {
            $active = $this.siblings('.active');

            $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项

            if ($active.hasClass('filter')) {

                //若之前active项为筛选,则隐藏筛选面板
                filter.hideFilter();
            } else {

                //切换container显示
                $goodsContainer.children('.container:not(.hide)').addClass('hide');

                switch (navType) {
                    case 'newest':
                        $ngc.removeClass('hide');
                        break;

                    case 'price':
                        $pgc.removeClass('hide');
                        break;

                    case 'discount':
                        $dgc.removeClass('hide');
                        break;
                }
            }

            $active.removeClass('active');
            $this.addClass('active');
        }

        if (nav.reload) {
            search();
        }
    }
});

$(window).scroll(function() {

    //当scroll到1/4$goodsContainer高度后继续请求下一页数据
    if ($(window).scrollTop() + winH >
        $(document).height() - 0.25 * $goodsContainer.height()) {
        search();
    }
});

if ($brandHeader.length > 0) {

    //品牌介绍
    btnIntroHammer = new Hammer($brandHeader.children('.btn-intro')[0]);
    btnIntroHammer.on('tap', function() {
        $introBox.removeClass('hide');

        //防止混合scroll发生
        $('body').addClass('overflow-hidden');
    });

    //关闭品牌介绍
    introHammer = new Hammer(document.getElementById('intro-box'));
    introHammer.on('tap', function(e) {
        var $this = $(e.target);

        e.srcEvent.preventDefault();

        //关闭品牌介绍box
        if ($this.closest('#brand-intro').length === 0 || $this.hasClass('close-intro')) {
            $introBox.addClass('hide');
            $('body').removeClass('overflow-hidden');
        }
    });

    //品牌收藏
    brandColHammer = new Hammer($brandHeader.children('.btn-col')[0]);
    brandColHammer.on('tap', function() {
        var $this = $(this);

        var id = $brandHeader.data('id'),
            opt;

        if ($this.hasClass('coled')) {
            opt = 'cancel';
        } else {
            opt = 'ok';
        }

        $.ajax({
            type: 'POST',
            url: '/product/opt/favoriteBrand',
            data: {
                id: id,
                opt: opt
            },
            success: function(data) {
                if (data.code === 200) {
                    $this.toggleClass('coled');
                } else if (data.code === 400 || data.code === 412) {
                    location.href = data.data;//未登录跳转登录页
                } else {
                    tip.show(data.message);
                }
            },
            error: function() {
                tip.show('网络断开连接了~');
            }
        });
    });
}

//初始请求最新第一页数据
search();
});
define("js/product/detail/detail", ["jquery","swiper","lazyload","index"], function(require, exports, module){
/**
 *  商品详情
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/20
 */
 var $ = require("jquery"),
    Swiper = require("swiper"),
    lazyLoad = require("lazyload"),
    goodsSwiper;

lazyLoad($('img.lazy'));

goodsSwiper = new Swiper('.banner-swiper', {
    lazyLoading: true,
    lazyLoadingInPrevNext: true,
    loop: true,
    paginationClickable: true,
    pagination: '.swiper-pagination',
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev'
});

// $('#iframe').load(function() {
//     var mainheight = $(this).contents().find('body').height() + 30;
//     $(this).height(mainheight);
// });
});