jQuery(function($){
    $('.computing_act input').click(function(){
        click_change_goodsnum($(this));
    });
    $('.computing_num input').blur(function(){
        click_change_goodsnum($(this).parent().siblings('.computing_act').find('input'));
    });
    $("#check_box").prop("checked", true);
    check_select('cart_id[]');
    compute_price();
});
//计算总价
function compute_price(){
    var all_goods_price = totalnum = 0;
    $("div.goods_box").each(function(){
        var shop_all_price = 0;
        if($(this).find('.product_list .product-main .activity_new').length>0) {
            $(this).find('.product_list .product-main .activity_new').each(function () {
                var promot_id = parseInt($(this).attr('rel'));
                var cart_id = parseInt($(this).siblings('div').find('input').first().attr('cart_id'));
                var this_promot_goods_price = 0;
                if (promot_id > 0) {
                    var this_promot_goods_num = true;
                    $(this).parent().find('.product_content[promotrel="' + promot_id + '"]').each(function () {
                        if ($(this).parent().is(':visible') && $(this).parent().find("input[type='checkbox'].goods_check").is(':checked')) {
                            //商品单价
                            var goods_unit_price = parseFloat($(this).find(".computing_num input[type='text']").attr('uni'));
                            //商品数量
                            var goods_num = parseInt($(this).find(".computing_num input[type='text']").val());
                             cart_id = parseInt($(this).find(".computing_num input[type='text']").attr("cart_id"));

                            totalnum+=parseInt(goods_num);
                            //商品总价
                            this_promot_goods_price += goods_unit_price * goods_num;
                            this_promot_goods_num = false;
                        }
                    });
                    var this_promot_parent = $(this);
                    click_change_price(this_promot_parent, promot_id, this_promot_goods_price,cart_id);
                }
                var cur_price = $(this).attr('cur');
                var ori_price = $(this).attr('ori');
                cur_price = (parseFloat(cur_price) > 0) ? parseFloat(cur_price) : parseFloat(this_promot_goods_price);
                shop_all_price += parseFloat(cur_price);
                all_goods_price += parseFloat(cur_price);
            });
        }

        if($(this).find('.product_content[promotlimitrel="1"]').length>0){
            var this_promot_goods_price = 0;
            $(this).find('.product_content[promotlimitrel="1"]').each(function () {
                if ($(this).parent().is(':visible') && $(this).parent().find("input[type='checkbox'].goods_check").is(':checked')) {
                    //商品单价
                    var goods_unit_price = parseFloat($(this).find(".computing_num input[type='text']").attr('uni'));
                    //商品数量
                    var goods_num = parseInt($(this).find(".computing_num input[type='text']").val());
                    totalnum+=parseInt(goods_num);
                    //商品总价
                    this_promot_goods_price += goods_unit_price * goods_num;
                }
            });
            var cur_price = parseFloat(this_promot_goods_price);
            shop_all_price += parseFloat(cur_price);
            all_goods_price += parseFloat(cur_price);
        }
        if($(this).find('.product_content[promotrel="0"]').length>0){
            var this_promot_goods_price = 0;
            $(this).find('.product_content[promotrel="0"]').each(function () {
                if ($(this).parent().is(':visible') && $(this).parent().find("input[type='checkbox'].goods_check").is(':checked')) {
                    //商品单价
                    var goods_unit_price = parseFloat($(this).find(".computing_num input[type='text']").attr('uni'));
                    //商品数量
                    var goods_num = parseInt($(this).find(".computing_num input[type='text']").val());
                    totalnum+=parseInt(goods_num);
                    //商品总价
                    this_promot_goods_price += goods_unit_price * goods_num;
                }
            });
            var cur_price = parseFloat(this_promot_goods_price);
            shop_all_price += parseFloat(cur_price);
            all_goods_price += parseFloat(cur_price);
        }
    });
    $('.btn_checkout').html(' 结算('+totalnum+') ');
    $('#totalPrice .price').html('¥'+foramtmoney(all_goods_price));
    /*******************************/
    /****如果购物车里没东西了就刷新页面***/
    var is_visible=0;
    $('.product_content').each(function(){
        if($(this).parent().is(':visible')){
            is_visible=1;
        }
    });
    if(is_visible==0){window.location.reload();}
    /*******************************/
}
//改变活动，刷新页面
function change_act(cart_id,act_id){
    var querydata = new Object;
    querydata['cart_id']=cart_id;
    querydata['act_id']=act_id;
    $.ajax({
        url: APP + "Mobile/Cart/change_act",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
//                alert(JSON.stringify(ret));
            if(ret.status==1){
                window.location.reload();
            }else $.showErr('更换活动失败',0,'hc');
        }
    });
};
//购物数量加减
function click_change_goodsnum(obj){
    var goodsnum = parseInt($(obj).parent().siblings('.computing_num').find('input').val());
    var goodsstock = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('sto'));
    var goodsinu = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('inu'));
    var goodsanu = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('anu'));
    var goodsmoq = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('moq'));
    var cart_id = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('cart_id'));
    var goods_id = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('goods_id'));
    var shop_id = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('shop_id'));
    var is_add=0;
    if(goodsnum>0){
        if($(obj).val()=='+'){
            goodsnum = goodsnum+1;
            is_add=1;
        }else if($(obj).val()=='-'){
            if(!isNaN(goodsmoq) && goodsmoq>=goodsnum){
                $.showErr('购买数量不能小于商品起订量',0,'hc');return false;
            }
            if(goodsnum>1){
                goodsnum = goodsnum-1;
            }else{
                click_del_goods(obj);
            }
            is_add=0;
        }
        if((goodsnum>goodsstock)) goodsnum = goodsstock;
        if((goodsanu>0)) {
            if((goodsnum>goodsanu)) goodsnum = goodsanu;
        }
        if((goodsinu>0)) {
            if((goodsnum<goodsinu)) goodsnum = goodsinu;
        }
    }else{
        goodsnum = 1;
    }
    var query = new Object;
    query.cart_id=cart_id;
    query.goods_id=goods_id;
    query.shop_id=shop_id;
    query.is_add=is_add;
    query.num=goodsnum;
    query.is_cart=1;
    $.ajax({
        url:APP + "Mobile/Cart/add_cart",
        data:query,
        type:"post",
        success:function(data){
			eid = data.eid;
            if(data.status==0) {
                if(data.url) {
                    $.showErr(data.info, 0, 'hc', function () {
                        window.location.href = data.url;
                    });
                }else{
                    $.showErr(data.info, 0, 'hc');
                }
            } else {
                //window.location.reload();
                $(obj).parent().siblings('.computing_num').find('input').val(goodsnum);
                click_change_promot(obj,$(obj).parents('.goods_box'),1);
            }
        }
    })

}
//活动改变

