<!--公共方法定义-->
/**
获取参数
**/
function getParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            if (unescape(r[2]) === "undefined") {
                return null;
            }
            return unescape(r[2]);
        }
        return null;
    }
/**
post请求处理,不带登录参数
**/
function post(requestUrl,requestData,callBackFunction,errorBackFunction)
{
$.ajax({
	url:requestUrl,
	data: requestData,
	type: "post",
	dataType: "json",
	contentType: "application/json",
	success: function(ret) {
		/*if(ret.code!="0000")
		{
			showErrorMsg(ret.message);
		}else{
			if(callBackFunction) callBackFunction(ret)
		}*/
	    if(ret.code!="0000")
		{
			showErrorMsg(ret.message);
		}
	    if(callBackFunction) callBackFunction(ret)
	},
    error: function (response) {
        if(errorBackFunction) errorBackFunction(response)
    }
})
}
/**
get请求处理,不带登录参数
**/
function get(requestUrl,requestData,callBackFunction,errorBackFunction)
{
$.ajax({
	url:requestUrl,
	data: requestData,
	type: "get",
	dataType: "json",
	contentType: "application/json",
	success: function(ret) {
	    if(ret.code!="0000")
		{
			showErrorMsg(ret.message);
		}
	    if(callBackFunction) callBackFunction(ret)
	},
    error: function (response) {
        if(errorBackFunction) errorBackFunction(response)
    }
})
}
/**
post请求处理,带登录参数
**/
function postWithLogin(requestUrl,requestData,mode,owner,callBackFunction,errorBackFunction)
{
	$.ajax({
	url:requestUrl,
	data: requestData,
	crossDomain:false,
	headers: {
        "session": getsession(),
		"Authorization": gettoken(mode),
		"owner": owner
	},
	type: "post",
	dataType: "json",
	contentType: "application/json",
	success: function(ret) {
	    if(ret.code!="0000")
		{
			showErrorMsg(ret.message);
		}
	    if(callBackFunction) callBackFunction(ret)
	},
	error: function (response) {
		if(errorBackFunction) errorBackFunction(response)
	}
})
}
/**
get请求处理,带登录参数
**/
function getWithLogin(requestUrl,requestData,mode,owner,callBackFunction,errorBackFunction)
{
	$.ajax({
	url:requestUrl,
	crossDomain:false,
	headers: {
        "session": getsession(),
		"Authorization": gettoken(mode),
		"owner": owner
	},
	type: "get",
	dataType: "json",
	contentType: "application/json",
	success: function(ret) {
	    if(ret.code!="0000")
		{
			showErrorMsg(ret.message);
		}
	    if(callBackFunction) callBackFunction(ret)
	},
	error: function (response) {
		if(errorBackFunction) errorBackFunction(response)
    }
})
}
/**
错误信息展示
*/
function showErrorMsg(message)
{
	console.log("错误信息:"+message);
}
