zoukankan      html  css  js  c++  java
  • 购物车相关Js代码

    //购物车  让总计放生变化
    $('.check').click(function(){
        totals();
    
    })
    
    function totals(){
            var total = 0;
            $('input[type=chechbok]:checked').each(function(){
    
    //小计加
            total += parseInt($(this).parents('tr').find('.amount').text());
            })
            $('#total').text(total
    //全选
        $('.qx').click(function(){
            $('.check').each(function(){
                this.checked = true;
            })
    
            totals();
    
            //阻止默认行为
            return false;
        })
    
    
    
        //
        $('.plus').click(function(){
            var pv = $(this).prev().val();
            pv++;
            //

          $(this).prev().val(pv);

            var pri = $(this).parents('tr').find('.price').text();
            $(this).parents('tr').find('.amant').text(pri*pv);
    
        })
        //
        $('.minus').click(function(){
            var pv = $(this).prev().val();
            pv--;
            if( pv <= 1){
                pv = 1;
            }
            //
        

          $(this).nextAll().val(pv);

            var pri = $(this).parents('tr').find('.price').text();
            $(this).parents('tr').find('.amant').text(pri*pv);
    
        })
    
    
        //删除
        $('.remove').click(function(){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            //
            var id = $(this).parent().parent().parent('div').find('.check').attr('gid');
            var trs = $(this).parent().parent().parent('div');
    
            $.post('/home/shop',{id:id},function(data){
            // alert(id);
            console.log(data);
    
                if(data == 1){
                    // console.log('123');
                    trs.remove();
                    // totals();
                }
            })
        })

    控制器相关代码

        public function store(Request $request )
        {
            //
            $id = $request->input('id');
            $res = Session::get('cartt');
    // var_dump($res);
    
            foreach($res as $k => $v){
    
                if($v['id']==$id){
    
                    Session::forget('cartt');
                    return '1';
                }
            }
            return '0';
        }
  • 相关阅读:
    python注释方法以及编码问题
    python数据类型和变量
    JavaScript必须了解的知识点总结。
    javaScript语法总结
    美图WEB开放平台环境配置
    变点问题的统计推新及其在全融中的应用 谭常春
    Structural breaks in time series
    多种单位根检验法的比较研究 房林邹卫星
    1-出口数据的平稳性分析
    时间序列中的结构突变与单位根检验
  • 原文地址:https://www.cnblogs.com/xujing6/p/6525121.html
Copyright © 2011-2022 走看看