function click_change_promot(obj,parents,type){
    //更换商品数量价格
    if(type==1){click_change_num_price(obj)};
    //循环计算活动与商品之间的价格
    $(parents).find('.activity_new').each(function(){
        var promot_id = parseInt($(this).attr('rel'));
        var cart_id = parseInt($(obj).parent().siblings('.computing_num').find('input').attr('cart_id'));
        if(promot_id>0){
            var this_promot_goods_price = 0;
            var this_promot_goods_num = true;
            $(parents).find('.product_content[promotrel="'+promot_id+'"]').each(function(){
                if($(this).parent().is(':visible')){
                    //商品单价
                    var goods_unit_price = parseFloat($(this).find(".computing_num input[type='text']").attr('uni'));

                    //商品数量
                    var goods_num = parseInt($(this).find(".computing_num input[type='text']").val());
                    cart_id = parseInt($(this).find(".computing_num input[type='text']").attr("cart_id"));
                    //商品总价
                    this_promot_goods_price+=goods_unit_price*goods_num;
                    this_promot_goods_num = false;
                }

            });
            //若当前活动下无商品   remove
            if(this_promot_goods_num){$(this).parents('.product-main').remove();}
            var this_promot_parent = $(parents).find('.activity_new[rel="'+promot_id+'"]');
            click_change_price(this_promot_parent,promot_id,this_promot_goods_price,cart_id);
        }
    });
    //end
    compute_price();
}
//计算数量价格
function click_change_num_price(obj){
    //数量
    var goodsnum = parseInt($(obj).parent().siblings('.computing_num').find('input').val());
    //单价
    var goodsprice = $(obj).parent().siblings('.computing_num').find('input').attr('uni');
    //单重
    var goods_weight = $(obj).parent().siblings('.computing_num').find('input').attr('uwe');
    //总重
    //$(obj).parent().parent().find('.buy-weight span').html(foramtmoney(goodsnum*goods_weight));
    //合计
    $(obj).parent().parent().parent().parent().find('a .sale_price').html('¥'+foramtmoney(goodsnum*goodsprice));
}
//计算活动价格
function click_change_price(parents,promot_id,prices,cart_id){
    prices = parseFloat(prices);
    var demo_prices = orig_prices =  prices;//alert(promot_id);//alert(promot_lists_json[promot_id]);
    if(promot_lists_json==null)return true;
    if(!promot_lists_json[promot_id] )return true;
    var act_name = promot_lists_json[promot_id]['act_name'];
    var min_amount = parseFloat(promot_lists_json[promot_id]['min_amount']);//金额下限
    var max_amount = parseFloat(promot_lists_json[promot_id]['max_amount']);//金额上限
    var act_type = promot_lists_json[promot_id]['act_type'];//类型:1满减2满折
    var act_type_ext = parseFloat(promot_lists_json[promot_id]['act_type_ext']);//优惠值
    var is_addup = promot_lists_json[promot_id]['is_addup'];//当活动为限时促销时 是否叠加
    var gift_id=$("#promot_gift_id_"+promot_id).val();
    //满足活动最低价
    if(prices>=min_amount){
        if(act_type==1){
            if(is_addup==1){
                if(max_amount&&prices>=max_amount){demo_prices = max_amount;}
                if(min_amount>0) prices = prices - (Math.floor(demo_prices/min_amount)*act_type_ext);
            }else{
                prices = prices - act_type_ext;
            }
            $("#promot_lite"+promot_id).addClass("hide");
        }else if(act_type==2){
            prices = prices*(act_type_ext/100);
            $("#promot_lite"+promot_id).addClass("hide");
        }else if(act_type==3){
            //$("#promot_"+promot_id).removeClass('hide');
            if(gift_id){
                var html='<a href="'+APP + 'Mobile/PromotAct/cont/id/'+promot_id+'/cart_id/'+cart_id+'/eid/'+eid+'" class="f_r" id="promot_'+promot_id+'">再逛逛&gt;</a>';
            }else {
                var html = '<a href="' + APP + 'Mobile/PromotAct/cont/id/' + promot_id + '/cart_id/' + cart_id + '/eid/' + eid + '" class="f_r" id="promot_' + promot_id + '">选赠品&gt;</a>';
            }
            $('#promot_html'+promot_id).html(html);
        }else if(act_type==4){
            var gift_id=parseInt($("#gift_pro_"+promot_id).val());
            if(gift_id>0){
                prices=prices+act_type_ext;
            }else{
                prices=prices;
            }
            if(gift_id){
                var html='<a href="'+APP + 'Mobile/PromotAct/cont/id/'+promot_id+'/cart_id/'+cart_id+'" class="f_r" id="promot_'+promot_id+'">再逛逛&gt;</a>';
            }else {
                var html = '<a href="' + APP + 'Mobile/PromotAct/cont/id/' + promot_id + '/cart_id/' + cart_id + '/eid/' + eid + '" class="f_r" id="promot_' + promot_id + '">去换购&gt;</a>';
            }
            $('#promot_html'+promot_id).html(html);
            $("#promot_lite"+promot_id).addClass("hide");
            is_gift(cart_id,promot_id);
        }
        //$(parents).find('.koujian').html('已优惠：'+foramtmoney(orig_prices-prices));
        //$(parents).find('.view-detail-btn').hide();
    }else{
        if(act_type==4){
            var less_money=foramtmoney(min_amount-prices,2);
            var html='<a href="'+APP + 'Mobile/PromotAct/cont/id/'+promot_id+'/cart_id/'+cart_id+'/eid/'+eid+'" class="f_r" id="promot_lite'+promot_id+'">还差'+less_money+'，去凑单&gt;</a>';
            $('#promot_html'+promot_id).html(html);
            $("#promot_"+promot_id).addClass("hide");
            $("#pro_add_"+promot_id).addClass("hide");
            $("#gift_temp_"+promot_id).addClass('hide');
            del_pro_goods(promot_id,cart_id);
        }else if(act_type==3){
            $('#pro_add_'+promot_id).addClass("hide");
            $("#gift_temp_"+promot_id).addClass('hide');
            var less_money=foramtmoney(min_amount-prices,2);
            var html='<a href="'+APP + 'Mobile/PromotAct/cont/id/'+promot_id+'/cart_id/'+cart_id+'/eid/'+eid+'" class="f_r" id="promot_lite'+promot_id+'">还差'+less_money+'，去凑单&gt;</a>';
            $('#promot_html'+promot_id).html(html);
            del_pro_goods(promot_id,cart_id);
        }else if(act_type==2){
            $('#pro_add_'+promot_id).addClass("hide");
            var less_money=foramtmoney(min_amount-prices,2);
            var html='<a href="'+APP + 'Mobile/PromotAct/cont/id/'+promot_id+'/cart_id/'+cart_id+'/eid/'+eid+'" class="f_r" id="promot_lite'+promot_id+'">还差'+less_money+'，去凑单&gt;</a>';
            $('#promot_html'+promot_id).html(html);
            del_pro_goods(promot_id,cart_id);
        }else if(act_type==1){
            $('#pro_add_'+promot_id).addClass("hide");
            var less_money=foramtmoney(min_amount-prices,2);
            var html='<a href="'+APP + 'Mobile/PromotAct/cont/id/'+promot_id+'/cart_id/'+cart_id+'/eid/'+eid+'" class="f_r" id="promot_lite'+promot_id+'">还差'+less_money+'，去凑单&gt;</a>';
            $('#promot_html'+promot_id).html(html);
            del_pro_goods(promot_id,cart_id);
        }
        //$(parents).find('.koujian').hide();
    }

    prices = foramtmoney(prices);
    orig_prices = foramtmoney(orig_prices);
    $(parents).attr('cur',prices);
    $(parents).attr('ori',orig_prices);
    //$(parents).find('.buy-price-count strong').html(prices);
    //$(parents).find('.buy-price-count del').html(orig_prices);
    //if(act_name){$(parents).find('.inblock').html(act_name);}
}
//删除商品
function click_del_goods(obj){
    $.showConfirm('确认删除？',function(){
        del_goods(obj);
    },1,'hc');
}
//删除订货商品
function click_del_purgoods(obj){
    $.showConfirm('确认删除？',function(){
        del_purgoods(obj);
    },1,'hc');
}
function clear_out_cart(){
    $.showConfirm('确认删除？',function(){
        var querydata = new Object;
        $.ajax({
            url: APP + "Mobile/Cart/clear_cart",
            type: "post",
            data: querydata,
            dataType: "json",
            success: function (ret) {
                if(ret.status==1){
                    $.showSuccess('删除成功',0,'hc');
                    window.location.reload();
                }else $.showErr('删除失败',0,'hc');
            }
        });
    },1,'hc');
}
function del_goods(obj){
    //Ajax 删除商品
    var querydata = new Object;
    querydata['id'] = new Object;
    if(obj){
        var cart_id=$(obj).parents('.product_list_wrap').find("input[name='del_id']").val();
        querydata['id'][cart_id]=cart_id;
    }else {
        $('input[name="cart_id[]"]:checked').each(function () {
            var cart_id = $(this).val();
            //del_goods('#del_cart' + cart_id);
            querydata['id'][cart_id]=cart_id;
        });
    }
    $.ajax({
        url: APP + "Mobile/Cart/del_cart",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
            if(ret.status==1){
                if(obj){
                    $(obj).parents('.product_list_wrap').hide();
                    window.location.reload();
                    //活动变动
                    click_change_promot(obj,$(obj).parents('.goods_box'),0);
                }else {
                    $('input[name="cart_id[]"]:checked').each(function () {
                        var cart_id = $(this).val();
                        var cart=$('#del_cart' + cart_id);
                        $(cart).parents('.product_list_wrap').hide();
                        window.location.reload();
                        //活动变动
                        click_change_promot(cart,$(cart).parents('.goods_box'),0);
                    });
                }
            }else $.showErr('删除失败',0,'hc');
        }
    });
    //End
}
function del_purgoods(obj){
    //Ajax 删除商品
    var querydata = new Object;
    querydata['id'] = new Object;
    if(obj){
        var cart_id=$(obj).parents('.product_list_wrap').find("input[name='del_id']").val();
        querydata['id'][cart_id]=cart_id;
    }else {
        $('input[name="cart_id[]"]:checked').each(function () {
            var cart_id = $(this).val();
            //del_goods('#del_cart' + cart_id);
            querydata['id'][cart_id]=cart_id;
        });
    }
    $.ajax({
        url: APP + "Mobile/PurCart/del_cart",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
            if(ret.status==1){
                if(obj){
                    $(obj).parents('.product_list_wrap').hide();
                    //活动变动
                    click_change_promot(obj,$(obj).parents('.goods_box'),0);
                }else {
                    $('input[name="cart_id[]"]:checked').each(function () {
                        var cart_id = $(this).val();
                        var cart=$('#del_cart' + cart_id);
                        $(cart).parents('.product_list_wrap').hide();
                        //活动变动
                        click_change_promot(cart,$(cart).parents('.goods_box'),0);
                    });
                }
            }else $.showErr('删除失败',0,'hc');
        }
    });
    //End
}
/**
 * 批量删除
 */
