亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

購物車頁面總結(jié)

原創(chuàng) 2019-03-11 13:40:25 477
摘要:基本思路:    首先將購物車頁面布局搭建出來,再將全選、商品數(shù)量的加減、相關(guān)價(jià)格的計(jì)算以及商品的總價(jià)通過jQuery實(shí)現(xiàn)對應(yīng)的邏輯功能計(jì)算出來,最終實(shí)現(xiàn)相關(guān)功能。注意事項(xiàng):1. 獲取當(dāng)前class名時(shí),需使用attr獲?。?. 在做全選功能時(shí),需要的邏輯功能是點(diǎn)擊全選按鈕下方的商品都被選中,若下方商品未被全部選中時(shí),則全選框?yàn)楸稽c(diǎn)擊。檢

基本思路:

    首先將購物車頁面布局搭建出來,再將全選、商品數(shù)量的加減、相關(guān)價(jià)格的計(jì)算以及商品的總價(jià)通過jQuery實(shí)現(xiàn)對應(yīng)的邏輯功能計(jì)算出來,最終實(shí)現(xiàn)相關(guān)功能。

注意事項(xiàng):

1. 獲取當(dāng)前class名時(shí),需使用attr獲??;

2. 在做全選功能時(shí),需要的邏輯功能是點(diǎn)擊全選按鈕下方的商品都被選中,若下方商品未被全部選中時(shí),則全選框?yàn)楸稽c(diǎn)擊。檢查是否被全選時(shí)需要?jiǎng)?chuàng)立一個(gè)相關(guān)功能的函數(shù),在函數(shù)中設(shè)置兩個(gè)變量分別存儲(chǔ)相關(guān)div沒有被選中時(shí)class的長度和相關(guān)div被選中時(shí)class的div的長度,通過條件判斷語句判斷它們此時(shí)的class名是否相等來給予全選鍵相關(guān)邏輯,以實(shí)現(xiàn)相關(guān)功能;

3. siblings() 獲得匹配集合中每個(gè)元素的同胞,通過選擇器進(jìn)行篩選是可選的;parseInt() 函數(shù)可解析一個(gè)字符串,并返回一個(gè)整數(shù)。

4. 三元運(yùn)算符格式為:條件表達(dá)式?表達(dá)式1:表達(dá)式2,條件表達(dá)式成立時(shí)輸出表達(dá)式1,否則輸出表達(dá)式2;

完整代碼:

html部分:

<!DOCTYPE html>
<html>
<head>
    <title>小米商城</title>
    <meta charset="utf-8">
    <link rel="shortcut icon" type="image/x-icon" href="static/images/footlogo.png" />
    <link rel="stylesheet" type="text/css" href="static/css/style.css">
    <link rel="stylesheet" href="static/css/cart.css">
    <link rel="stylesheet" href="static/font-awesome/css/font-awesome.min.css">
    <script src="static/js/jq_3.3.1_mi.js"></script>
    <script src="static/js/cart.js"></script>
