$(function(){
	var openId = $("#openId").val();
	var developId = $("#developId").val();
	var organizationId = $("#organizationId").val();
	var userId =$("#userId").val();
	var userStatus = $("#status").val();
	var register = getRequest("register");
    //跳转服务
    $(".nav-btn.service").on("click",function(){
        window.location.href=$("#contextPath").val()+"/wechat/index/serviceListPage?openId="+openId+"&developId="+developId+"&userStatus="+userStatus+"&userId="+$("#userId").val()+"&register="+register+"&organId="+organizationId;
    });
    //跳转首页
    $(".nav-btn.home").on("click",function(){
        window.location.href=$("#contextPath").val()+"/wechat/index/homePageView?openId="+openId+"&developId="+developId+"&organizationId="+organizationId+"&userId="+userId;
    });
});
/**
 * 获取url参数
 * @param name
 */
 function getRequest(name) {
    const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
    const r = window.location.search.substr(1).match(reg)
    if (r != null) return unescape(r[2])
    return null
}
/**
 * 解除绑定
 */
function unbundling(){
        layer.open({
            cancel: function() {
                layer.open({
                    content: '你点了x',
                    time: 1
                });
            },
            btn: ['确认','取消'],
            shadeClose: false, //默认：true，是否点击遮罩时关闭层
            yes: function() {
            	var contextPath=$("#contextPath").val();
     	 	   var openId=$("#openId").val();
     	 	   var developId=$("#developId").val();
     	 	   var userId=$("#userId").val();
     	 	   $.ajax({
     	 			url:contextPath+"/wechat/appUser/removeBinding",
     	 			type:"POST",
     	 			data:{userId:userId},
     	 			success : function(data) {
     	 				if("success"==data){
     	 	        		layer.open({
     	 	   	       			content : "解绑成功",
     	 	   	       			skin : 'msg',
     	 	   	       			time : 1
     	 	   	       		,end:function(){
     	 	   	       			location.href=contextPath+"/wechat/appUser/userInfo?&openId="+openId+"&developId="+developId+"&userId="+userId;
     	 	   	       		}});
     	 	        	}else{
     	 	        		layer.open({
     	    	       			content : "请检查网络，提交失败.",
     	    	       			skin : 'msg',
     	    	       			time : 2
     	    	       		});
     	 	        	}
     	 			}, error : function(xhr,textStatus){
     	 				alert(textStatus);
     	 		    }
     	 		});
            },
            no: function() {
                
            },
            content: '您确定要解除绑定'
        });
	
}

/**
 * 修改资料
 */
function updateUserInfo(){
	var status=$("#status").val();
	if(status=="1"){
		return;
	}
	var contextPath=$("#contextPath").val();
	   var organizationId=$("#organizationId").val();
	   var openId=$("#openId").val();
	   var developId=$("#developId").val();
	   var userId=$("#userId").val();
	location.href=contextPath+"/wechat/appUser/uauthentication?organizationId="+organizationId+"&openId="+openId+"&developId="+developId+"&userId="+userId;
}