function all_del(){
    $.showConfirm('确认删除？',function(){
        del_goods('');
    },1,'hc');
}
/**
 * 领取优惠券
 * @param id
 */
function get_ecv(id){
    var query=new Object();
    query.id=id;
    $.ajax({
        url:APP + "Mobile/Goods/get_ecv",
        data:query,
        type:"post",
        success:function(data){
            if(data.status==1) {
                $.showSuccess(data.info,0,'hc');
                $(".ticket_"+id).find("p.jian-text").after('<p class="chenggong">已领取</p>');
                $(".ticket_"+id).removeAttr('onclick');
            }else{
                $.showErr(data.info,0,'hc');
            }
        }
    })
}
/**
 * 选择全部
 */
function check_select(name,shop_id,cart_id) {
    shop_id = parseInt(shop_id);
    cart_id = parseInt(cart_id);
    if(shop_id>=0){
        if(cart_id>0){
            //判断是否店铺下商品都选中了
            var is_goods_all=true;
            $("input[name='" + name + "'][shop_id='" + shop_id + "'].goods_check").each(function() {
                if ($(this).prop("checked") == false) is_goods_all=false;
            });
            if(is_goods_all==true) $("#check_box_shop_id_"+shop_id).prop("checked",true);
            else $("#check_box_shop_id_"+shop_id).prop("checked",false);
            /**************************************/
            /*这段和!cart_id>0的代码相似，但不可以合一起*/
            if ($("#check_box_shop_id_" + shop_id).prop("checked") == false) {
                $("#check_box").prop("checked", false);
            } else {
                //判断是否店铺都选中了
                var is_all = true;
                $("input[name='" + name + "'].shop_check").each(function () {
                    if ($(this).prop("checked") == false) is_all = false;
                });
                if (is_all == true) $("#check_box").prop("checked", true);
                else $("#check_box").prop("checked", false);
            }
            /**************************************/
        }else {
            if ($("#check_box_shop_id_" + shop_id).prop("checked") == false) {
                $("input[name='" + name + "'][shop_id='" + shop_id + "']").each(function () {
                    this.checked = false;
                });
                $("#check_box").prop("checked", false);
            } else {
                $("input[name='" + name + "'][shop_id='" + shop_id + "']").each(function () {
                    this.checked = true;
                });
                //判断是否店铺都选中了
                var is_all = true;
                $("input[name='" + name + "'].shop_check").each(function () {
                    if ($(this).prop("checked") == false) is_all = false;
                });
                if (is_all == true) $("#check_box").prop("checked", true);
                else $("#check_box").prop("checked", false);
            }
        }
    }else{
        if ($("#check_box").prop("checked") == false) {
            $("input[name='" + name + "']").each(function() {
                this.checked = false;
            });
        } else {
            $("input[name='" + name + "']").each(function() {
                this.checked = true;
            });
        }
    }
    compute_price();
}

