jQuery(function($){
    var id=$('#goods_id').val();
    var type=$('#type').val();
    ajax_is_collect(id,type);
});
function add_favorite(id,type,is_on){
	var query = new Object;
	query.id=id;
	query.type=type;
	query.is_on=is_on;
	$.ajax({
		type:"get",
		url:APP+"Mobile/Goods/favorite",
		data:query,
		success:function(data){
			if(data.status==0) {
				window.location.href=APP+"Mobile/Login/index";
			}else if(data.status == 2){
				$("#words").text('加入收藏');
				if(!data.is_on){
					$("#collect").html("&#xe64c;");
					$("#collect").removeClass("class_sc");
				}
				// $.showSuccess(data.msg,1,'hc');
			}else if(data.status == 3){
				$.showErr(data.msg,0,'hc');
			}else{
				$("#words").text('已收藏');
				if(data.is_on==1){
					$("#collect").html("&#x3432;");
					$("#collect").addClass("class_sc");
				}
				// $.showSuccess(data.msg,1,'hc');
			}
		}
	}); 
}
//是否有收藏
function ajax_is_collect(id,type){
    var query=new Object();
    query.goods_id=id;
    query.type=type;
    $.ajax({
        url:APP + "Mobile/Goods/ajax_is_collect",
        data:query,
        type:"post",
        success:function(data){
            if(data.is_collect>0){
                $("#collect").html("&#x3432;");
				$("#collect").addClass("class_sc");
                $('#words').html('已收藏');
            }
            else $('#words').html('加入收藏');
        }
    })
}
function collect_shop(id){
     $.get(APP+"Home/Shop/collect", { id: id}, function(data){
         if(data.status==0) {
			$.openUrl(data.url, data.msg, 'ID', '800', function () {
				return false;
			}, function () {
				return false;
			});
		 }else if(data.status == 2){
             $("#shop_collect_words").text('加入收藏');
             $.showSuccess(data.msg,0,'hc');
         }else if(data.status == 3){
             $.showErr(data.msg,0,'hc');
         }else{
             $("#shop_collect_words").text('已收藏');
             $.showSuccess(data.msg,0,'hc');
         }
    }); 
}