</head>
<body>
    <!-- 購物車頭部 -->
    <div>
        <div>
            <div>
                <a href=""></a>
                <h1>我的購物車</h1>
                
                <h6>溫馨提示:產(chǎn)品是否購買成功,以最終下單為準(zhǔn)哦,請盡快結(jié)算</h6>
            </div>
            <div>
                <div>
                    <div>
                        <a href="javascript:void(0)">我是某某某</a>
                        <ul>
                            <li>個(gè)人中心</li>
                            <li>評價(jià)曬單</li>
                            <li>我的喜歡</li>
                            <li>小米賬戶</li>
                            <li>退出登錄</li>
                        </ul>
                    </div>
                    <i class="fa fa-angle-down fa-1x"></i>
                </div>
                <div><a href="order.html">我的訂單</a></div>
            </div>
        </div>
    </div>
    

    <!-- 購物車軀干部分 -->
    <div>
        <!--購物車-->
        <div>
            <div class="list list-title">
                <div class="select select-all"><i class="fa fa-check" id="check-all"></i>全選</div>
                <div></div>
                <div style="font-size:14px; ">商品名稱</div>
                <div>單價(jià)</div>
                <div>數(shù)量</div>
                <divstyle="color:#424242;">小計(jì)</div>
                <div>操作</div>
            </div>
            <div class="list list-item">
                <div><i class="fa fa-check"></i></div>
                <div><img src="static/images/phone/phone1.png" alt=""></div>
                <div> 小米MIX 2S 全網(wǎng)通版 6GB內(nèi)存 陶瓷標(biāo)準(zhǔn)版 64GB 白色 64GB </div>
                <div>3199元</div>
                <div>
                    <div>
                        <button>-</button>
                        <input type="text" value="1">
                        <button>+</button>
                    </div>
                </div>
                <div>3199元</div>
                <div><i class="fa fa-times"></i></div>
            </div>
            <div class="list list-item">
                <div><i class="fa fa-check"></i></div>
                <div><img src="static/images/phone/phone1.png" alt=""></div>
                <div> 小米MIX 2S 全網(wǎng)通版 6GB內(nèi)存 陶瓷標(biāo)準(zhǔn)版 64GB 白色 64GB </div>
                <div>3199元</div>
                <div>
                    <div>
                        <button>-</button>
                        <input type="text" value="1">
                        <button>+</button>
                    </div>
                </div>
                <div>3199元</div>
                <div><i class="fa fa-times"></i></div>
            </div>
            <div class="list list-item">
                <div><i class="fa fa-check"></i></div>
                <div><img src="static/images/phone/phone1.png" alt=""></div>
                <div> 小米MIX 2S 全網(wǎng)通版 6GB內(nèi)存 陶瓷標(biāo)準(zhǔn)版 64GB 白色 64GB </div>
                <div>3199元</div>
                <div>
                    <div>
                        <button>-</button>
                        <input type="text" value="1">
                        <button>+</button>
                    </div>
                </div>
                <div>3199元</div>
                <div><i class="fa fa-times"></i></div>
            </div>
            <div class="list list-total">
                <div>
                    <span><a href="">繼續(xù)購物</a></span>
                    <span>共 <span>0</span> 件商品,已選擇 <span>0</span> 件</span>
                </div>
                <div>
                    <div>合計(jì): <span>0</span> 元</div>
                    <a href="./close.html"><button>去結(jié)算</button></a>
                </div>
            </div>
        </div>

        <!--其他商品推薦-->
        <div style="margin-top: 60px;">
            <p>買購物車中商品的人還買了</p>
        </div>
    <div>
<div>
<div></div>
<div>
<div style="margin-right: 12.7px;">
<img src="static/images/buy/手機(jī)1.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div style="margin-right: 12.7px;">
<span>享八折</span>
<img src="static/images/buy/手機(jī)2.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div style="margin-right: 12.7px;">
<img src="static/images/buy/手機(jī)3.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div>
<span>享八折</span>
<img src="static/images/buy/手機(jī)4.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div style="margin-right: 12.7px; margin-top:12.7px; ">
<img src="static/images/buy/手機(jī)1.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div style="margin-right: 12.7px; margin-top:12.7px;">
<img src="static/images/buy/手機(jī)1.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div style="margin-right: 12.7px; margin-top:12.7px;">
<img src="static/images/buy/手機(jī)1.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
<div style=" margin-top:12.7px;">
<img src="static/images/buy/手機(jī)1.jpg">
<h3><a href="">小米5X 4G+64GB</a></h3>
<p>光學(xué)變焦雙攝,拍人更美</p>
<p><span style="color: #ff6700;">1499 元</span></p>
</div>
</div>
</div>

   </div>
   <!--——————————————————————————————————————————————————————————————— 底部——————————————————————————————————————————————————————————————————————————— -->
 <div>