//提交购物车
function sub_cart(){
    var querydata = new Object;
    querydata['id'] = new Array();
    querydata['number'] = new Array();
    $("input[name='cart_id[]'].goods_check").each(function() {
        if ($(this).prop("checked") == true){
            querydata['id'].push($(this).val());
            querydata['number'].push($(this).parent().find("div.computing_num input[type='text']").val());
        }
    });
    $.ajax({
        url: APP + "Mobile/Cart/sub_cart",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
            if(ret.status==1){
                window.location.href=ret.url
            }else if(ret.status==2){
                // $.showErr(ret.msg,0,'hc');
                showtoast(ret.msg);
                window.location.href=ret.url
            }else{
                showtoast(ret.msg);
                var body = $('body').css("position");
                if(body=='relative'){
                    $('body').css("position","");
                }
                if(ret.msg=='请完善信息' || ret.msg=='请先晋升等级在购买'){
                    window.location.href=ret.url;
                }
            }
        }
    });
}
//提交订货购物车
function sub_pcart(){
    var querydata = new Object;
    querydata['id'] = new Array();
    querydata['number'] = new Array();
    $("input[name='cart_id[]'].goods_check").each(function() {
        if ($(this).prop("checked") == true){
            querydata['id'].push($(this).val());
            querydata['number'].push($(this).parent().find("div.computing_num input[type='text']").val());
        }
    });
    $.ajax({
        url: APP + "Mobile/PurCart/sub_cart",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
            if(ret.status==1){
                window.location.href=ret.url
            }else if(ret.status==2){
                $.showErr(ret.msg,0,'hc');
                window.location.href=ret.url
            }
            else $.showErr(ret.msg,0,'hc');
        }
    });
}

