function delete_collect(id,type){
     $.get(APP+"Member/Collection/delete_collect", { id: id,type:type}, function(data){
         if(data.status==0) {
                $.showErr(data.msg,0,'hc');
            }else if(data.status == 1){
             $.showSuccess(data.msg,0,'hc');
             window.location.reload();
         }
    }); 
}
//修改个人信息
function refer(info){
	var query=new Object();
             if(info=='pwd' || info=='user'){
                query = $("form[name='myform']").serialize();
                if(info=='user'){
                    var nickname=$("input[name='nickname']").val();
                    if(!nickname){
                      $.showErr('昵称不能为空',0,'hc');
                      return false;
                    }
                    var username=$("input[name='username']").val();
                    if(!username){
                      $.showErr('用户名不能为空',0,'hc');
                      return false;
                    }
                    var re1=/[a-zA-Z]|[0-9]/g;
                    var re2=/[\u4e00-\u9fa5]/g;
                    var length=0;
                    var length2=0;
                    if(username.match(re1)){
                      var letter=username.match(re1);
                      length+=letter.length;
                      length2+=letter.length;
                    }
                    if (username.match(re2)) {
                      var chinese = username.match(re2);
                      length += chinese.length;
                      length2 = length2+chinese.length*2;
                    } 
                    if (length == username.length) {
                      if (length2<6 || length2>16) {
                            $.showErr('请输入6-16位字符,可包含汉字、数字、字母',0,'hc');
                             return false;
                      }      
                    }else{
                            $.showErr('请输入6-16位字符,可包含汉字、数字、字母',0,'hc');
                             return false;
                    }
                }
            }
            if(info=='paypwd'){
                query = $("form[name='myforms']").serialize();
            }
			if(info=='card_paypwd'){
                query = $("form[name='myforms']").serialize();
            }
    	$.ajax({
        		url:APP + "Member/Userinfo/updateinfo",
        		data:query,
        		type:"post",
        		success:function(data){
            			if(data.status==1) {
                			$.showSuccess(data.msg,0,'hc');
                                                window.location.href=data.url;
	            		}else{
	                		$.showErr(data.msg,0,'hc');
	            		}
        		}
    	})
}
 //添加,修改收货地址,弹窗
 function pop_address(id){
     if(id>0){
        $.openUrl(APP+'Member/Userinfo/pop_address/id/'+id+'.html','修改收货地址',id, '800', function () {
                    return false;
                }, function () {
                    return false;
                }); 
     }else{
         $.openUrl(APP+'Member/Userinfo/pop_address','添加收货地址', 'ID', '800', function () {
                    return false;
                }, function () {
                    return false;
                });
     }
 }
function close_pop(){
    window.location.reload(); //刷新父窗口中的网页
    window.close();
}
//添加,修改收货地址 
 function update_address(){
    var query=new Object();
    query = $("form[name='myform']").serialize();
        $.ajax({
                url:APP + "Member/Userinfo/update_address",
                data:query,
                type:"post",
                success:function(data){
                        if(data.status==1) {
                            $.showSuccess(data.msg,0,'hc');
                            window.location.reload();
                        }else{
                            $.showErr(data.msg,0,'hc');
                        }
                }
        })
 } 
 //删除地址
 function del_address(id){
    $.get(APP+"Member/Userinfo/del_address", { id: id}, function(data){
         if(data.status==0) {
                $.showErr(data.msg,0,'hc');
            }else if(data.status == 1){
             $.showSuccess(data.msg,0,'hc');
             window.location.reload();
         }
    }); 
 }
//删除红包
function del_redPacket(id){
    $.get(APP+"Member/AccountLog/del_redPacket", { id: id}, function(data){
         if(data.status==0) {
                $.showErr(data.msg,0,'hc');
            }else if(data.status == 1){
             $.showSuccess(data.msg,0,'hc');
             window.location.reload();
         }
    }); 
 }
 //领取红包
 function draw_redpacket(){
    var query=new Object();
    query = $("form[name='myform']").serialize();
        $.ajax({
                url:APP + "Member/AccountLog/draw_redpacket",
                data:query,
                type:"post",
                success:function(data){
                        if(data.status==1) {
                            $.showSuccess(data.msg,0,'hc');
                            window.location.href=data.url;
                        }else{
                            $.showErr(data.msg,0,'hc');
                        }
                }
        })
 } 
 //解除第三方绑定关系 
 function del_other(id){
	$.showConfirm("您确定要解除绑定吗？",function(){
		var query=new Object();
		query.id = id;
		$.ajax({
			url:APP + "Member/Userinfo/del_other",
			data:query,
			type:"post",
			success:function(data){
				if(data.status==1) {
					$.showSuccess(data.info,1,'hc');
					$('#is_del').val('已解除');
					$('#is_del').attr("disabled", "true");
				}else{
					$.showErr(data.info,0,'hc');
				}
			}
		})
	},'hc');
 }