美文网首页
购物车结算 删除 加1效果

购物车结算 删除 加1效果

作者: DistanceMJ | 来源:发表于2018-06-27 10:28 被阅读0次

<!Doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>购物车</title>
    <link type="text/css" rel="stylesheet" href="css/module.css"/>
</head>
<body>
    <div class="shopping">
        <div class="shop-group-item">
            <ul>
                <li class="bb">
                    <div class="shop-info mm">
                        <input type="checkbox" class="check goods-check goodsCheck">
                        <div class="shop-info-img">
                            <a href="#"><img src="images/03.jpg" /></a>
                        </div>
                        <div class="shop-info-text">
                            <h4>女子Plush Terry连帽运动T恤</h4>
                            <div class="shop-brief"><span>颜色:灰色 ;尺码:L </span><img src="images/icon.jpg" alt="" class="img1" /></div>
                            <div class="shop-price">
                                <div class="shop-pices">¥<b class="price">699.00</b></div>
                                <div class="shop-arithmetic">
                                    <a href="javascript:;" class="reduce">-</a>
                                    <span class="num">1</span>
                                    <a href="javascript:;" class="add">+</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="bb">
                    <div class="shop-info mm">
                        <input type="checkbox" class="check goods-check goodsCheck">
                        <div class="shop-info-img">
                            <a href="#"><img src="images/06.jpg" /></a>
                        </div>
                        <div class="shop-info-text">
                            <h4>Storm Roll Trance背包-1261953</h4>
                            <div class="shop-brief"><span>均码</span><img src="images/icon.jpg" alt="" class="img1" /></div>
                            <div class="shop-price">
                                <div class="shop-pices">¥<b class="price">499.00</b></div>
                                <div class="shop-arithmetic">
                                    <a href="javascript:;" class="reduce">-</a>
                                    <span class="num">1</span>
                                    <a href="javascript:;" class="add">+</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="bb">
                    <div class="shop-info mm">
                        <input type="checkbox" class="check goods-check goodsCheck">
                        <div class="shop-info-img">
                            <a href="#"><img src="images/08.jpg" /></a>
                        </div>
                        <div class="shop-info-text">
                            <h4>Renegade Twist运动帽</h4>
                            <div class="shop-brief"><span>均码</span><img src="images/icon.jpg" alt="" class="img1" /></div>
                            <div class="shop-price">
                                <div class="shop-pices">¥<b class="price">219.00</b></div>
                                <div class="shop-arithmetic">
                                    <a href="javascript:;" class="reduce">-</a>
                                    <span class="num">1</span>
                                    <a href="javascript:;" class="add">+</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="bb">
                    <div class="shop-info mm">
                        <input type="checkbox" class="check goods-check goodsCheck">
                        <div class="shop-info-img">
                            <a href="#"><img src="images/03.jpg" /></a>
                        </div>
                        <div class="shop-info-text">
                            <h4>女子Plush Terry连帽运动T恤</h4>
                            <div class="shop-brief"><span>颜色:灰色 ;尺码:L </span><img src="images/icon.jpg" alt="" class="img1" /></div>
                            <div class="shop-price">
                                <div class="shop-pices">¥<b class="price">699.00</b></div>
                                <div class="shop-arithmetic">
                                    <a href="javascript:;" class="reduce">-</a>
                                    <span class="num">1</span>
                                    <a href="javascript:;" class="add">+</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="bb">
                    <div class="shop-info">
                        <input type="checkbox" class="check goods-check goodsCheck">
                        <div class="shop-info-img">
                            <a href="#"><img src="images/06.jpg" /></a>
                        </div>
                        <div class="shop-info-text">
                            <h4>Storm Roll Trance背包-1261953</h4>
                            <div class="shop-brief"><span>均码</span><img src="images/icon.jpg" alt="" class="img1" /></div>
                            <div class="shop-price">
                                <div class="shop-pices">¥<b class="price">499.00</b></div>
                                <div class="shop-arithmetic">
                                    <a href="javascript:;" class="reduce">-</a>
                                    <span class="num">1</span>
                                    <a href="javascript:;" class="add">+</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <div class="pay">
        <div class="all-checkbox" style="color:#777;"><input type="checkbox" class="check goods-check" id="AllCheck">全选</div>
        <a href="#" class="settlement">结算:<span class="total" id="AllTotal">¥0.00</span></a>
    </div>