function del_pro_goods(promot_id,cart_ids){
    var querydata = new Object;
    querydata['cart_ids'] = cart_ids;
    querydata['pro_id'] = promot_id;
    $.ajax({
        url: APP + "Mobile/Cart/add_pro_goods",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
            if(ret.status==1){
                if(ret.data.goods_info){
                    $("#pro_add_"+ret.data.pro_id).removeClass('hide');
                    $("#gift_temp_"+ret.data.pro_id).removeClass('hide');
                    $("#gift_pro_"+ret.data.pro_id).val(1);
                    var html=' <div class="product_box"> ';
                    html+="<div class='product_pic' data-tpa='GOTO_PRODUCT_DETAIL'> <img src="+ret.data.goods_info.img+"> </div>";
                    html+="<div class='product_con'>";
                    html+="<span class='product_title'>"+ret.data.goods_info.goods_name+"</span>";
                    if(ret.data.goods_info.goods_attr_format) {
                        html += "<p class='product_from'>" + ret.data.goods_info.goods_attr_format + "</p>";
                    }
                    html+="<p class='cell_price'>";
                    html+="<span class='sale_price'> "+ret.data.goods_info.all_price+"</span></p></div><div class='product_option'>";
                    html+="</div> </div>";
                    $("#pro_add_"+ret.data.pro_id).html(html);
                    compute_price();
                }else{
                    $("#gift_pro_"+ret.data.pro_id).val(0);
                    $("#pro_add_"+ret.data.pro_id).addClass('hide');
                    $("#gift_temp_"+ret.data.pro_id).addClass('hide');
                }
            }
        }
    });
}
function is_gift(cart_id,pro_id){
    var querydata = new Object;
    querydata['cart_ids'] = cart_id;
    querydata['pro_id'] = pro_id;
    $.ajax({
        url: APP + "Mobile/Cart/is_gift",
        type: "post",
        data: querydata,
        dataType: "json",
        success: function (ret) {
            if(ret.status==1){
                if(ret.gift){
                    $('#pro_add_'+pro_id).removeClass("hide");
                    $("#gift_temp_"+pro_id).removeClass('hide');
                }else{
                    $("#pro_add_"+pro_id).addClass('hide');
                    $("#gift_temp_"+pro_id).addClass('hide');
                }
            }
        }
    });
}