<div>
        <div>
            <div>
                <a href="#"><i class="fa fa-wrench"></i>預(yù)約維修服務(wù)</a><span></span>
                <a href="#"><i class="fa fa-rotate-right "></i>7天無理由退貨</a><span></span>
                <a href="#"><i class="fa fa-refresh"></i>15天免費(fèi)換貨</a><span></span>
                <a href="#"><i class="fa fa-gift"></i>滿150元包郵</a><span></span>
                <a href="#"><i class="fa fa-map-marker"></i>520余家售后網(wǎng)點(diǎn)</a>
            </div>
            <span></span>
            <div>
                <div>
                    <dl>
                        <dt>幫助中心</dt>
                        <dd><a href="">賬戶管理</a></dd>
                        <dd><a href="">購物指南</a></dd>
                        <dd><a href="">訂單操作</a></dd>
                    </dl>
                    <dl>
                        <dt>服務(wù)支持</dt>
                        <dd><a href="">售后政策</a></dd>
                        <dd><a href="">自助服務(wù)</a></dd>
                        <dd><a href="">相關(guān)下載</a></dd>
                    </dl>
                    <dl>
                        <dt>線下門店</dt>
                        <dd><a href="">小米之家</a></dd>
                        <dd><a href="">服務(wù)網(wǎng)點(diǎn)</a></dd>
                        <dd><a href="">授權(quán)體驗(yàn)店</a></dd>
                    </dl>
                    <dl>
                        <dt>關(guān)于小米</dt>
                        <dd><a href="">了解小米</a></dd>
                        <dd><a href="">加入小米</a></dd>
                        <dd><a href="">投資者關(guān)系</a></dd>
                    </dl>
                    <dl>
                        <dt>關(guān)注我們</dt>
                        <dd><a href="">新浪微博</a></dd>
                        <dd><a href="">官網(wǎng)微博</a></dd>
                        <dd><a href="">聯(lián)系我們</a></dd>
                    </dl>
                    <dl>
                        <dt>特色服務(wù)</dt>
                        <dd><a href="">F碼通道</a></dd>
                        <dd><a href="">禮物碼</a></dd>
                        <dd><a href="">防偽查詢</a></dd>
                    </dl>
                    <div>
                        <p>Feir-520-1314</p>
                        <p>周一至周日 8:00-18:00<br>(僅收市話費(fèi))</p>
                        <button><span class="fa fa-commenting "></span> 聯(lián)系客服</button>
                    </div>
                </div>
            </div>
             <div></div>
        </div>
        <div>
            <div style="margin-right: 15px;">
                <img src="static/images/footlogo.png" alt="">
            </div>
            <div  style="margin-right:50px;">
                <div>
                    <ul>
                        <li>小米商城<span></span></li>
                        <li>MIUI<span></span></li>
                        <li>米家<span></span></li>
                        <li>米聊<span></span></li>
                        <li>多看<span></span></li>
                        <li>游戲<span></span></li>
                        <li>路由器<span></span></li>
                        <li>米粉卡<span></span></li>
                        <li>政企服務(wù)<span></span></li>
                        <li>小米天貓店<span></span></li>
                        <li>隱私政策<span></span></li>
                        <li>問題反饋<span></span></li>
                        <li>Select Region</li>
                    </ul>
                </div>
                <div>
                    <a href="">?mi.com</a>
                    京ICP證110507號
                    <a href="">京ICP備10046444號</a>
                    <a href="">京公網(wǎng)安備11010802020134號</a>
                    <a href="">京網(wǎng)文[2014]0059-0009號</a>
                    <br>
                    違法和不良信息舉報(bào)電話:185-0130-1238,本網(wǎng)站所列數(shù)據(jù),除特殊說明,所有數(shù)據(jù)均出自我司實(shí)驗(yàn)室測試
                </div>
            </div>
            <div>
                <img src="static/images/footericon1.png" alt="" style="margin-right: 10px;">
                <img src="static/images/footericon2.png" alt="" style="margin-right: 10px;">
                <img src="static/images/footericon3.png" alt="" style="margin-right: 10px;">
                <img src="static/images/footericon4.png" alt="" style="margin-right: 10px;">
                <img src="static/images/footericon5.png" alt="">
            </div>
            <div>
               探索黑科技,小米為發(fā)燒而生!
            </div>   
        </div>  
    </div>
</div> 
</body>
</html>

css部分:

