Jquery開發電商網站實戰(帶源碼)

組件化思想,包含:javascript

下拉菜單項封裝 + 按需加載css

搜索功能組件化,顯示數據 + 下拉顯示 + 緩存html

分類導航按需加載java

幻燈片效果組件封裝及按需加載jquery

商品樓層模塊組件化 + 商品數據按需加載 + Tab選項卡 + 電梯結構css3

是時候放出大長圖了!!!web

 

 

index.htmlajax

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/common.css" />
    <link rel="stylesheet" href="css/index.css" />
</head>

<body>
    <!-- 站點導航開始 -->
    <div class="nav-site">
        <div class="container">
            <ul class="fl">
                <li class="fl"><a href="javascript:;" id="nav-site-signin" class="nav-site-login">親,請登陸</a></li>
                <li class="fl"><a href="javascript:;" id="nav-site-signup" class="nav-site-signup link">免費註冊</a></li>
                <li class="fl"><a href="###" target="_blank" class="nav-site-mobile link">手機逛XX網</a></li>
            </ul>
            <ul class="fr">
                <li class="menu dropdown fl" data-active="menu">
                    <a href="###" target="_blank" class="dropdown-toggle link  transition">個人XX<i class="dropdown-arrow icon transition">&#xe609;</i></a>
                    <ul class="dropdown-layer dropdown-left">
                        <li><a href="###" target="_blank" class="menu-item">已買到的寶貝</a></li>
                        <li><a href="###" target="_blank" class="menu-item">個人足跡</a></li>
                    </ul>
                </li>
                <li class="menu dropdown fl" data-active="menu">
                    <a href="###" target="_blank" class="dropdown-toggle link transition">收藏夾<i class="dropdown-arrow icon transition">&#xe609;</i></a>
                    <ul class="dropdown-layer dropdown-left">
                        <li><a href="###" target="_blank" class="menu-item">收藏的寶貝</a></li>
                        <li><a href="###" target="_blank" class="menu-item">收藏的店鋪</a></li>
                    </ul>
                </li>
                <li class="fl">
                    <a href="###" target="_blank" class="nav-site-category link">商品分類</a>
                </li>
                <li class="menu dropdown fl" data-active="menu" data-load="js/dropdown-seller.json">
                    <a href="###" target="_blank" class="dropdown-toggle link transition">賣家中心<i class="dropdown-arrow icon transition">&#xe609;</i></a>
                    <ul class="dropdown-layer dropdown-left">
                        <li class="dropdown-loading"></li>
                    </ul>
                </li>
                <li class="nav-site-service menu dropdown fl" data-active="menu">
                    <a href="###" target="_blank" class="dropdown-toggle link transition">聯繫客服<i class="dropdown-arrow icon transition">&#xe609;</i></a>
                    <ul class="dropdown-layer dropdown-right">
                        <li><a href="###" target="_blank" class="menu-item">消費者客服</a></li>
                        <li><a href="###" target="_blank" class="menu-item">賣家客服</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!-- 站點導航結束 -->
    <!-- header區開始 -->
    <div class="header">
        <div class="container">
            <h1 class="fl"><a href="./index.html" class="header-logo text-hidden">XX網</a></h1>
            <div id="header-search" class="search fl">
                <form action="https://s.taobao.com/search" class="search-form">
                    <input type="text" name="q" placeholder="靈魂沒事一元搶" autocomplete="off" class="search-inputbox fl" />
                    <input type="submit" value="搜索" class="search-btn btn fl" />
                </form>
                <ul class="search-layer">
                    <li class="search-layer-item text-ellipsis">111</li>
                    <li class="search-layer-item text-ellipsis">111</li>
                    <li class="search-layer-item text-ellipsis">111</li>
                </ul>
            </div>
            
        </div>
    </div>
    <!-- header區開始 -->
    <!-- 中心部分導航 -->
    <div class="nav-main">
        <div class="container">
            <a href="###" target="_blank" class="link">數碼城</a
            ><a href="###" target="_blank" class="link">天黑黑</a
            ><a href="###" target="_blank" class="link">團購</a
            ><a href="###" target="_blank" class="link">發現</a
            ><a href="###" target="_blank" class="link">二手特價</a
            ><a href="###" target="_blank" class="link">名品彙</a>
        </div>
    </div>
    <div class="focus">
        <div class="container">
            <div id="focus-category" class="category fl">
                <a href="###" target="_blank" class="category-title"><i class="icon">&#xe608;</i>商品分類</a>
                <ul class="category-list">
                    <li class="dropdown" data-active="category" data-load="js/category-detail-1.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">家用電器</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-2.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">手機</a
                            ><a href="###" target="_blank" class="dropdown-link">運營商</a
                            ><a href="###" target="_blank" class="dropdown-link">數碼</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-3.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">電腦</a
                            ><a href="###" target="_blank" class="dropdown-link">辦公</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-4.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">家居</a
                            ><a href="###" target="_blank" class="dropdown-link">傢俱</a
                            ><a href="###" target="_blank" class="dropdown-link">家裝</a
                            ><a href="###" target="_blank" class="dropdown-link">廚具</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-5.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">男裝</a
                            ><a href="###" target="_blank" class="dropdown-link">女裝</a
                            ><a href="###" target="_blank" class="dropdown-link">童裝</a
                            ><a href="###" target="_blank" class="dropdown-link">內衣</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-6.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">化妝</a
                            ><a href="###" target="_blank" class="dropdown-link">清潔</a
                            ><a href="###" target="_blank" class="dropdown-link">寵物</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-7.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">運動戶外</a
                            ><a href="###" target="_blank" class="dropdown-link">鐘錶</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-8.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">汽車</a
                            ><a href="###" target="_blank" class="dropdown-link">汽車用品</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-9.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">母嬰</a
                            ><a href="###" target="_blank" class="dropdown-link">玩具樂器</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-10.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">食品</a
                            ><a href="###" target="_blank" class="dropdown-link">酒類</a
                            ><a href="###" target="_blank" class="dropdown-link">生鮮</a
                            ><a href="###" target="_blank" class="dropdown-link">特產</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-11.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">醫藥保健</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-12.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">圖書</a
                            ><a href="###" target="_blank" class="dropdown-link">音像</a
                            ><a href="###" target="_blank" class="dropdown-link">電子書</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-13.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">彩票</a
                            ><a href="###" target="_blank" class="dropdown-link">旅行</a
                            ><a href="###" target="_blank" class="dropdown-link">充值</a
                            ><a href="###" target="_blank" class="dropdown-link">票務</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                    <li class="dropdown" data-active="category" data-load="js/category-detail-14.json">
                        <div class="dropdown-toggle">
                            <a href="###" target="_blank" class="dropdown-link">理財</a
                            ><a href="###" target="_blank" class="dropdown-link">衆籌</a
                            ><a href="###" target="_blank" class="dropdown-link">白條</a
                            ><a href="###" target="_blank" class="dropdown-link">保險</a>
                            <i class="dropdown-arrow">&gt;</i>
                        </div>
                        <div class="dropdown-layer">
                            <div class="dropdown-loading"></div>
                        </div>
                    </li>
                </ul>
            </div>
            <div id="focus-slider" class="slider fl">
                <div class="slider-container">
                    <div class="slider-item">
                        <!-- <a href="###" target="_blank"><img src="../img/focus-slider/loading.gif" data-src="https://gratisography.com/pictures/407_1.jpg" alt="" class="slider-img" /></a> -->
                        <a href="###" target="_blank"><img src="img/focus-slider/loading.gif" data-src="img/focus-slider/1.png" alt="" class="slider-img" /></a>
                    </div>
                    <div class="slider-item">
                        <a href="###" target="_blank"><img src="img/focus-slider/loading.gif" data-src="img/focus-slider/2.png" alt="" class="slider-img" /></a>
                    </div>
                    <div class="slider-item">
                        <a href="###" target="_blank"><img src="img/focus-slider/loading.gif" data-src="img/focus-slider/3.png" alt="" class="slider-img" /></a>
                    </div>
                    <div class="slider-item">
                        <a href="###" target="_blank"><img src="img/focus-slider/loading.gif" data-src="img/focus-slider/4.png" alt="" class="slider-img" /></a>
                    </div>
                </div>
                <ol class="slider-indicator-wrap">
                    <li class="slider-indicator text-hidden fl">1</li>
                    <li class="slider-indicator text-hidden fl">2</li>
                    <li class="slider-indicator text-hidden fl">3</li>
                    <li class="slider-indicator text-hidden fl">4</li>
                </ol>
                <a href="javascript:;" class="slider-control slider-control-left">&lt;</a>
                <a href="javascript:;" class="slider-control slider-control-right">&gt;</a>
            </div>
            <div class="focus-sidebar fr">
                <div class="focus-news">
                    <div class="focus-news-head">
                        <h2 class="focus-news-title fl">XX快報</h2>
                        <a href="###" target="_blank" class="link fr">更多 &gt;</a>
                    </div>
                    <div class="focus-news-body">
                        <p class="text-ellipsis">
                            <a href="###" target="_blank" class="link"><strong>[特惠]</strong> 精選圖書每滿150減50</a>
                        </p>
                        <p class="text-ellipsis">
                            <a href="###" target="_blank" class="link"><strong>[公告]</strong> 因廣州圖書倉搬倉升級配送延遲</a>
                        </p>
                        <p class="text-ellipsis">
                            <a href="###" target="_blank" class="link"><strong>[特惠]</strong> 爆款手機12期免息</a>
                        </p>
                        <p class="text-ellipsis">
                            <a href="###" target="_blank" class="link"><strong>[公告]</strong> 廣東、福建受颱風影響配送延遲</a>
                        </p>
                        <p class="text-ellipsis">
                            <a href="###" target="_blank" class="link"><strong>[特惠]</strong> 大閘蟹領券滿399減180</a>
                        </p>
                    </div>
                </div>
                <div class="focus-service cf">
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe612;</i>
                        <span class="focus-service-text">話費</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe611;</i>
                        <span class="focus-service-text">機票</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe607;</i>
                        <span class="focus-service-text">電影票</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe60e;</i>
                        <span class="focus-service-text">遊戲</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe605;</i>
                        <span class="focus-service-text">彩票</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe603;</i>
                        <span class="focus-service-text">加油卡</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe602;</i>
                        <span class="focus-service-text">酒店</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe601;</i>
                        <span class="focus-service-text">火車票</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe60d;</i>
                        <span class="focus-service-text">衆籌</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe60c;</i>
                        <span class="focus-service-text">理財</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe610;</i>
                        <span class="focus-service-text">禮品卡</span>
                    </a>
                    <a href="###" target="_blank" class="focus-service-item fl">
                        <i class="icon focus-service-icon">&#xe60f;</i>
                        <span class="focus-service-text">白條</span>
                    </a>
                </div>
                <div class="focus-ad"></div>
            </div>
        </div>
    </div>

    <div class="todays">
        <div class="container">
            <div id="todays-slider" class="slider">
                <div class="slider-container">
                    <div class="slider-item">
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/1.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/2.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/3.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/4.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/5.png" class="slider-img" /></a>
                    </div>
                    <div class="slider-item">
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/6.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/7.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/8.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/9.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/10.png" class="slider-img" /></a>
                    </div>
                    <div class="slider-item">
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/11.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/3.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/5.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/7.png" class="slider-img" /></a>
                        <a href="###" target="_blank" class="fl"><img src="img/todays-slider/loading.gif" alt="" data-src="img/todays-slider/9.png" class="slider-img" /></a>
                    </div>
                </div>
                <a href="javascript:;" class="slider-control slider-control-left">&lt;</a>
                <a href="javascript:;" class="slider-control slider-control-right">&gt;</a>
            </div>
        </div>
    </div>

    <!-- floor-1 -->
    <div class="floor">
        <div class="container">
            <img src="img/floor-loading.gif" alt="" />
        </div>
    </div>

    <!-- floor2 -->
    <div class="floor">
        <div class="container">
            <img src="img/floor-loading.gif" alt="" />
        </div>
    </div>

    <!-- floor3 -->
    <div class="floor">
        <div class="container">
           <img src="img/floor-loading.gif" alt="" /> 
        </div>
    </div>

    <!-- floor4 -->
    <div class="floor">
        <div class="container">
         <img src="img/floor-loading.gif" alt="" />   
        </div>
    </div>

    <!-- floor5 -->
    <div class="floor floor-last">
        <div class="container">
            <img src="img/floor-loading.gif" alt="" />
        </div>
    </div>

    <!-- elevator -->
    <div id="elevator" class="elevator container">
        <a href="javascript:;" class="elevator-item">
            <span class="elevator-num">F1</span>
            <span class="elevator-text">服飾</span>
        </a>
        <a href="javascript:;" class="elevator-item">
            <span class="elevator-num">F2</span>
            <span class="elevator-text">美妝</span>
        </a>
        <a href="javascript:;" class="elevator-item">
            <span class="elevator-num">F3</span>
            <span class="elevator-text">手機</span>
        </a>
        <a href="javascript:;" class="elevator-item">
            <span class="elevator-num">F4</span>
            <span class="elevator-text">家電</span>
        </a>
        <a href="javascript:;" class="elevator-item">
            <span class="elevator-num">F5</span>
            <span class="elevator-text">數碼</span>
        </a>
    </div>
   
    
    <div class="toolbar">
        <a href="javascript:;" class="toolbar-item">
            <i class="toolbar-icon icon">&#xe617;</i>
            <span class="toolbar-text transition">會員</span>
        </a>
        <a href="javascript:;" class="toolbar-item">
            <i class="toolbar-icon icon">&#xe613;</i>
            <span class="toolbar-text transition">購物車</span>
        </a>
        <a href="javascript:;" class="toolbar-item">
            <i class="toolbar-icon icon">&#xe616;</i>
            <span class="toolbar-text transition">個人關注</span>
        </a>
        <a href="javascript:;" class="toolbar-item">
            <i class="toolbar-icon icon">&#xe614;</i>
            <span class="toolbar-text transition">個人消息</span>
        </a>
        <a href="javascript:;" id="backToTop" class="toolbar-item">
            <i class="toolbar-icon icon">&#xe615;</i>
            <span class="toolbar-text transition">頂部</span>
        </a>
    </div>
    <script>
    //兩種判斷是否有jquery庫的寫法:
    // window.jQuery || document.write('<script src="js/jquery.js"><' + '/script>')
    window.jQuery || document.write('<script src="js/jquery.js"><\/script>');
    </script>
    <script src="js/transition.js"></script>
    <script src="js/showhide.js"></script>
    <script src="js/dropdown.js"></script>
    <script src="js/search.js"></script>
    <script src="js/move.js"></script>
    <script src="js/slider.js"></script>
    <script src="js/tab.js"></script>
    <script src="js/index.js"></script>
