function delete_collect(id,type){
     $.get(APP+"Mobile/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();
            }
    	$.ajax({
        		url:APP + "Mobile/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 jump_orderurl(id){
    var order_ids=$("#ids").val();
    if(order_ids){
        window.location.href=APP+"Mobile/Order/index/ids/"+order_ids+"/addres_id/"+id;
    }else if(order_parm.type==1){
        window.location.href=APP+"Mobile/Order/index/goods_id/"+order_parm.goods_id+"/number/"+order_parm.number+"/goods_attr/"+order_parm.goods_attr+"/act/"+order_parm.act+"/type/"+order_parm.type+"addres_id/"+id;
    }else if(order_parm.type==3){
        window.location.href=APP+"Mobile/Order/index/goods_id/"+order_parm.goods_id+"/number/"+order_parm.number+"/goods_attr/"+order_parm.goods_attr+"/integra/"+order_parm.integra+"/type/"+order_parm.type+"addres_id/"+id;
    }
}
//添加,修改收货地址 
function update_address(id){
    var query=new Object();
    var order_ids=$("#ids").val();
    //列表页修改默认状态
    if(id){
        query.id = id;query.status = 1;query.changetype = 1;
    }else{
        query = $("form[name='myform']").serialize();
    }
    $.ajax({
        url:APP + "Mobile/Address/update_address",
        data:query,
        type:"post",
        success:function(data){
            if(data.status==1) {
                $.showSuccess(data.msg,0,'hc');
                if(order_ids){
                    window.location.href=APP+"Mobile/Order/index/ids/"+order_ids+"/addres_id/"+id;
                }else if(order_parm){
                    if(order_parm.type==1){
                        window.location.href=APP+"Mobile/Order/index/goods_id/"+order_parm.goods_id+"/number/"+order_parm.number+"/goods_attr/"+order_parm.goods_attr+"/act/"+order_parm.act+"/type/"+order_parm.type+"/addres_id/"+id;
                    }else if(order_parm.type==3){
                        window.location.href=APP+"Mobile/Order/index/goods_id/"+order_parm.goods_id+"/number/"+order_parm.number+"/goods_attr/"+order_parm.goods_attr+"/integra/"+order_parm.integra+"/type/"+order_parm.type+"/addres_id/"+id;
                    }
                } else{
                    window.history.back();
                }

            }else{
                $.showErr(data.msg,0,'hc');
            }
        }
    })
} 
 //删除地址
 function del_address(id){
    $.get(APP+"Mobile/Address/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 copy_code(copyText) {
    if (window.clipboardData) {
        window.clipboardData.setData("Text", copyText)
    } 
    else {
        var flashcopier = 'flashcopier';
        if(!document.getElementById(flashcopier)) {
          var divholder = document.createElement('div');
          divholder.id = flashcopier;
          document.body.appendChild(divholder);
        }
        document.getElementById(flashcopier).innerHTML = '';
        var divinfo = '<embed src="'+ROOT_PATH+'/Public/images/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(copyText)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        document.getElementById(flashcopier).innerHTML = divinfo;
    }
    $.showSuccess('代码已复制到剪贴板！',0,'hc');
}
$(document).ready(function(){ 
            $("#copy-dynamic").click( function () { 
                var url=$('input#dynamic').val();
                copy_code(url);
            });
});
//删除红包
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 submit_service(){
  var query=new Object();
	query = $("form[name='myform']").serialize();
	$.ajax({
		url:APP + "Mobile/UserInfo/submit_service",
		data:query,
		type:"post",
		success:function(data){
			if(data.status==1) {
				$.showSuccess(data.msg,0,'hc');
				window.location.href=data.mobile_url;
			}else{
				$.showErr(data.msg,0,'hc');
			}
		}
	});
}
function shop_logout(){
    $.get(APP+"Mobile/ShopInfo/logout", '', function(data){
		if(data.status==0) {
			$.showErr(data.info,0,'hc');
			window.location.href=data.url;
		}else if(data.status == 1){
			$.showSuccess(data.info,0,'hc');
			window.location.href=data.url;
		}
    }); 
}