*{margin: 0px;padding: 0px;border: none;}
.clear{clear: both;}
li{list-style: none;}
a{text-decoration: none;color: #ccc;cursor:pointer;}
/*頭部, 軀干寬度設(shè)定*/
.header,.trunk{width: 100%}
/*頭部邊框, 高度設(shè)定*/
.header{height: 100px;border-bottom:  2px solid #ff6700;}
/*軀干背景顏色和溢出設(shè)定*/
.trunk{background-color:#f5f5f5;overflow: hidden;}
/*內(nèi)容總寬度, 居中設(shè)定*/
.header>.content,.trunk>.cart,.trunk>.recommend{width: 1226px;margin:0 auto;}.cart{padding-top: 38px;}

.header .content-left{float: left;}
.header .content-right{float: right;}
.header .logo,
.header .title,
.header .notice,
.header .userinfo,
.header .toOrderDetail{float: left;margin-top: 26px;}
.header .logo{width: 48px;height: 48px;margin-right:45px;background: url('../img/footlogo.png') center center;}
.header .title{font-size: 28px;line-height: 48px; margin-right: 15px;font-weight: 400;color:#424242;}
.header .notice{font-size:12px;line-height: 48px;margin-top: 32px;font-weight: 400;color: #757575;}
.header .userinfo{width: 120px;line-height: 48px;margin-top:28px;font-size: 12px;color:#757575;position: relative;}
.header .toOrderDetail{line-height: 48px;margin-top:28px;font-size:12px; color:#757575;}
.userinfo .username a,
.header .toOrderDetail a{color:#757575;}


.userinfo .username ul{position:absolute;width: 120px;padding:7px 0;display:none;background-color: #fff;margin-left: -10px;text-align: center;box-shadow:0 2px 10px rgba(0,0,0,0.15)}
.userinfo .username li{height: 30px;width: 100%;color:#757575;line-height: 30px;}
.userinfo :hover ul{display:block;}
.userinfo .username li:hover{color:#ff6700;background-color:#f5f5f5;}
.userinfo i{position:absolute;top:20px;right:20px;}

.userinfo :hover a,
.userinfo :hover i{color:#ff6700;}

.cart>.list{background-color: #fff;overflow: hidden;}
.list div{float: left;}
.cart .select{width: 110px;text-align: center;}
.cart .select i{font-size:13px;  display:inline-block;height: 15px;width:15px;line-height: 15px;background-color:#fff;color:rgba(0,0,0,0);border:1px solid #e0e0e0;margin:0 15px 0 24px;cursor: pointer;}
/*.cart .select i:hover{color:#757575}*/
.cart .select .checked{color:#fff;background-color: #ff6700;border:1px solid #ff6700;}
.cart .good-img{width: 120px;cursor: pointer;}
.cart .good-img img{width: 60px;height: 60px;margin-top: 15px;}
.cart .good-name{width: 380px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;cursor: pointer;font-size: 17px;color: #424242;}
.cart .good-price{width:75px;padding-right: 84px;text-align: right;}

.cart .good-num{width: 150px;text-align: center;}
.good-num .num-input{padding:0;margin-top:24px;width: 150px;height: 40px;border:1px solid #e0e0e0;padding-top: 1px;}
.num-input button{width: 38px;height:38px;text-align: center;line-height: 38px;color:#757575;background-color:#fff;font-size: 20px;}
.num-input button:hover{background-color: #e0e0e0}
.num-input .minus{float: left;}
.num-input .plus{float: right;}
.num-input .num-value{float: left; width: 72px;height: 38px;text-align: center;font-size: 16px;}

.cart .good-total-price{width: 120px;padding-right: 81px;text-align: right;color: #FF6A00;}
.cart .operation{width: 80px;padding-right: 26px;text-align: center;}
.cart .operation i{display:inline-block;width: 20px;height: 20px;border-radius: 10px;color:#757575;line-height: 20px;font-size: 12px; }
.cart .operation i:hover{background-color: #F07474;color:#fff;cursor: pointer;}

.list-title div{height: 70px;line-height: 70px;font-size: 14px;}
.list-item div{height: 86px;padding:15px 0;line-height: 86px;border-top:1px solid #e0e0e0;}
.list-total{margin: 20px 0px;height: 50px;line-height: 50px;font-size:14px;}
.list-total .list-total-left{float: left;}
.list-total .list-total-right{float: right;}
.list-total-left .notice{margin-left: 32px;font-size: 12px;background-color:#fff;color: #424242;}
.list-total-left .notice a{color: #424242;font-size: 14px;}
.list-total-left .statistics{margin-left: 16px;padding-left: 16px;font-size: 12px;border-left: 1px solid #eee;color: #424242;font-size: 14px;}
.statistics span{color:#FF6A00;}
.list-total-right .total-price{float: left;font-size: 14px;color: #ff6700}
.list-total-right .total-price .sum-price{font-size: 24px;}
.list-total-right .submit-cart{float: right;height:50px;width: 200px;background-color:#ff6700;color:#fff;font-size: 18px;margin-left: 60px;}

/*商品推薦*/
.recommend{position: relative;border-top:1px solid #ccc;height: 40px;}
.recommend p{font-size: 31px;color: #757575;background: #F5F5F5;width:460px;height: 40px;position: absolute;top: -20px; left:380px;text-align: center;}

.content-bottom{background:#F5F5F5;padding-bottom:60px; }
.content-bottom1{width: 1226px; margin:0px auto;  }
.content-bottom1_shop{height: 614px;width: 1226px;margin-top: 10px;}
.content-bottom1_shop1{height: 614px;width:234px;background: url(../img/buy/手機(jī)AD.jpg);margin-right:10px;float:left;}
.content-bottom1_shop2{height: 614px;width:982px;float:left;}
.content-bottom1_1 div{height:300px;width: 235px;}
.content-bottom1_a{margin-right:12.7px;background:#ccc;float: left;}
.content-bottom1_b{margin-right:12.7px;background:#ccc;float: left;}
.content-bottom1_c{margin-right:12.7px;background:#ccc;float: left;}
.content-bottom1_d{background:#ccc;float: left;}
.content-bottom1_2 div{height:300px;width: 235px;margin-top: 14px;}
.content-bottom1_e{margin-right:12.7px;background:#ccc;float: left;}
.content-bottom1_f{margin-right:12.7px;background:#ccc;float: left;}
.content-bottom1_g					

批改老師:韋小寶批改時(shí)間:2019-03-11 17:09:24
老師總結(jié):寫的非常棒 總結(jié)的也很到位 購物車稍微還是有難的 其實(shí)只要一開始邏輯清楚了 寫起來就方便了

發(fā)布手記

熱門詞條