</body>

</html>

base.csschrome

/*css reset*/
    /*清除內外邊距*/
    body, h1, h2, h3, h4, h5, h6, p, hr, /*結構元素*/
    ul, ol, li, dl, dt, dd, /*列表元素*/
    form, fieldset, legend, input, button, select, textarea, /*表單元素*/
    th, td, /*表格元素*/
    pre {
        padding: 0;
        margin: 0;
    }

    /*重置默認樣式*/
    body, button, input, select, textarea {
        /*font: 12px/1 微軟雅黑, Tahoma, Helvetica, Arial, 宋體, sans-serif;*/
        color: #333;
        font: 12px/1 "Microsoft YaHei", Tahoma, Helvetica, Arial, SimSun, sans-serif;
    }
    h1, h2, h3, h4, h5, h6 {
        font-size: 100%;
        font-weight: normal;
    }
    em, i {
        font-style: normal;
    }

    a {
        text-decoration: none;
    }
    li {
        list-style-type: none;
        vertical-align: top;
    }
    img {
        border: none;
        /*display: block;*/
        vertical-align: top;
    }
    textarea {
        overflow: auto;
        resize: none;
    }
    table {
        border-spacing: 0;
        border-collapse: collapse;
    }

/*經常使用公共樣式*/
    .fl {
        float: left;
        display: inline;
    }
    .fr {
        float: right;
        display: inline;
    }
    .cf:before,
    .cf:after {
        content: " ";
        display: table;
        
    }
    .cf:after {
        clear: both;
    }
    .cf {
        *zoom: 1;
    }

common.cssjson

/*公共樣式*/

    .container {
        /*站點導航*/
        width: 1200px;
        margin: 0 auto;
    }

    a.link {
        /*連接正常顏色*/
        color: #4d555d;
    }

    a.link:hover {
        /*連接通過顏色*/
        color: #f01414 !important;
    }

    .transition {
        -o-transition: all 0.5s;
        -ms-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -webkit-transition: all 0.5s;
        transition: all 0.5s;
    }

    .text-hidden{
        text-indent: -9999px;
        overflow: hidden;
    }


    .text-ellipsis{
        text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
    }

/*icon*/
    @font-face {
        font-family: "iconfont";
        src: url('../test/font/iconfont.eot?t=1477124206');
        /* IE9*/
        src: url('../test/font/iconfont.eot?t=1477124206#iefix') format('embedded-opentype'), /* IE6-IE8 */
        url('../test/font/iconfont.woff?t=1477124206') format('woff'), /* chrome, firefox */
        url('../test/font/iconfont.ttf?t=1477124206') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
        url('../test/font/iconfont.svg?t=1477124206#iconfont') format('svg');
        /* iOS 4.1- */
    }

    .icon {
        font-family: "iconfont" !important;
        font-size: 14px;
        font-style: normal;
        -webkit-font-smoothing: antialiased;
        -webkit-text-stroke-width: 0.2px;
        -moz-osx-font-smoothing: grayscale;
    }