</body>
    <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript">
                $(function(){

// 数量加
$(".add").click(function() {
var t = $(this).parent().find('.num');
t.text(parseInt(t.text()) + 1);
if (t.text() <= 1) {
t.text(1);
}
TotalPrice();
});

// 数量减
$(".reduce").click(function() {
var t = $(this).parent().find('.num');
t.text(parseInt(t.text()) - 1);
if (t.text() <= 1) {
t.text(1);
}
TotalPrice();
});

// 删除
$('.img1').click(function(){
$(this).parent().parent().parent().remove();
TotalPrice();
})

//最左边按钮
$(".goodsCheck").click(function() {
var goods = $(this).closest(".shop-group-item").find(".goodsCheck");
var goodsC = $(this).closest(".shop-group-item").find(".goodsCheck:checked");
var Shops = $(this).closest(".shop-group-item").find(".shopCheck");
if (goods.length == goodsC.length) {
Shops.prop('checked', true);
if ($(".shopCheck").length == $(".shopCheck:checked").length) {
$("#AllCheck").prop('checked', true);
TotalPrice();
} else {
$("#AllCheck").prop('checked', false);
TotalPrice();
}
} else {
Shops.prop('checked', false);
$("#AllCheck").prop('checked', false);
TotalPrice();
}
});

// 点击全选按钮
$("#AllCheck").click(function() {
if ($(this).prop("checked") == true) {
$(".goods-check").prop('checked', true);
TotalPrice();
} else {
$(".goods-check").prop('checked', false);
TotalPrice();
}
});

//计算
function TotalPrice() {
var allprice = 0;
$(".shop-group-item").each(function() {
var oprice = 0;
$(this).find(".goodsCheck").each(function() {
if ($(this).is(":checked")) {
var num = parseInt($(this).parents(".shop-info").find(".num").text());
var price = parseFloat($(this).parents(".shop-info").find(".price").text());
var total = price * num;
oprice += total;
}
$("#AllTotal").text(oprice.toFixed(2));
});
});
if($('.img1').length==0){
$("#AllTotal").text(0.00);
}
}
});
</script>
</html>

相关文章

  • 购物车结算 删除 加1效果

    // 数量加$(".add").click(function() {var t =...

  • 购物车结算

    购物车结算普通写法 购物车结算抽离函数写法

  • reactNative 之navigator.pop 数据无刷新

    问题场景如下: 【购物车结算页】点击“结算”跳转到【订单确认页】,这时候操作物理返回,发现【购物车结算页】购物车的...

  • 手机淘宝购物车加支付原型图

    购物车页面原型图 说明: 1.购物车(x) x为购物车中商品种类数量(非总商品数量,同理结算(0) 0为结算时商品...

  • 后端存储3

    购物车系统的主要功能包括:加购、购物车列表页和结算下单。 购物车系统需要保存两类购物车,一类是未登录情况下的“暂存...

  • Android 购物车实现(NEW)

    没错就是购物车 放图镇楼 大体效果应该就是这样 购物车涉及到的功能 全选 ,反选,总金额,数量加减,结算金额等 差...

  • vue.js 练习

    1.购物车加减效果 html部分 js部分 2.添加删除效果 html部分 js部分 3.选项卡 html部分 js部分

  • 购物车可选择商品支付,功能设计

    老系统中购物车内所有商品只能全部结算,现在需要购物车内商品可选择结算,需求如下 需求描述 增加选择结算功能 点击提...

  • 竞品分析:购物车设计

    一、横向分析 常规的购物车功能:价格提醒、活动促销、凑单、商品收藏与删除、失效商品管理、合并结算。平台不同的定位,...

  • 【Axure交互教程】购物车结算效果

    作品名称:滑动拼图验证登录效果 作品编号:Case010 软件版本:Axure9 作品类型:交互案例 今天我们制作...

网友评论

      本文标题:购物车结算 删除 加1效果

      本文链接:https://www.haomeiwen.com/subject/zmqbyftx.html