/*showhide*/

    .fadeOut {
        visibility: hidden !important;
        opacity: 0 !important;
    }
    .slideUpDownCollapse {
        height: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    .slideLeftRightCollapse {
        width: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

/*dropdown*/
    .dropdown {
        position: relative;
    }

    .dropdown-toggle {
        position: relative;
        z-index: 2;
    }

    .dropdown-arrow {
        display: inline-block;
        line-height: 1;
        /*background-repeat: no-repeat;*/
        vertical-align: middle;
        
    }
    


    .dropdown-layer {
        display: none;
        position: absolute;
        z-index: 1;
    }

    .dropdown-left {
        left: 0;
        right: auto;
    }

    .dropdown-right {
        right: 0;
        left: auto;
    }

     .dropdown-loading{
            width:32px;
            height: 32px;
            background: url(../img/loading.gif) no-repeat;
            margin: 20px;
        }

    .menu-active .dropdown-arrow{
    -o-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    -moz-transform: rotate(180deg);
    -webkit-transform: rotate(180deg);
    transform: rotate(180deg);
    }  

/*.menu .dropdown*/
        .menu{
            z-index: 3;
        }

        .menu .dropdown-toggle {
            display: block;
            height: 100%;
            padding: 0 13px 0 12px;
            border-left: 1px solid #f3f5f7;
            border-right: 1px solid #f3f5f7;
        }

        .menu .dropdown-arrow {
            /*width: 8px;
            height: 6px;
            background-image: url(../img/dropdown-arrow.png);*/
            margin-left: 5px;
        }

        .menu .dropdown-layer {
            top: 43px;
            background-color: #fff;
            border: 1px solid #cdd0d4;
        }

        .menu-item {
            display: block;
            height: 30px;
            line-height: 30px;
            padding: 0 12px;
            color: #4d555d;
            white-space: nowrap;
        }

        .menu-item:hover {
            background-color: #f3f5f7;
        }

        .menu-active .dropdown-toggle {
            background-color: #fff;
            border-color: #cdd0d4;
        }

        .menu-active .dropdown-arrow {
            /*background-image: url(../img/dropdown-arrow-active.png);*/
        }

        /*.menu-active .dropdown-layer {
            display: block;
        }*/

/*btn*/
    .btn {
        display: inline-block;
        border: none;
        color: #fff;
        text-align: center;
        cursor: pointer;
    }        

/*search*/
    .search {
        position: relative;
        border: 1px solid #cfd2d5;
    }
    .search-inputbox {
        width: 585px;
        height: 40px;
        line-height: 40px;
        padding: 0 10px;
        background-color: #fff;
        border: none;
    }
    .search-btn {
        width: 73px;
        height: 40px;
        line-height: 40px;
        background-color: #07111b;
        font-size: 14px;
        
    }
    .search-layer {
        display: none;
        position: absolute;
        top: 100%;
        left: -1px;
        width: 100%;
        background-color: #fff;
        border: 1px solid #cfd2d5;
        z-index: 3;
    }
    .search-layer-item {
        height: 24px;
        line-height: 24px;
        padding: 0 10px;
        cursor: pointer;

    }
    .search-layer-item:hover {
        background-color: #f3f5f7;
    }



/*category*/

    .category {
        position: relative;
        width: 208px;
        margin-top: -62px;
        font-size: 14px;
    }
    .category .dropdown{
        position: static;
    }
    .category-title {
        display: block;
        height: 54px;
        line-height: 54px;
        padding: 0 20px;
        background-color: #c81414;
        color: #fff;
    }

    .category-title .icon {
        margin-right: 10px;
        font-size: 16px;
    }

    .category-list {
        height: 512px;
        background-color: #f01414;
    }
    .category .dropdown-toggle {
        height: 36px;
        line-height: 36px;
        padding-left: 16px;
        color: #fff;
    }

    .category .dropdown-link {
        color: #fff;
    }

    .category .dropdown-arrow {
        position: absolute;
        top: 12px;
        right: 12px;
        font-family: simsun;
        font-weight: bold;
    }

    .category-active .dropdown-toggle {
        background-color: #fff;
    }

    .category-active .dropdown-toggle,
    .category-active .dropdown-link {
        color: #f01414;
    }

    .category .dropdown-layer {
        top: 54px;
        left: 100%;
        width: 744px;
        min-height: 473px;
        padding: 8px 0 31px 0;
        background-color: #fff;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    }

    .category-details {
        width:744px;        
        margin-top: 24px;
        line-height: 20px;
    }
    .category-details-title{
        width: 84px;
        padding-right: 16px;
        border-right: 1px solid #d9dde1;
        text-align: right;
       
    }

    .category-details-title-link {
        color: #07111b;
        font-weight: bold;
    }

    .category-details-item {
        width: 592px;
        padding-left: 15px;
    }
    .category-details-item .link {
        display: inline-block;
        margin-right: 16px;
    }

    .category .dropdown-loading {
        margin: 220px auto 0;
     }

/*slider*/
    .slider {
            
            position: relative;
            overflow: hidden;
            width: 728px;
            height: 504px;
        }

    .slider-indicator-wrap {
        position: absolute;
        bottom: 24px;
        left: 50%;
        margin-left: -36px;
    }

    .slider-indicator {
        width: 8px;
        height: 8px;
        background-color: #313a43;
        border-radius: 50%;
        margin-right: 12px;
        cursor: pointer;
    }

    .slider-indicator-active {
        position: relative;
        top: -2px;
        background-color: #f7f8f9;
        border: 2px solid #858b92;
    }

    .slider-control {
        display: none;
        position: absolute;
        top: 50%;
        margin-top: -31px;
        width: 28px;
        height: 62px;
        line-height: 62px;
        background-color: #000;
        opacity: 0.8;
        filter: alpha(opacity=80);
        color: #fff;
        font-size: 22px;
        font-family: simsun;
        text-align: center;
    }

    .slider-control-left {
        left: 0;
    }

    .slider-control-right {
        right: 0;
    }

    .slider-fade .slider-item {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .slider-slide .slider-item {
        position: absolute;
        top: 0;

        left: 100%;
        width: 100%;
        height: 100%;
    }
    /*.slider-slide .slider-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 1000%;
            height: 100%;
            background-color: red;
        }
        .slider-slide .slider-item {
            float: left;
        }*/
    /*tab*/
   .tab-panel {
        display: none;
        
    }     

index.css

/*nav-site*/
.nav-site{ /*站點導航總體設置*/
    width:100%;
    background-color: #f3f5f7;
}
.nav-site .container{  /*站點導航內容塊總體設置*/
    height: 44px;
    line-height: 44px;
    border-bottom: 1px solid #cdd0d4;
}
.nav-site-login{  /*站點導航「親,請登錄」設置*/
    margin-left:15px;
    color:#f01414;
}
.nav-site-signup,
.nav-site-mobile{ /*站點導航「註冊和手機購買」設置*/
    margin-left:10px;
}
.nav-site-category{
    margin:0 10px;
}

.nav-site-service{
    margin-right:15px;
}



/*下拉菜單樣式dropdown*/
.dropdown{
    position: relative;
}
.dropdown-toggle{
    position: relative;
    z-index: 2;
    display:block;
    height: 100%;
    padding: 0 16px 0 12px;
    border-left: 1px solid #f3f5f7;
    border-right: 1px solid #f3f5f7;

}
.dropdown-arrow{
    display: inline-block;
    /*width:8px;
    height:6px;*/
    /*background: url(../img/dropdown-arrow.png) no-repeat;*/
    margin-left:8px;
    vertical-align: middle;

}
.dropdown-layer{
    display:none;
    position: absolute;
    top:43px;
    background-color:#fff;
    z-index: 1;
    border: 1px solid #cdd0d4;
}
.dropdown-left{
    left:0;
    right:auto;

}
.dropdown-right{
    right:0;
    left:auto;

}
.dropdown-item{
    display:block;
    height:30px;
    line-height:30px;
    padding:0 12px;
    color:#4d555d;
    white-space: nowrap;

}
.dropdown-item:hover{
    background-color: #f3f5f7;
}

/*下拉菜單經過js和css來實現dropdown*/

/*header*/
.header{
    width: 100%;
    height: 124px;
    background-color: #f3f5f7;
}
    .header-logo,
    .header .search,
    .header .cart {
        margin-top: 36px;
    }
.header-logo{
    display: block;
    width:136px;
    height: 48px;
    background: url(../img/header-logo.png) no-repeat;
    margin-left:15px;
    
}

.header .search{
    margin-left: 145px;
}
.header .cart{
    margin-right: 15px;
}

/*nav-main*/
    .nav-main {
        width: 100%;
        height: 48px;
        background-color: #07111b;
        margin-bottom: 8px;
        text-indent: 182px;
    }
    .nav-main .link {
        margin-left: 50px;
        color: #fff;
        font-size: 14px;
        line-height: 48px;
    }
    
/*focus*/
    .focus {
        width: 100%;
        height: 504px;
        background-color: #eee;
        margin-bottom: 8px;
    }

    .focus-sidebar {
        width: 249px;
    }

    .focus-news {
        padding: 7px 20px 12px;
        background-color: #fff;
        border: 1px solid #d9dde1;
        border-bottom: none;
    }
    .focus-news-head {
        height: 38px;
        line-height: 38px;
    }
    .focus-news-title {
        color: #f01414;
        font-size: 16px;
    }
    .focus-news-body {
        line-height: 28px;
    }
    .focus-service {
        background-color: #fff;
        border-left: 1px solid #d9dde1;
    }
    .focus-service-item {
        width: 61px;
        height: 71px;
        border-top: 1px solid #d9dde1;
        border-right: 1px solid #d9dde1;
        text-align: center;
    }
    .focus-service-icon,
    .focus-service-text {
        display: inline-block;
        width: 100%;
    }
    .focus-service-icon {
        margin-top: 17px;
        color: #f67272;
        font-size: 22px;
    }
    .focus-service-text {
        margin-top: 6px;
        color: #4d555d;
    }
    .focus-ad {
        width: 100%;
        height: 90px;
        background: url(../img/focus-ad.png) no-repeat;
    }
    .focus .slider{
        margin-left: 8px;
    }

/*todays*/
    .todays .slider{
        position: relative;
        z-index:1;
        width:100%;
        height:158px;
        margin-bottom:10px;
    }

    .todays .slider-img{
        width:240px;

    } 


 /*floor*/
        .floor {
            height: 533px;
            margin-bottom: 10px;
        }
        .floor-last{
            margin-bottom: 32px;
        }
        .floor .container{
            position: relative;
            z-index: 1;
        }
        
        .floor-head {
            height: 68px;
            border-bottom: 1px solid #f01414;
        }
        .floor-title {
            margin-top: 22px;
        }
        .floor-title-num {
            display: inline-block;
            width: 24px;
            height: 24px;
            line-height: 24px;
            border-radius: 50%;
            background-color: #07111b;
            margin-right: 12px;
            color: #fff;
            text-align: center;
        }
        .floor-title-text {
            position: relative;
            top: 3px;
            color: #07111b;
            font-size: 20px;
        }
        .floor-body {
            height: 464px;
        }
        .floor-item {
            width: 200px;
            height: 232px;
            text-align: center;
        }
        .floor-item:hover {
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
        }
        .floor-item-pic {
            margin-top: 24px;
        }
        .floor-item-name {
            margin-top: 24px;
        }
        .floor-item-name .link {
            color: #07111b;
        }
        .floor-item-price {
            margin-top: 11px;
            color: #f01414;
            font-size: 14px;
            font-weight: bold;
        } 
        

        .floor-head .tab-item-wrap {
            height: 62px;
            line-height: 62px;
            margin-top: 7px;
        }
        .floor-head .tab-item {
            display: inline-block;
            margin-right: 16px;
            color: #93999f;
            font-size: 14px;
        }
        .floor-head .tab-item-active {
            background: url(../img/floor-arrow.png) no-repeat center bottom;
            color: #f01414;
        }
        .floor-divider {
            width: 1px;
            height: 14px;
            background-color: #d9dde1;
            margin: 22px 16px 0 0;
        }
        .floor-head .tab-panel {
            height: 100%;
        }
    

/*elevator*/
    .elevator {
        display: none;
        position: fixed;
        left: 50%;
        top: 50%;
        margin-top: -90px;
        margin-left: -640px;

        
    }
    .elevator-item {
        display: block;
        width: 24px;
        height: 35px;
        line-height: 35px;
        border-top: 1px solid #d9dde1;
        text-align: center;
        color: #4d555d;
    }
    .elevator-item:hover,
    .elevator-active {
        color: #f01414;
    }
    .elevator-text {
        display: none;
    }
    .elevator-item:hover .elevator-num,
    .elevator-active .elevator-num {
        display: none;
    }
    .elevator-item:hover .elevator-text,
    .elevator-active .elevator-text {
        display: block;
    }

    
    


/*toolbar*/
    .toolbar {
        position: fixed;
        z-index: 2;
        right: 0;
        top: 50%;
        margin-top: -102px;
    }
    .toolbar-item {
        position: relative;
        display: block;
        width: 40px;
        height: 40px;
        line-height: 40px;
        margin-bottom: 1px;
        color: #fff;
        text-align: center;
    }
    .toolbar-icon {
        position: relative;
        z-index: 2;
        display: block;
        background-color: #b7bbbf;
        font-size: 30px;
    }
    .toolbar-text {
        position: absolute;
        left: 0;
        top: 0;
        width: 62px;
        height: 40px;
    }
    .toolbar-item:hover .toolbar-icon {
        background-color: #71777d;
    }
    .toolbar-item:hover .toolbar-text {
        left: -62px;
        background-color: #71777d;
    }

transition.js(兼容瀏覽器的transition)

(function () {
    var transitionEndEventName = {
        transition: 'transitionend',
        MozTransition: 'transitionend',
        WebkitTransition: 'webkitTransitionEnd',
        OTransition: 'oTransitionEnd otransitionend'
    };
    var transitionEnd = '',
        isSupport = false;

    for (var name in transitionEndEventName) {
        if (document.body.style[name] !== undefined) {
            transitionEnd = transitionEndEventName[name];
            isSupport = true;
            break;
        }
    }

    window.mt = window.mt || {};
    window.mt.transition = {
        end: transitionEnd,
        isSupport: isSupport
    };
})();

showhide.js(動畫效果設置)

(function($) {
    var transition = window.mt.transition; // transition兼容解決,transition.js

    // 提取init公共部分
    function init($elem, hiddenCallback) {

        if ($elem.is(':hidden')) {
            $elem.data('status', 'hidden');
            if (typeof hiddenCallback === 'function') hiddenCallback();

        } else {
            $elem.data('status', 'shown');
        }
    }

    // 提取show公共部分

    function show($elem, callback) {
        if ($elem.data('status') === 'show') return;
        if ($elem.data('status') === 'shown') return;
        $elem.data('status','show').trigger('show');
        callback();
    }

    function hide($elem, callback) {
        if ($elem.data('status') === 'hide') return;
        if ($elem.data('status') === 'hidden') return;
        $elem.data('status', 'hide').trigger('hide');
        callback();
    }

    // 正常顯示和隱藏
    var silent = {
        // 提取公共init後
        init: init,
      
        show: function($elem) {
            show($elem, function() {
                $elem.show();
                $elem.data('status', 'shown').trigger('shown');
            });
        },
      
        hide: function($elem) {
            hide($elem, function() {
                $elem.hide();
                $elem.data('status', 'hidden').trigger('hidden');
            });
        }
    };

    // 帶效果的顯示和隱藏,css3實現方法
    var css3 = {

        fade: { // 淡入淡出

            init: function($elem) {
                css3._init($elem, 'fadeOut');

            },

            show: function($elem) {
                css3._show($elem, 'fadeOut');

            },

            hide: function($elem) {
                css3._hide($elem, 'fadeOut');

            }

        },
        slideUpDown: { 

            init: function($elem) {
                $elem.height($elem.height());
                css3._init($elem, 'slideUpDownCollapse');

            },
            show: function($elem) {
                css3._show($elem, 'slideUpDownCollapse');

            },
            hide: function($elem) {
                css3._hide($elem, 'slideUpDownCollapse');
            }
        },
        slideLeftRight: { // 左右滾動
            init: function($elem) {
                $elem.width($elem.width());
                css3._init($elem, 'slideLeftRightCollapse');

            },
            show: function($elem) {
                css3._show($elem, 'slideLeftRightCollapse');

            },
            hide: function($elem) {
                css3._hide($elem, 'slideLeftRightCollapse');
            }
        },
        fadeSlideUpDown: { // 淡入淡出上下滾動
            init: function($elem) {
                $elem.height($elem.height());
                css3._init($elem, 'fadeOut slideUpDownCollapse');

            },
            show: function($elem) {
                css3._show($elem, 'fadeOut slideUpDownCollapse');

            },
            hide: function($elem) {
                css3._hide($elem, 'fadeOut slideUpDownCollapse');
            }
        },

        fadeSlideLeftRight: { // 淡入淡出左右滾動
            init: function($elem) {
                $elem.width($elem.width());
                css3._init($elem, 'fadeOut slideLeftRightCollapse');

            },
            show: function($elem) {
                css3._show($elem, 'fadeOut slideLeftRightCollapse');

            },
            hide: function($elem) {
                css3._hide($elem, 'fadeOut slideLeftRightCollapse');
            }
        }
    };

    css3._init = function($elem, className) {
        $elem.addClass('transition');
        init($elem, function() {
            $elem.addClass(className);

        });

    };

    css3._show = function($elem, className) {
        show($elem, function() {
            $elem.off(transition.end).one(transition.end, function() {
                $elem.data('status', 'shown').trigger('shown');
            });
            $elem.show();
            setTimeout(function() {
                $elem.removeClass(className);
            }, 20);
        });


    };

    css3._hide = function($elem, className) {
        hide($elem, function() {
            $elem.off(transition.end).one(transition.end, function() {
                $elem.hide();
                $elem.data('status', 'hidden').trigger('hidden');
            });
            $elem.addClass(className);

        });

    }

    // 帶效果的顯示和隱藏,js實現方法
    var js = {
        fade: { // 淡入淡出
            init: function($elem) {
                js._init($elem);
            },
            show: function($elem) {
                js._show($elem, 'fadeIn');
            },
            hide: function($elem) {

                js._hide($elem, 'fadeOut');

            }
        },
        slideUpDown: { // 上下滾動
            init: function($elem) {
                js._init($elem);
            },
            show: function($elem) {
                js._show($elem, 'slideDown');

            },
            hide: function($elem) {

                js._hide($elem, 'slideUp');

            }
        },
        slideLeftRight: { // 左右滾動
            init: function($elem) {
                js._customInit($elem, {

                    'width': 0,
                    'padding-left': 0,
                    'padding-right': 0
                });
            },
            show: function($elem) {

                js._customshow($elem);
            },
            hide: function($elem) {

                js._customHide($elem, {
                    'width': 0,
                    'padding-left': 0,
                    'padding-right': 0
                });
            }
        },
        fadeSlideUpDown: { // 淡入淡出上下滾動
            init: function($elem) {
  
                js._customInit($elem, {

                    'opacity': 0,
                    'height': 0,
                    'padding-top': 0,
                    'padding-bottom': 0
                });
            },
            show: function($elem) {

                js._customshow($elem);
            },
            hide: function($elem) {

                js._customHide($elem, {
                    'opacity': 0,
                    'height': 0,
                    'padding-top': 0,
                    'padding-bottom': 0
                });
            }
        },
        fadeSlideLeftRight: { // 淡入淡出左右滾動
            init: function($elem) {
 
                js._customInit($elem, {

                    'opacity': 0,
                    'width': 0,
                    'padding-left': 0,
                    'padding-right': 0
                });
            },
            show: function($elem) {

                js._customshow($elem);
            },
            hide: function($elem) {
 
                js._customHide($elem, {
                    'opacity': 0,
                    'width': 0,
                    'padding-left': 0,
                    'padding-right': 0
                });
            }
        }
    };

    js._init = function($elem, hiddenCallback) {
        $elem.removeClass('transition'); // js和transition動畫衝突,在執行js前,將transition去掉,屏蔽風險。
        init($elem, hiddenCallback);
    };

    js._customInit = function($elem, options) {
        var styles = {};
        for (var p in options) {
            styles[p] = $elem.css(p);
        }

        $elem.data('styles', styles);

        js._init($elem, function() {
            $elem.css(options);
        });

    };

    js._customshow = function($elem) {
        var styles = $elem.data('styles');
        show($elem, function() {
            $elem.show();
            $elem.stop().animate($elem.data('styles'), function() {
                $elem.data('status', 'shown').trigger('shown');
            });
        });
    };

    js._customHide = function($elem, options) {
        hide($elem, function() {

            $elem.stop().animate(options, function() {
                $elem.hide();
                $elem.data('status', 'hidden').trigger('hidden');
            });
        });
    };


    js._show = function($elem, mode) {
        show($elem, function() {
            $elem.stop()[mode](function() {
                $elem.data('status', 'shown').trigger('shown');
            });
        });
    };

    js._hide = function($elem, mode) {

        hide($elem, function() {
            $elem.stop()[mode](function() {
                $elem.data('status', 'hidden').trigger('hidden');
            });
        });

    };

    // 動畫效果的默認設置
    var defaults = {
        css3: true,
        js: true,
        animation: 'fade'
    };

    function showHide($elem, options) {
        var mode = null;

        if (options.css3 && transition.isSupport) { 
            mode = css3[options.animation] || css3[defaults.animation];
          
        } else if (options.js) { 
            mode = js[options.animation] || js[defaults.animation];
        } else { 
            mode = silent;
        }
        mode.init($elem);
        return {
            show: $.proxy(mode.show, this, $elem),
            hide: $.proxy(mode.hide, this, $elem),
        };
    }
    
    $.fn.extend({
        showHide: function (option) {
            return this.each(function () {
                var $this = $(this),
                    options = $.extend({}, defaults, typeof option === 'object' && option),
                    mode = $this.data('showHide');

                if (!mode) {
                    $this.data('showHide', mode = showHide($this, options));
                }

                if (typeof mode[option] === 'function') {
                    mode[option]();
                }
            });
        }
    });

})(jQuery);

dropdown.js(下拉組件封裝)

(function($) {
    'use strict'

    function Dropdown($elem, options) {
        this.$elem = $elem;
            this.options = options;
        this.$layer = this.$elem.find('.dropdown-layer'),
            this.activeClass = options.active + '-active';

        this._init();
    }

    Dropdown.DEFAULTS = {
        event: "hover",
        css3: true,
        js: true,
        animation: 'fade',
        delay: 0,
        active: 'dropdown'
    };
    Dropdown.prototype._init=function () {
        var self=this;
        this.$layer.showHide(this.options);       
        this.$layer.on('show shown hide hidden',function (e) {
            self.$elem.trigger('dropdown-'+e.type);
            
        });

        if (this.options.event === 'click') {
            this.$elem.on('click', function(e) {
                self.show();
                e.stopPropagation();
            });
            $(document).on('click', $.proxy(this.hide, this));

        } else {
            this.$elem.hover($.proxy(this.show, this), $.proxy(this.hide, this));

        }
    }

    Dropdown.prototype.show = function() {
        var self = this;
        if (this.options.delay) {
            this.timer = setTimeout(function() {
                _show();
            }, this.options.delay);
        } else {
            _show();
        }

        function _show() {
            self.$elem.addClass(self.activeClass);
            self.$layer.showHide('show');
        }

    }

    Dropdown.prototype.hide = function() {
        if(this.options.delay){
            clearTimeout(this.timer);

        }
        this.$elem.removeClass(this.activeClass);
        this.$layer.showHide('hide');
    }

    $.fn.extend({
        dropdown: function(option) {
            return this.each(function() {
                
                var $this=$(this),
                dropdown=$this.data('dropdown'),
                options = $.extend({}, Dropdown.DEFAULTS, $(this).data(), typeof option==='object'&&option);
                // dropdown(this, options);  
                if(!dropdown){//解決屢次調用dropdown問題
                    $this.data('dropdown',dropdown=new Dropdown($this,options));

                }  

                if(typeof dropdown[option]==='function'){
                    dropdown[option]();

                }

            });

        }
    });


})(jQuery);

search.js(搜索框組件封裝)

// 面向對象方式實現搜索功能

(function($) {
    'use strict';

     var cache = {
        data: {},
        count: 0,
        addData: function (key, data) {
            if (!this.data[key]) {
                this.data[key] = data;
                this.count++;
            }
        },
        readData: function (key) {
            return this.data[key];
        },
        deleteDataByKey: function (key) {
            delete this.data[key];
            this.count--;
        },
        deleteDataByOrder: function (num) {
            var count = 0;

            for (var p in this.data) {
                if (count >= num) {
                    break;
                }
                count++;
                this.deleteDataByKey(p);
            }
        }
    };

    function Search($elem, options) {
        this.$elem = $elem;
        this.options = options;

        this.$form = this.$elem.find('.search-form');
        this.$input = this.$elem.find('.search-inputbox');
        this.$layer = this.$elem.find('.search-layer');
        this.loaded = false;
        this.$elem.on('click', '.search-btn', $.proxy(this.submit, this));
        if (this.options.autocomplete) {
            this.autocomplete();
        }

    }
    Search.DEFAULTS = {
        autocomplete: false,
        url: 'https://suggest.taobao.com/sug?code=utf-8&_ksTS=1484204931352_18291&callback=jsonp18292&k=1&area=c2c&bucketid=6&q=',
        css3: false,
        js: false,
        animation: 'fade',
        getDataInterval: 200

    };
    Search.prototype.submit = function() {
        if (this.getInputVal() === '') {
            return false;
        }
        this.$form.submit();
    };
    Search.prototype.autocomplete = function() {
        var timer = null,
            self = this;
        this.$input
            .on('input', function() {
                if (self.options.getDataInterval) {

                    clearTimeout(timer);
                    timer = setTimeout(function() {
                        self.getData();
                    }, self.options.getDataInterval);
                } else {
                    self.getData();
                }

            })
            .on('focus', $.proxy(this.showLayer, this))
            .on('click', function() {
                return false;
            });

        this.$layer.showHide(this.options);
        $(document).on('click', $.proxy(this.hideLayer, this));
    };

    Search.prototype.getData = function() {
        var self = this;
        var inputVal = this.getInputVal();
        if (inputVal == '') return self.$elem.trigger('search-noData');
        if(cache.readData(inputVal)) return self.$elem.trigger('search-getData',[cache.readData(inputVal)]);
        if (this.jqXHR) this.jqXHR.abort();
        this.jqXHR = $.ajax({
            url: this.options.url + inputVal,
            dataType: 'jsonp'
        }).done(function(data) {
            console.log(data);
            cache.addData(inputVal, data);
            console.log(cache.data);
            console.log(cache.count);
            self.$elem.trigger('search-getData', [data]);
        }).fail(function() {
            self.$elem.trigger('search-noData');
        }).always(function() {
            self.jqXHR = null;
        });

    };
    Search.prototype.showLayer = function() {
        if (!this.loaded) return;
        this.$layer.showHide('show');
    };
    Search.prototype.hideLayer = function() {
        this.$layer.showHide('hide');
    };

    Search.prototype.getInputVal = function() {
        return $.trim(this.$input.val());
    };

    Search.prototype.setInputVal = function(val) {
        this.$input.val(removeHtmlTags(val));

        function removeHtmlTags(str) {
            return str.replace(/<(?:[^>'"]|"[^"]*"|'[^']*')*>/g, '');
        }
    };

    Search.prototype.appendLayer = function(html) {
        this.$layer.html(html);
        this.loaded = !!html;
    };

    $.fn.extend({
        search: function(option, value) {
            return this.each(function() {

                var $this = $(this),
                    search = $this.data('search'),
                    options = $.extend({}, Search.DEFAULTS, $(this).data(), typeof option === 'object' && option);

                if (!search) {
                    $this.data('search', search = new Search($this, options));

                }

                if (typeof search[option] === 'function') {
                    search[option](value);

                }

            });

        }
    });



})(jQuery);

move.js

(function($) {
    'use strict';
    var transition = window.mt.transition;
    var init = function($elem) {
        this.$elem = $elem;
        this.curX = parseFloat(this.$elem.css('left'));
        this.curY = parseFloat(this.$elem.css('top'));

    }

    var to = function(x, y, callback) {
        x = (typeof x === 'number') ? x : this.curX;
        y = (typeof y === 'number') ? y : this.curY;
        if (this.curX === x && this.curY === y) return;

        this.$elem.trigger('move', [this.$elem]);
        if (typeof callback === 'function') {
            callback();
        }

        this.curX = x;
        this.curY = y;

    }

    var Silent = function($elem) {
        init.call(this, $elem); //改變this的指向,這裏this指外面的this,如不使用call,this指init。
        this.$elem.removeClass('transition');


    };
    Silent.prototype.to = function(x, y) {
        var self = this;
        to.call(this, x, y, function() {

            self.$elem.css({
                left: x,
                top: y
            });
            self.$elem.trigger('moved', [self.$elem]);

        });




    };
    Silent.prototype.x = function(x) {
        this.to(x);
    };
    Silent.prototype.y = function(y) {
        this.to(null, y);

    };

    // css3 方式
    var Css3 = function($elem) {
        this.$elem = $elem;
        this.$elem.addClass('transition');
        this.curX = parseFloat(this.$elem.css('left'));
        this.curY = parseFloat(this.$elem.css('top'));
        this.$elem.css({
            left: this.curX,
            top: this.curY
        });

    };

    Css3.prototype.to = function(x, y) {
        var self = this;
        to.call(this, x, y, function() {


            self.$elem.off(transition.end).one(transition.end, function() {
                self.$elem.trigger('moved', [self.$elem]);
            });

            self.$elem.css({
                left: x,
                top: y
            });

        });
    };
    Css3.prototype.x = function(x) {
        this.to(x);
    };
    Css3.prototype.y = function(y) {
        this.to(null, y);
    };


    // js方式
    var Js = function($elem) {
        init.call(this, $elem);
        this.$elem.removeClass('transition');

    };

    Js.prototype.to = function(x, y) {
        var self = this;
        to.call(this, x, y, function() {
            self.$elem.stop().animate({
                left: x,
                top: y
            }, function() {
                self.$elem.trigger('moved', [self.$elem]);
            });
        });
    };

    Js.prototype.x = function(x) {
        this.to(x);

    };
    Js.prototype.y = function(y) {
        this.to(null, y);

    };

    var defaults = {
            css3: false,
            js: false
        };

    var move = function ($elem, options) {
        var mode = null;

        if (options.css3 && transition.isSupport) { // css3 transition
            mode = new Css3($elem);
        } else if (options.js) { // js animation
            mode = new Js($elem);
        } else { // no animation
            mode = new Silent($elem);
        }

        return {
            to: $.proxy(mode.to, mode), //改變指針this指向mode.
            x: $.proxy(mode.x, mode),
            y: $.proxy(mode.y, mode)
        };
    };

    $.fn.extend({
        move: function (option,x,y) {
            return this.each(function () {
                var $this = $(this),
                    mode = $this.data('move'),
                    options = $.extend({}, defaults, typeof option === 'object' && option);

                if (!mode) { // first time
                    $this.data('move', mode = move($this, options));
                }

                if (typeof mode[option] === 'function') {
                    mode[option](x, y);
                }
            });
        }

    });

})(jQuery);

slider.js(輪播海報組件)

(function ($) {
    'use strict';

    function Slider($elem, options) {
        this.$elem = $elem;
        this.options = options;

        this.$items = this.$elem.find('.slider-item');
        this.$indicators = this.$elem.find('.slider-indicator');
        this.$controls = this.$elem.find('.slider-control');

        this.itemNum = this.$items.length;
        this.curIndex = this._getCorrectIndex(this.options.activeIndex);

        this._init();
    }
    Slider.DEFAULTS = {
        css3: false,
        js: false,
        animation: 'fade', // slide
        activeIndex: 0,
        interval: 0
    };
    Slider.prototype._init = function() {
        var self = this;
        this.$elem.trigger('slider-show',[this.curIndex,this.$items[this.curIndex]]);

        // init show
        this.$indicators.removeClass('slider-indicator-active');
        this.$indicators.eq(this.curIndex).addClass('slider-indicator-active');

        // to
        if (this.options.animation === 'slide') {
            this.$elem.addClass('slider-slide');
            this.$items.eq(this.curIndex).css('left', 0);

            // send message
            this.$items.on('move moved', function (e) {
                var index = self.$items.index(this);

                if (e.type === 'move') {
                    if (index === self.curIndex) {
                        self.$elem.trigger('slider-hide', [index, this]);
                    } else {
                        self.$elem.trigger('slider-show', [index, this]);
                    }
                } else { // moved
                    if (index === self.curIndex) { // 指定的
                        self.$elem.trigger('slider-shown', [index, this]);
                    } else {
                        self.$elem.trigger('slider-hidden', [index, this]);
                    }
                }
            });
            // move init
            this.$items.move(this.options);
            this.to = this._slide;

            this.itemWidth = this.$items.eq(0).width();
            this.transitionClass = this.$items.eq(0).hasClass('transition') ? 'transition' : '';
        } else { // fade
            this.$elem.addClass('slider-fade');
            this.$items.eq(this.curIndex).show();

            // send message
            this.$items.on('show shown hide hidden', function (e) {
                self.$elem.trigger('slider-' + e.type, [self.$items.index(this), this]);
            });
            // showHide init
            this.$items.showHide(this.options);
            this.to = this._fade;
        }

        // bind event
        this.$elem
            .hover(function () {
                self.$controls.show();
            }, function () {
                self.$controls.hide();
            })
            .on('click', '.slider-control-left', function () {
                self.to(self._getCorrectIndex(self.curIndex - 1), 1);
            })
            .on('click', '.slider-control-right', function () {
                self.to(self._getCorrectIndex(self.curIndex + 1), -1);
            })
            .on('click', '.slider-indicator', function () {
                self.to(self._getCorrectIndex(self.$indicators.index(this)));
            });

        // auto
        if (this.options.interval && !isNaN(Number(this.options.interval))) {
            this.$elem.hover($.proxy(this.pause, this), $.proxy(this.auto, this));
            this.auto();
        }
    };
    Slider.prototype._getCorrectIndex = function(index) {
        if (isNaN(Number(index))) return 0;
        if (index < 0) return this.itemNum - 1;
        if (index > this.itemNum - 1) return 0;
        return index;
    };
    Slider.prototype._activateIndicators = function(index) {
        this.$indicators.eq(this.curIndex).removeClass('slider-indicator-active');
        this.$indicators.eq(index).addClass('slider-indicator-active');
    };
    Slider.prototype._fade = function(index) {
        if (this.curIndex === index) return;

        this.$items.eq(this.curIndex).showHide('hide');
        this.$items.eq(index).showHide('show');

        this._activateIndicators(index);

        this.curIndex = index;
    };
    Slider.prototype._slide = function(index, direction) {
        if (this.curIndex === index) return;

        var self = this;

        // 肯定滑入滑出的方向
        if (!direction) { // click indicators
            if (this.curIndex < index) {
                direction = -1;
            } else if (this.curIndex > index) {
                direction = 1;
            }
        }

        // 設置指定滑入幻燈片的初始位置
        this.$items.eq(index).removeClass(this.transitionClass).css('left', -1 * direction * this.itemWidth);

        // 當前幻燈片滑出可視區域,指定幻燈片滑入可視區域
        setTimeout(function () {
            self.$items.eq(self.curIndex).move('x', direction * self.itemWidth);
            self.$items.eq(index).addClass(self.transitionClass).move('x', 0);
            self.curIndex = index;
        }, 20);
        
        // 激活indicator
        this._activateIndicators(index);
    };
    Slider.prototype.auto = function() {
        var self = this;

        this.intervalId = setInterval(function () {
            self.to(self._getCorrectIndex(self.curIndex + 1), -1);
        }, this.options.interval);
    };
    Slider.prototype.pause = function() {
        clearInterval(this.intervalId);
    };

    $.fn.extend({
        slider: function (option) {
            return this.each(function () {
                var $this = $(this),
                    slider = $this.data('slider'),
                    options = $.extend({}, Slider.DEFAULTS, $this.data(), typeof option === 'object' && option);

                if (!slider) { // first time
                    $this.data('slider', slider = new Slider($this, options));
                }

                if (typeof slider[option] === 'function') {
                    slider[option]();
                }
            });
        }
    })
})(jQuery);

 

 tab.js(tab選項卡組件)

(function($) {
    'use strict';

    function Tab($elem, options) {
        this.$elem = $elem;
        this.options = options;

        this.$items = this.$elem.find('.tab-item');
        this.$panels = this.$elem.find('.tab-panel');

        this.itemNum = this.$items.length;
        this.curIndex = this._getCorrectIndex(this.options.activeIndex);

        this._init();
    }
    Tab.DEFAULTS = {
        event: 'mouseenter', // click
        css3: false,
        js: false,
        animation: 'fade',
        activeIndex: 0,
        interval:0,
        delay:0

    };
    Tab.prototype._init = function() {
        var self = this,
            timer=null;

        // init show
        this.$items.removeClass('tab-item-active');
        this.$items.eq(this.curIndex).addClass('tab-item-active');
        this.$panels.eq(this.curIndex).show();
        this.$elem.trigger('tab-show', [this.curIndex, this.$panels[this.curIndex]]);


        // trigger event
        this.$panels.on('show shown hide hidden', function(e) {
            self.$elem.trigger('tab-' + e.type, [self.$panels.index(this), this]);
        });

        // showHide init
        this.$panels.showHide(this.options);

        // bind event
        this.options.event = this.options.event === 'click' ? 'click' : 'mouseenter';
        this.$elem.on(this.options.event, '.tab-item', function() {
            var elem=this;
            if (self.options.delay) { // delay
                clearTimeout(timer);
                timer = setTimeout(function () {
                    self.toggle(self.$items.index(elem));
                }, self.options.delay);
            } else { // immediate
                self.toggle(self.$items.index(elem));
            }

        });

        // auto
        if (this.options.interval && !isNaN(Number(this.options.interval))) {
            this.$elem.hover($.proxy(this.pause, this), $.proxy(this.auto, this));
            this.auto();
        }


    };
    Tab.prototype._getCorrectIndex = function(index) {
        if (isNaN(Number(index))) return 0;
        if (index < 0) return this.itemNum - 1;
        if (index > this.itemNum - 1) return 0;
        return index;
    };
    Tab.prototype.toggle = function(index) {
        if (this.curIndex === index) return;

        this.$panels.eq(this.curIndex).showHide('hide');
        this.$panels.eq(index).showHide('show');

        this.$items.eq(this.curIndex).removeClass('tab-item-active');
        this.$items.eq(index).addClass('tab-item-active');

        this.curIndex = index;
    };


    Tab.prototype.auto = function() {
        var self = this;

        this.intervalId = setInterval(function () {
            self.toggle(self._getCorrectIndex(self.curIndex + 1));
        }, this.options.interval);
    };
    Tab.prototype.pause = function() {
        clearInterval(this.intervalId);
    };

    $.fn.extend({
        tab: function(option) {
            return this.each(function() {
                var $this = $(this),
                    tab = $this.data('tab'),
                    options = $.extend({}, Tab.DEFAULTS, $this.data(), typeof option === 'object' && option);

                if (!tab && typeof option !== 'object') return;

                if (!tab) { // first time
                    $this.data('tab', tab = new Tab($this, options));
                }

                if (typeof tab[option] === 'function') {
                    tab[option]();
                }
            });
        }
    });
})(jQuery);

index.js

(function($) {

    'use strict';
    //menu
    var dropdown = {};
    $('.menu')
        .on('dropdown-show', function(e) {
            dropdown.loadOnce($(this), dropdown.buildMenuItem);
        })
        .dropdown({
            css3: true,
            js: false
        });

    dropdown.buildMenuItem = function($elem, data) {

        var html = "";
        if (data.length === 0) return;
        for (var i = 0; i < data.length; i++) {
            html += '<li><a href="' + data[i].url + '" target="_blank" class="menu-item">' + data[i].name + '</a></li>'
        }
        $elem.find('.dropdown-layer').html(html);

    };

    //header search
    var search = {};
    search.$headerSearch = $('#header-search');
    search.$headerSearch.html = '';
    search.$headerSearch.maxNum = 10;

    // 得到數據處理
    search.$headerSearch.on('search-getData', function(e, data) {
        var $this = $(this);
        search.$headerSearch.html = search.$headerSearch.createHeaderSearchLayer(data, search.$headerSearch.maxNum);
        $this.search('appendLayer', search.$headerSearch.html);
        // 將生成的html呈如今頁面中        
        if (search.$headerSearch.html) {
            $this.search('showLayer');
        } else {
            $this.search('hideLayer');

        }
    }).on('search-noData', function(e) {
        // 沒得到數據處理
        $(this).search('hideLayer').search('appendLayer', '');

    }).on('click', '.search-layer-item', function() {
        // 點擊每項時,提交
        search.$headerSearch.search('setInputVal', $(this).html());
        search.$headerSearch.search('submit');
    });

    search.$headerSearch.search({
        autocomplete: true,
        css3: false,
        js: false,
        animation: 'fade',
        getDataInterval: 0
    });

    // 獲取數據,生成html

    search.$headerSearch.createHeaderSearchLayer = function(data, maxNum) {
        var html = '',
            dataNum = data['result'].length;

        if (dataNum === 0) {
            return '';
        }
        for (var i = 0; i < dataNum; i++) {
            if (i >= maxNum) break;
            html += '<li class="search-layer-item text-ellipsis">' + data['result'][i][0] + '</li>';
        }
        return html;

    };

    // focus-category

    $('#focus-category').find('.dropdown')
        .on('dropdown-show', function() {
            dropdown.loadOnce($(this), dropdown.createCategoryDetails);
        })
        .dropdown({
            css3: false,
            js: false
        });

    dropdown.createCategoryDetails = function($elem, data) {
        var html = '';
        for (var i = 0; i < data.length; i++) {
            html += '<dl class="category-details cf"><dt class="category-details-title fl"><a href="###" target="_blank" class="category-details-title-link">' + data[i].title + '</a></dt><dd class="category-details-item fl">';

            for (var j = 0; j < data[i].items.length; j++) {
                html += '<a href="###" target="_blank" class="link">' + data[i].items[j] + '</a>';
            }
            html += '</dd></dl>';
        }
        // setTimeout(function () {
        $elem.find('.dropdown-layer').html(html);
        // },1000);

    };

    dropdown.loadOnce = function($elem, success) {
        var dataLoad = $elem.data('load');
        if (!dataLoad) return;
        if (!$elem.data('loaded')) {
            $elem.data('loaded', true);
            $.getJSON(dataLoad).done(function(data) {
                if (typeof success === 'function') success($elem, data);
            }).fail(function() {
                $elem.data('loaded', false);
            });
        }
    };

   // imgLoader
    var imgLoader = {};
    imgLoader.loadImg = function(url, imgLoaded, imgFailed) {
        var image = new Image();
        image.onerror = function() {
            if (typeof imgFailed === 'function') imgFailed(url);
        }
        image.onload = function() {
            if (typeof imgLoaded === 'function') imgLoaded(url);
        };
        image.src = url;
    };

    imgLoader.loadImgs = function($imgs, success, fail) {        
        
        $imgs.each(function(_, el) { // _ 至關佔位,不使用該參數。
            var $img = $(el);
            imgLoader.loadImg($img.data('src'), function(url) {
                $img.attr('src', url);
                success();
            }, function(url) {
                console.log('從' + url + '加載圖片失敗');
                fail($img, url);
            });
        });
    }

    //lazyLoad

    var lazyLoad = {};

    lazyLoad.loadUntil = function(options) {

        var items = {},
            loadedItemNum = 0,
            loadItemFn = null,
            $elem = options.$container,
            id = options.id
        // 何時開始加載
        $elem.on(options.triggerEvent, loadItemFn = function(e, index, elem) {
            if (items[index] !== 'loaded') {
                $elem.trigger(id + '-loadItem', [index, elem, function() {
                    items[index] = 'loaded';
                    loadedItemNum++;
                    console.log(index + ': loaded');
                    if (loadedItemNum === options.totalItemNum) {
                        // 所有加載完畢
                        $elem.trigger(id + '-itemsLoaded');
                    }
                }]);
            }
        });

        //加載完畢
        $elem.on(id + '-itemsLoaded', function(e) {
            console.log(id + '-itemsLoaded');
            // 清除事件
            $elem.off(options.triggerEvent, loadItemFn);
        });

    }

    lazyLoad.isVisible = function(offsetTop,height) {
        var $win = browser.$win;
        return ($win.height() + $win.scrollTop() > offsetTop) && ($win.scrollTop() < offsetTop + height)
    }


    // foucs-slider
    var slider = {};
    slider.$focusSlider = $('#focus-slider');
    
    slider.$focusSlider.on('focus-loadItem', function(e, index, elem, success) {

        imgLoader.loadImgs($(elem).find('.slider-img'), success, function($img, url) {
            $img.attr('src', 'img/focus-slider/placeholder.png');
        });
    });

    lazyLoad.loadUntil({
        $container: slider.$focusSlider,
        totalItemNum: slider.$focusSlider.find('.slider-img').length,
        triggerEvent: 'slider-show',
        id: 'focus'
    });


    slider.$focusSlider.slider({
        css3: true,
        js: false,
        animation: 'fade', // fade  slide
        activeIndex: 0,
        interval: 0
    });


    // todays-slider   
    slider.$todaysSlider = $('#todays-slider');
    
    slider.$todaysSlider.on('todays-loadItem', function(e, index, elem, success) {

        imgLoader.loadImgs($(elem).find('.slider-img'), success, function($img, url) {
            $img.attr('src', 'img/todays-slider/placeholder.png');
        });
    });

    lazyLoad.loadUntil({
        $container: slider.$todaysSlider,
        totalItemNum: slider.$todaysSlider.find('.slider-img').length,
        triggerEvent: 'slider-show',
        id: 'todays'
    });

    slider.$todaysSlider.slider({
        css3: true,
        js: false,
        animation: 'fade', // fade  slide
        activeIndex: 0,
        interval: 0
    });


//floor
    var floor = {};
    floor.$floor = $('.floor');


    floor.floorData = [{
        num: '1',
        text: '服裝鞋包',
        tabs: ['大牌', '男裝', '女裝'],
        offsetTop: floor.$floor.eq(0).offset().top,
        height: floor.$floor.eq(0).height(),
        items: [
            [{
                name: '匡威男棒球開衫外套2015',
                price: 479
            }, {
                name: 'adidas 阿迪達斯 訓練 男子',
                price: 335
            }, {
                name: '必邁BMAI一體織跑步短袖T恤',
                price: 159
            }, {
                name: 'NBA襪子半毛圈運動高邦棉襪',
                price: 65
            }, {
                name: '特步官方運動帽男女帽子2016',
                price: 69
            }, {
                name: 'KELME足球訓練防寒防風手套',
                price: 4999
            }, {
                name: '戰地吉普三合一衝鋒衣',
                price: 289
            }, {
                name: '探路者戶外男士徒步鞋',
                price: 369
            }, {
                name: '羽絨服2015秋冬新款輕薄男士',
                price: 399
            }, {
                name: '溯溪鞋涉水鞋戶外鞋',
                price: 689
            }, {
                name: '旅行揹包多功能雙肩揹包',
                price: 269
            }, {
                name: '戶外旅行雙肩揹包OS0099',
                price: 99
            }],
            [{
                name: '匡威男棒球開衫外套2015',
                price: 479
            }, {
                name: 'adidas 阿迪達斯 訓練 男子',
                price: 335
            }, {
                name: '必邁BMAI一體織跑步短袖T恤',
                price: 159
            }, {
                name: 'NBA襪子半毛圈運動高邦棉襪',
                price: 65
            }, {
                name: '特步官方運動帽男女帽子2016',
                price: 69
            }, {
                name: 'KELME足球訓練防寒防風手套',
                price: 4999
            }, {
                name: '戰地吉普三合一衝鋒衣',
                price: 289
            }, {
                name: '探路者戶外男士徒步鞋',
                price: 369
            }, {
                name: '羽絨服2015秋冬新款輕薄男士',
                price: 399
            }, {
                name: '溯溪鞋涉水鞋戶外鞋',
                price: 689
            }, {
                name: '旅行揹包多功能雙肩揹包',
                price: 269
            }, {
                name: '戶外旅行雙肩揹包OS0099',
                price: 99
            }],
            [{
                name: '匡威男棒球開衫外套2015',
                price: 479
            }, {
                name: 'adidas 阿迪達斯 訓練 男子',
                price: 335
            }, {
                name: '必邁BMAI一體織跑步短袖T恤',
                price: 159
            }, {
                name: 'NBA襪子半毛圈運動高邦棉襪',
                price: 65
            }, {
                name: '特步官方運動帽男女帽子2016',
                price: 69
            }, {
                name: 'KELME足球訓練防寒防風手套',
                price: 4999
            }, {
                name: '戰地吉普三合一衝鋒衣',
                price: 289
            }, {
                name: '探路者戶外男士徒步鞋',
                price: 369
            }, {
                name: '羽絨服2015秋冬新款輕薄男士',
                price: 399
            }, {
                name: '溯溪鞋涉水鞋戶外鞋',
                price: 689
            }, {
                name: '旅行揹包多功能雙肩揹包',
                price: 269
            }, {
                name: '戶外旅行雙肩揹包OS0099',
                price: 99
            }]
        ]
    }, {
        num: '2',
        text: '個護美妝',
        tabs: ['熱門', '國際大牌', '國際名品'],
        offsetTop: floor.$floor.eq(1).offset().top,
        height: floor.$floor.eq(1).height(),
        items: [
            [{
                name: '韓束紅石榴鮮活水盈七件套裝',
                price: 169
            }, {
                name: '溫碧泉八杯水親親水潤五件套裝',
                price: 198
            }, {
                name: '御泥坊紅酒透亮礦物蠶絲面膜貼',
                price: 79.9
            }, {
                name: '吉列手動剃鬚刀鋒隱致護',
                price: 228
            }, {
                name: 'Mediheal水潤保溼面膜',
                price: 119
            }, {
                name: '納益其爾蘆薈舒緩保溼凝膠',
                price: 39
            }, {
                name: '寶拉珍選基礎護膚旅行四件套',
                price: 299
            }, {
                name: '溫碧泉透芯潤五件套裝',
                price: 257
            }, {
                name: '玉蘭油多效修護三部曲套裝',
                price: 199
            }, {
                name: 'LOREAL火山岩控油清痘潔面膏',
                price: 36
            }, {
                name: '百雀羚水嫩倍現盈透精華水',
                price: 139
            }, {
                name: '珀萊雅新柔皙瑩潤三件套',
                price: 99
            }],
            [{
                name: '韓束紅石榴鮮活水盈七件套裝',
                price: 169
            }, {
                name: '溫碧泉八杯水親親水潤五件套裝',
                price: 198
            }, {
                name: '御泥坊紅酒透亮礦物蠶絲面膜貼',
                price: 79.9
            }, {
                name: '吉列手動剃鬚刀鋒隱致護',
                price: 228
            }, {
                name: 'Mediheal水潤保溼面膜',
                price: 119
            }, {
                name: '納益其爾蘆薈舒緩保溼凝膠',
                price: 39
            }, {
                name: '寶拉珍選基礎護膚旅行四件套',
                price: 299
            }, {
                name: '溫碧泉透芯潤五件套裝',
                price: 257
            }, {
                name: '玉蘭油多效修護三部曲套裝',
                price: 199
            }, {
                name: 'LOREAL火山岩控油清痘潔面膏',
                price: 36
            }, {
                name: '百雀羚水嫩倍現盈透精華水',
                price: 139
            }, {
                name: '珀萊雅新柔皙瑩潤三件套',
                price: 99
            }],
            [{
                name: '韓束紅石榴鮮活水盈七件套裝',
                price: 169
            }, {
                name: '溫碧泉八杯水親親水潤五件套裝',
                price: 198
            }, {
                name: '御泥坊紅酒透亮礦物蠶絲面膜貼',
                price: 79.9
            }, {
                name: '吉列手動剃鬚刀鋒隱致護',
                price: 228
            }, {
                name: 'Mediheal水潤保溼面膜',
                price: 119
            }, {
                name: '納益其爾蘆薈舒緩保溼凝膠',
                price: 39
            }, {
                name: '寶拉珍選基礎護膚旅行四件套',
                price: 299
            }, {
                name: '溫碧泉透芯潤五件套裝',
                price: 257
            }, {
                name: '玉蘭油多效修護三部曲套裝',
                price: 199
            }, {
                name: 'LOREAL火山岩控油清痘潔面膏',
                price: 36
            }, {
                name: '百雀羚水嫩倍現盈透精華水',
                price: 139
            }, {
                name: '珀萊雅新柔皙瑩潤三件套',
                price: 99
            }]
        ]
    }, {
        num: '3',
        text: '手機通信',
        tabs: ['熱門', '品質優選', '新機嚐鮮'],
        offsetTop: floor.$floor.eq(2).offset().top,
        height: floor.$floor.eq(2).height(),
        items: [
            [{
                name: '摩托羅拉 Moto Z Play',
                price: 3999
            }, {
                name: 'Apple iPhone 7 (A1660)',
                price: 6188
            }, {
                name: '小米 Note 全網通 白色',
                price: 999
            }, {
                name: '小米5 全網通 標準版 3GB內存',
                price: 1999
            }, {
                name: '榮耀7i 海島藍 移動聯通4G手機',
                price: 1099
            }, {
                name: '樂視(Le)樂2(X620)32GB',
                price: 1099
            }, {
                name: 'OPPO R9 4GB+64GB內存版',
                price: 2499
            }, {
                name: '魅藍note3 全網通公開版',
                price: 899
            }, {
                name: '飛利浦 X818 香檳金 全網通4G',
                price: 1998
            }, {
                name: '三星 Galaxy S7(G9300)',
                price: 4088
            }, {
                name: '華爲 榮耀7 雙卡雙待雙通',
                price: 1128
            }, {
                name: '努比亞(nubia)Z7Max(NX505J)',
                price: 728
            }],
            [{
                name: '摩托羅拉 Moto Z Play',
                price: 3999
            }, {
                name: 'Apple iPhone 7 (A1660)',
                price: 6188
            }, {
                name: '小米 Note 全網通 白色',
                price: 999
            }, {
                name: '小米5 全網通 標準版 3GB內存',
                price: 1999
            }, {
                name: '榮耀7i 海島藍 移動聯通4G手機',
                price: 1099
            }, {
                name: '樂視(Le)樂2(X620)32GB',
                price: 1099
            }, {
                name: 'OPPO R9 4GB+64GB內存版',
                price: 2499
            }, {
                name: '魅藍note3 全網通公開版',
                price: 899
            }, {
                name: '飛利浦 X818 香檳金 全網通4G',
                price: 1998
            }, {
                name: '三星 Galaxy S7(G9300)',
                price: 4088
            }, {
                name: '華爲 榮耀7 雙卡雙待雙通',
                price: 1128
            }, {
                name: '努比亞(nubia)Z7Max(NX505J)',
                price: 728
            }],
            [{
                name: '摩托羅拉 Moto Z Play',
                price: 3999
            }, {
                name: 'Apple iPhone 7 (A1660)',
                price: 6188
            }, {
                name: '小米 Note 全網通 白色',
                price: 999
            }, {
                name: '小米5 全網通 標準版 3GB內存',
                price: 1999
            }, {
                name: '榮耀7i 海島藍 移動聯通4G手機',
                price: 1099
            }, {
                name: '樂視(Le)樂2(X620)32GB',
                price: 1099
            }, {
                name: 'OPPO R9 4GB+64GB內存版',
                price: 2499
            }, {
                name: '魅藍note3 全網通公開版',
                price: 899
            }, {
                name: '飛利浦 X818 香檳金 全網通4G',
                price: 1998
            }, {
                name: '三星 Galaxy S7(G9300)',
                price: 4088
            }, {
                name: '華爲 榮耀7 雙卡雙待雙通',
                price: 1128
            }, {
                name: '努比亞(nubia)Z7Max(NX505J)',
                price: 728
            }]
        ]
    }, {
        num: '4',
        text: '家用電器',
        tabs: ['熱門', '你們電', '生活電器'],
        offsetTop: floor.$floor.eq(3).offset().top,
        height: floor.$floor.eq(3).height(),
        items: [
            [{
                name: '暴風TV 超體電視 40X 40英寸',
                price: 1299
            }, {
                name: '小米(MI)L55M5-AA 55英寸',
                price: 3699
            }, {
                name: '飛利浦HTD5580/93 音響',
                price: 2999
            }, {
                name: '金門子H108 5.1套裝音響組合',
                price: 1198
            }, {
                name: '方太ENJOY雲魔方抽油煙機',
                price: 4390
            }, {
                name: '美的60升預定洗浴電熱水器',
                price: 1099
            }, {
                name: '九陽電飯煲多功能智能電飯鍋',
                price: 159
            }, {
                name: '美的電烤箱家用大容量',
                price: 329
            }, {
                name: '奧克斯(AUX)936破壁料理機',
                price: 1599
            }, {
                name: '飛利浦麪條機 HR2356/31',
                price: 665
            }, {
                name: '松下NU-JA100W 家用蒸烤箱',
                price: 1799
            }, {
                name: '飛利浦咖啡機 HD7751/00',
                price: 1299
            }],
            [{
                name: '暴風TV 超體電視 40X 40英寸',
                price: 1299
            }, {
                name: '小米(MI)L55M5-AA 55英寸',
                price: 3699
            }, {
                name: '飛利浦HTD5580/93 音響',
                price: 2999
            }, {
                name: '金門子H108 5.1套裝音響組合',
                price: 1198
            }, {
                name: '方太ENJOY雲魔方抽油煙機',
                price: 4390
            }, {
                name: '美的60升預定洗浴電熱水器',
                price: 1099
            }, {
                name: '九陽電飯煲多功能智能電飯鍋',
                price: 159
            }, {
                name: '美的電烤箱家用大容量',
                price: 329
            }, {
                name: '奧克斯(AUX)936破壁料理機',
                price: 1599
            }, {
                name: '飛利浦麪條機 HR2356/31',
                price: 665
            }, {
                name: '松下NU-JA100W 家用蒸烤箱',
                price: 1799
            }, {
                name: '飛利浦咖啡機 HD7751/00',
                price: 1299
            }],
            [{
                name: '暴風TV 超體電視 40X 40英寸',
                price: 1299
            }, {
                name: '小米(MI)L55M5-AA 55英寸',
                price: 3699
            }, {
                name: '飛利浦HTD5580/93 音響',
                price: 2999
            }, {
                name: '金門子H108 5.1套裝音響組合',
                price: 1198
            }, {
                name: '方太ENJOY雲魔方抽油煙機',
                price: 4390
            }, {
                name: '美的60升預定洗浴電熱水器',
                price: 1099
            }, {
                name: '九陽電飯煲多功能智能電飯鍋',
                price: 159
            }, {
                name: '美的電烤箱家用大容量',
                price: 329
            }, {
                name: '奧克斯(AUX)936破壁料理機',
                price: 1599
            }, {
                name: '飛利浦麪條機 HR2356/31',
                price: 665
            }, {
                name: '松下NU-JA100W 家用蒸烤箱',
                price: 1799
            }, {
                name: '飛利浦咖啡機 HD7751/00',
                price: 1299
            }]
        ]
    }, {
        num: '5',
        text: '電腦數碼',
        tabs: ['熱門', '電腦/平板', '潮流影音'],
        offsetTop: floor.$floor.eq(4).offset().top,
        height: floor.$floor.eq(4).height(),
        items: [
            [{
                name: '戴爾成就Vostro 3800-R6308',
                price: 2999
            }, {
                name: '聯想IdeaCentre C560',
                price: 5399
            }, {
                name: '惠普260-p039cn臺式電腦',
                price: 3099
            }, {
                name: '華碩飛行堡壘旗艦版FX-PRO',
                price: 6599
            }, {
                name: '惠普(HP)暗影精靈II代PLUS',
                price: 12999
            }, {
                name: '聯想(Lenovo)小新700電競版',
                price: 5999
            }, {
                name: '遊戲背光牧馬人機械手感鍵盤',
                price: 499
            }, {
                name: '羅技iK1200背光鍵盤保護套',
                price: 799
            }, {
                name: '西部數據2.5英寸移動硬盤1TB',
                price: 419
            }, {
                name: '新睿翼3TB 2.5英寸 移動硬盤',
                price: 849
            }, {
                name: 'Rii mini i28無線迷你鍵盤鼠標',
                price: 349
            }, {
                name: '羅技G29 力反饋遊戲方向盤',
                price: 2999
            }],
            [{
                name: '戴爾成就Vostro 3800-R6308',
                price: 2999
            }, {
                name: '聯想IdeaCentre C560',
                price: 5399
            }, {
                name: '惠普260-p039cn臺式電腦',
                price: 3099
            }, {
                name: '華碩飛行堡壘旗艦版FX-PRO',
                price: 6599
            }, {
                name: '惠普(HP)暗影精靈II代PLUS',
                price: 12999
            }, {
                name: '聯想(Lenovo)小新700電競版',
                price: 5999
            }, {
                name: '遊戲背光牧馬人機械手感鍵盤',
                price: 499
            }, {
                name: '羅技iK1200背光鍵盤保護套',
                price: 799
            }, {
                name: '西部數據2.5英寸移動硬盤1TB',
                price: 419
            }, {
                name: '新睿翼3TB 2.5英寸 移動硬盤',
                price: 849
            }, {
                name: 'Rii mini i28無線迷你鍵盤鼠標',
                price: 349
            }, {
                name: '羅技G29 力反饋遊戲方向盤',
                price: 2999
            }],
            [{
                name: '戴爾成就Vostro 3800-R6308',
                price: 2999
            }, {
                name: '聯想IdeaCentre C560',
                price: 5399
            }, {
                name: '惠普260-p039cn臺式電腦',
                price: 3099
            }, {
                name: '華碩飛行堡壘旗艦版FX-PRO',
                price: 6599
            }, {
                name: '惠普(HP)暗影精靈II代PLUS',
                price: 12999
            }, {
                name: '聯想(Lenovo)小新700電競版',
                price: 5999
            }, {
                name: '遊戲背光牧馬人機械手感鍵盤',
                price: 499
            }, {
                name: '羅技iK1200背光鍵盤保護套',
                price: 799
            }, {
                name: '西部數據2.5英寸移動硬盤1TB',
                price: 419
            }, {
                name: '新睿翼3TB 2.5英寸 移動硬盤',
                price: 849
            }, {
                name: 'Rii mini i28無線迷你鍵盤鼠標',
                price: 349
            }, {
                name: '羅技G29 力反饋遊戲方向盤',
                price: 2999
            }]
        ]
    }];


    floor.buildFloor = function(floorData) {
        var html = '';

        html += '<div class="container">';
        html += floor.buildFloorHead(floorData);
        html += floor.buildFloorBody(floorData);
        html += '</div>';

        return html;
    };

    floor.buildFloorHead = function(floorData) {
        var html = '';
        html += '<div class="floor-head">';
        html += '<h2 class="floor-title fl"><span class="floor-title-num">' + floorData.num + 'F</span><span class="floor-title-text">' + floorData.text + '</span></h2>';
        html += '<ul class="tab-item-wrap fr">';
        for (var i = 0; i < floorData.tabs.length; i++) {
            html += '<li class="fl"><a href="javascript:;" class="tab-item">' + floorData.tabs[i] + '</a></li>';
            if (i !== floorData.tabs.length - 1) {
                html += '<li class="floor-divider fl text-hidden">分隔線</li>';
            }
        }
        html += '</ul>';
        html += '</div>';
        return html;
    };

    floor.buildFloorBody = function(floorData) {
        var html = '';
        html += '<div class="floor-body">';
        for (var i = 0; i < floorData.items.length; i++) {
            html += '<ul class="tab-panel">';
            for (var j = 0; j < floorData.items[i].length; j++) {
                html += '<li class="floor-item fl">';
                html += '<p class="floor-item-pic"><a href="###" target="_blank"><img src="img/floor/loading.gif" class="floor-img" data-src="img/floor/' + floorData.num + '/' + (i + 1) + '/' + (j + 1) + '.png" alt="" /></a></p>';
                html += '<p class="floor-item-name"><a href="###" target="_blank" class="link">' + floorData.items[i][j].name + '</a></p>';
                html += '<p class="floor-item-price">' + floorData.items[i][j].price + '</p>';
                html += '</li>';
            }

            html += '</ul>';
        }

        html += '</div>';

        return html;
    };

    var browser={};    

    browser.$win = $(window);
    browser.$doc = $(document);

    
    floor.timeToShow = function() {
        console.log('time to show');
        floor.$floor.each(function(index, elem) {
            if (lazyLoad.isVisible(floor.floorData[index].offsetTop,floor.floorData[index].height)) {
                browser.$doc.trigger('floor-show', [index, elem]);
            }
        });
    }

    browser.$win.on('scroll resize', floor.showFloor=function () {
        clearTimeout(floor.floorTimer);
        floor.floorTimer=setTimeout(floor.timeToShow,250);
    });

    floor.$floor.on('floor-loadItem', function(e, index, elem, success) {

        imgLoader.loadImgs($(elem).find('.floor-img'), success, function($img, url) {
            $img.attr('src', 'img/floor.placeholder.png');
        });
    });

    browser.$doc.on('floors-loadItem', function(e, index, elem, success) {

        var html = floor.buildFloor(floor.floorData[index]),
            $elem = $(elem);
        success();
            $elem.html(html);
            lazyLoad.loadUntil({
                $container: $elem,
                totalItemNum: $elem.find('.floor-img').length,
                triggerEvent: 'tab-show',
                id: 'floor'
            });
            $elem.tab({
                event: 'mouseenter', // mouseenter或click
                css3: false,
                js: false,
                animation: 'fade',
                activeIndex: 0,
                interval: 0,
                delay: 0
            });

    });

    browser.$doc.on('floors-itemsLoaded', function() {
        browser.$win.off('scroll resize', floor.showFloor);
    });

    lazyLoad.loadUntil({
        $container: browser.$doc,
        totalItemNum: floor.$floor.length,
        triggerEvent: 'floor-show',
        id: 'floors'
    });

    floor.timeToShow();


// elevator
    floor.whichFloor = function () {
        var num = -1;

        floor.$floor.each(function (index, elem) {
            var floorData = floor.floorData[index];

            num = index;

            if (browser.$win.scrollTop()+browser.$win.height()/2 < floorData.offsetTop) {
                num = index - 1;
                return false;
            }
        });

        return num;
    };
    console.log(floor.whichFloor());

    floor.$elevator = $('#elevator');
    floor.$elevator.$items = floor.$elevator.find('.elevator-item');
    floor.setElevator = function () {
        var num = floor.whichFloor();

        if (num === -1) { // hide
            floor.$elevator.fadeOut();
        } else { // show
            floor.$elevator.fadeIn();
            floor.$elevator.$items.removeClass('elevator-active');
            floor.$elevator.$items.eq(num).addClass('elevator-active');
        }
    };

    floor.setElevator();

    browser.$win.on('scroll resize', function () {
        clearTimeout(floor.elevatorTimer);
        floor.elevatorTimer = setTimeout(floor.setElevator, 250);
    });

    floor.$elevator.on('click', '.elevator-item', function () {
        $('html, body').animate({
            scrollTop: floor.floorData[$(this).index()].offsetTop
        });
    });

    $('#backToTop').on('click', function () {
        $('html, body').animate({
            scrollTop: 0
        });
    });


})(jQuery);

json數據就不貼出了……

相關文章
相關標籤/搜索