﻿
/*
 * 爱车信使webservice调用接口
 * @para methodname 方法名称
 * @para parameters 相应方法的参数
 * @para async      异步还是同步方式
 * @para callback   相应方法的回调函数，处理返回的结果
 */




/*
 * 用户信息接口
 */
function user_info(user_name,user_phone,link_phone,link_phone2,email,address,owner_phone,password_type,web_title,cc_service_type){
	this.user_name = user_name;        	//用户姓名
	this.user_phone = user_phone;       	//手机
	this.link_phone = link_phone;       	//联系电话
	this.link_phone2 = link_phone2;     	//联系电话2
	this.email = email;            		//电子邮箱
	this.address = address;          	//联系地址
	this.owner_phone = owner_phone;     	//车主手机
	this.password_type = password_type; 	//验证密码方式，0：固定密码；1：随机密码；
	this.web_title = web_title;        	//网页标题
	this.cc_service_type = cc_service_type; //呼叫中心服务编号
}
function alarm_linker_info(linker_name,linker_phone){
	this.linker_name = linker_name;
	this.linker_phone = linker_phone;
}
function cc_service_time(begin_time,end_time){
	this.begin_time = begin_time;
	this.end_time = end_time;
}
function position_info(longitude,latitude,speed,current_time,stars,directions,current_status){
    this.longitude = longitude;
    this.latitude = latitude;
    this.speed = speed;
    this.current_time = current_time;
    this.stars = stars;
    this.directions = directions;
    this.current_status = current_status;    
}
function  para_type(name,value){
    this.name = name;
    this.value = value;
}

function loadXML(xmlFile){
	var xmlDoc;
	if(window.ActiveXObject){
		xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
		xmlDoc.async = false;
		xmlDoc.load(xmlFile);
	}else if (document.implementation && document.implementation.createDocument){
		xmlDoc = document.implementation.createDocument('', '', null);
		xmlDoc.load(xmlFile);
	}else{
		alert('您的浏览器不支持xml文件读取,于是本页面禁止您的操作,推荐使用IE5.0以上可以解决此问题!');
		xmlDoc = null;
	}
	return xmlDoc;
}
function getNodeValue(xmlDoc,xPath){
    var noderoot = xmlDoc.getElementsByTagName(xPath);
	if(noderoot && noderoot.length > 0){
		var node = xmlDoc.getElementsByTagName(xPath)[0].childNodes;
		var length = node.length;
		if(node.length == 1 && node[0].nodeType == 3)
			return node[0].nodeValue;
		else
			return "";
	}
	else return "";
}
function getNodeElements(xmlDoc,xPath){
	var node = xmlDoc.getElementsByTagName(xPath);//[0].childNodes;
	var length = node.length;
	if(length > 0)
		return node;
	else
		return null;
}
var web_server_service_url = "http://www.bbznl.com/q6/";
var nsuri = 'http://acxs.carto.cn/';
var error_message_system = "参数错误，请与客户服务中心联系！";
var error_message_web_server = "服务器错误，请与客户服务中心联系！";
var error_message_timeout = "由于您长时间未登录，为了您帐号的安全，请重新登录后操作！";
var error_carno_no="人员名称错误，请确认是否已经删除此人员！";
var error_carno_err="人员名称格式错误，请输入或选择正确的名称！";
var error_noCar="没有可操作的人员！";
/*
 * 爱车信使webservice调用接口
 * @para methodname 方法名称
 * @para parameters 相应方法的参数
 * @para callback   相应方法的回调函数，处理返回的结果
 */
 
 function acxs_q6_function(methodname,parameters,async,callback){
    var service_url = web_server_service_url+"carto_service_q6.asmx";
    if(async){
        SOAPClient.invoke(service_url, methodname,parameters , async , callback);       //异步调用
    }else{
        return SOAPClient.invoke(service_url, methodname,parameters , async , null);    //同步调用
    }
}
function acxs_user_function(methodname,parameters,async,callback){
    var service_url = web_server_service_url+"carto_service_user.asmx";
    if(async){
        SOAPClient.invoke(service_url, methodname,parameters , async , callback);       //异步调用
    }else{
        return SOAPClient.invoke(service_url, methodname,parameters , async , null);    //同步调用
    }
}

function acxs_car_function(methodname,parameters,async,callback){
    var service_url = web_server_service_url+"carto_service_car.asmx";
    if(async){
        SOAPClient.invoke(service_url, methodname,parameters , async , callback);       //异步调用
    }else{
        return SOAPClient.invoke(service_url, methodname,parameters , async , null);    //同步调用
    }
}
function acxs_common_function(methodname,parameters,async,callback){
   var service_url = web_server_service_url+"carto_service_common.asmx";
   //  var service_url = "http://localhost/acxs_web_service_no_session_20081030/carto_service_common.asmx";
    if(async){
        SOAPClient.invoke(service_url, methodname,parameters , async , callback);       //异步调用
    }else{
        return SOAPClient.invoke(service_url, methodname,parameters , async , null);    //同步调用
    }
}
function acxs_phone_no_function(methodname,parameters,async,callback){
    var service_url = web_server_service_url+"carto_service_phone_no.asmx";
    if(async){
        SOAPClient.invoke(service_url, methodname,parameters , async , callback);       //异步调用
    }else{
        return SOAPClient.invoke(service_url, methodname,parameters , async , null);    //同步调用
    }
}
function carto_web_alarm_phone(phone_no,alarm_type_id){
    this.phone_no = phone_no;
    this.alarm_type_id = alarm_type_id;
    this.is_enalbe = 1;
}
function stop_monitor(phone_no,password)
{
    this.phone_no=phone_no;
    this.password=password;
}
function areainfo(lonlat,mobile,message){
	this.lonlat = lonlat;
	this.mobile = mobile;
	this.mobileflag = false;
	this.message = message;
	this.messageflag = false;
}
function carto_web_area_info(area_type,area_index,longitude_left,longitude_right,latitude_top,latitude_bottom)
{
    this.area_type=area_type;
    this.area_index=area_index;
    this.longitude_left=longitude_left;
    this.longitude_right=longitude_right;
    this.latitude_top=latitude_top;
    this.latitude_bottom=latitude_bottom;
}
function carto_web_alarm_module(module_type_id,alarm_module)
{
    this.module_type_id=module_type_id;
    this.alarm_module=alarm_module;
}
function  carto_web_autoup(begin_time,end_time,time_interval)
{  
    this.begin_time=begin_time;          //上发开始时间
    this.end_time=end_time;              //上发结束时间
    this.time_interval=time_interval;    //时间上发间隔
   
}

areainfo.prototype.setlonlat=function(lonlat){this.lonlat = lonlat;}
areainfo.prototype.setmessage=function(message){this.message = message;}
areainfo.prototype.setmessageflag=function(flag){this.messageflag = flag;}
areainfo.prototype.setmobileflag=function(flag){this.mobileflag = flag;}
areainfo.prototype.setmobile=function(mobile){this.mobile = mobile;}
areainfo.prototype.getmessageflag=function(){return this.messageflag;}
areainfo.prototype.getmobileflag=function(){return this.mobileflag;}
areainfo.prototype.getlonlat=function(){return this.lonlat;}
areainfo.prototype.getmessage=function(){return this.message;}
areainfo.prototype.getmobile=function(){return this.mobile;}

var area_current_info = new areainfo("0,0,0,0","","");            //初始化区域信息
var bAreaIsChanged = false;

var areaArray = new Array();                            //初始化数组
for(var i=0;i<10;i++){
    areaArray[i] = new areainfo("","","");            //初始化区域信息
}
/*
 * 用户登录调用函数
 * @para UserName 		用户帐号
 * @para UserPassword 	用户密码
 */
function user_login(user_name,user_password,callback) {
    
    var parameters = new SOAPClientParameters();
    parameters.add("user_name", user_name);
    parameters.add("user_password", user_password);
    
    acxs_q6_function('UserLogin',parameters,true,callback);
    
}
function childInfoAdd(child_name,child_phone,imei_no,loginKey,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("child_name", child_name);
    parameters.add("child_phone", child_phone);
    parameters.add("imei_no", imei_no);
    parameters.add("login_key", parseInt(loginKey));
     acxs_q6_function('AddChildInfo',parameters,true,callback);
   
}
function getUserRightInfo(child_name,loginKey,callback)
{
     var parameters = new SOAPClientParameters();
    parameters.add("child_name", child_name);
    parameters.add("login_key", parseInt(loginKey));
     acxs_q6_function('GetChildInfo_forChildName',parameters,true,callback);
}
function modify_child_info(child_name,child_phone,child_id,imei_no,loginKey,callback)
{
   
    var parameters = new SOAPClientParameters();
    parameters.add("login_key", parseInt(loginKey));
    parameters.add("child_id", parseInt(child_id));
    parameters.add("imei_no", imei_no);
    parameters.add("child_name", child_name);
    parameters.add("child_phone", child_phone);    
    acxs_q6_function('ModifyChildInfo',parameters,true,callback);
}
function del_child_info(child_id,loginKey,callback)
{
     var parameters = new SOAPClientParameters();
    parameters.add("child_id", parseInt(child_id));
    parameters.add("login_key", parseInt(loginKey));
     acxs_q6_function('DeleteChildInfo',parameters,true,callback);
}
function add_child_quyu(child_id,quyu_index,quyu_name,loginKey,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("child_id", parseInt(child_id));
    parameters.add("area_index", parseInt(quyu_index));
    parameters.add("area_name", quyu_name);
    parameters.add("login_key", parseInt(loginKey));
    
     acxs_q6_function('AddChildAreaInfo',parameters,true,callback);
}
function del_child_quyu(child_id,quyu_index,loginKey,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("child_id", parseInt(child_id));
    parameters.add("area_index", parseInt(quyu_index));

    parameters.add("login_key", parseInt(loginKey));
    
     acxs_q6_function('DeleteChildAreaInfo',parameters,true,callback);
}

function add_child_frend(child_id,friend_index,friend_name,friend_phone,loginKey,callback)
{   
  //  alert("child_id:"+child_id+"friend_index:"+friend_index+"friend_name:"+friend_name);
    var parameters = new SOAPClientParameters();
    parameters.add("child_id", parseInt(child_id));
    parameters.add("friend_name", friend_name);
    parameters.add("friend_index", parseInt(friend_index));
    parameters.add("friend_phone", friend_phone);
    parameters.add("login_key", parseInt(loginKey));
    
     acxs_q6_function('AddChildFriendInfo',parameters,true,callback);
}
function del_child_frend(child_id,friend_index,loginKey,callback)
{
      var parameters = new SOAPClientParameters();
    parameters.add("child_id", parseInt(child_id));
    parameters.add("friend_index", parseInt(friend_index));
    parameters.add("login_key", parseInt(loginKey));
    
     acxs_q6_function('DeleteChildFriendInfo',parameters,true,callback);
}


function getChildFrendByID(child_id,friend_id,loginKey,callback)
{
   
    var parameters = new SOAPClientParameters();
    parameters.add("child_id",parseInt(child_id));
    parameters.add("friend_id", parseInt(friend_id));
    parameters.add("login_key", parseInt(loginKey));
    acxs_q6_function('GetChildFriendInfo',parameters,true,callback);
}
function getChildAreaByID(child_id,area_id,loginKey,callback)
{
      var parameters = new SOAPClientParameters();
    parameters.add("child_id",parseInt(child_id));
    parameters.add("area_id", parseInt(area_id));
    parameters.add("login_key", parseInt(loginKey));
    acxs_q6_function('GetChildAreaInfo',parameters,true,callback);
}
function command_(child_name,str,loginKey,common_id,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("child_name",child_name);
    parameters.add("login_key", parseInt(loginKey));
    parameters.add("common_id", parseInt(common_id));//，2加区域,3加短语,4隐身，5加好友,6锁机,7关机
    parameters.add("command_string", escape(str));
     acxs_q6_function('SendCommandToPhone',parameters,true,callback);
}

//common_id:1即时位置，
function q6CommonCurrentPosition(child_name,loginKey,common_id,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("child_name",child_name);
    parameters.add("login_key", parseInt(loginKey));
    parameters.add("common_id", parseInt(common_id));  
     acxs_q6_function('Q6CommonCurrentPosition',parameters,true,callback);
}

function getPhraseById(p_id,loginKey,callback)
{  
    var parameters = new SOAPClientParameters();
    parameters.add("content_id",p_id);
    parameters.add("login_key", loginKey);
     acxs_q6_function('GetPhrasesInfo',parameters,true,callback);
}

function LastPositionQuery(phone_no,child_name,loginKey,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("phone_no",escape(phone_no));
    parameters.add("child_name",escape(child_name));
    parameters.add("login_key", parseInt(loginKey));
    acxs_q6_function('Q6CommonLastPositionQuery',parameters,true,callback);
}

//自动运行返回数据
function Get_q6_Return_Result(serial_no,login_key,callback)
{
    var parameters = new SOAPClientParameters();
    parameters.add("login_key",login_key);
    parameters.add("random",Math.random());
    parameters.add("serial_no",escape(serial_no));
    acxs_q6_function('Q6CommonGetReturnResult',parameters,true,callback);
}
//查询实时,返回位置。
function Q6_Show_Current_Position_To_Map(phone_no,child_name,login_key,callback){
    var parameters = new SOAPClientParameters();
    parameters.add("phone_no",escape(phone_no));
        parameters.add("child_name",escape(child_name));
    parameters.add("login_key", parseInt(login_key));
    acxs_q6_function('Q6CommonLastPositionQuery',parameters,true,callback);	
}

//取登陆名
function Get_Login_Name(login_key,callback)
{	
   var parameters = new SOAPClientParameters();  
   parameters.add("login_key",login_key);
	acxs_q6_function('Q6GetLoginName',parameters,true,callback);
	
}
//查登陆名
function Check_Login_Name(login_key,new_login_name,callback)
{
    var parameters =new SOAPClientParameters();
    parameters.add("login_key",login_key);
    parameters.add("new_login_name",new_login_name);
    
    acxs_q6_function('Q6CheckLoginName',parameters,true,callback); 
}
//修改登陆名
function eidt_LoginNmae(login_key,old_login_name,new_login_name,callback)
{
    var parameters =new SOAPClientParameters();
    parameters.add("login_key",login_key);
    parameters.add("old_login_name",old_login_name);
    parameters.add("new_login_name",new_login_name);
    
   acxs_q6_function('Q6LoginNameModify',parameters,true,callback); 

}
//修改密码
function eidt_userpassword(login_key,old_password,new_password,callback)
{
    var parameters =new SOAPClientParameters();
    parameters.add("login_key",login_key);
    parameters.add("old_password",old_password);
    parameters.add("new_password",new_password);
    
    acxs_q6_function('Q6UserPasswordModify',parameters,true,callback); 
}

function User_Encrypt_Login(user_name,user_password,login_time,callback) {
 // var parameters = new Array({name:"user_name",value:user_name},{name:"user_password",value:user_password},{name:"login_time",value:login_time});
  //acxs_function_user('UserEncryptLogin',parameters,callback);
  var parameters = new SOAPClientParameters();
    parameters.add("user_name", user_name);
    parameters.add("user_password", user_password);
    parameters.add("login_time", login_time);
    acxs_q6_function('UserEncryptLogin',parameters,true,callback);
}
//查询上发条件参数设置
function Common_Auto_Up_Query(child_name,login_key,callback){	
	var parameters = new SOAPClientParameters();
    parameters.add("login_key",login_key);
    parameters.add("child_name",escape(child_name));
	acxs_q6_function('Q6CommonQueryAutoup',parameters,true,callback);	
}
//取历吏轨迹
function Get_Track_Info(child_name,begin_time,end_time,login_key,callback){
    var parameters = new SOAPClientParameters();
    parameters.add("login_key",login_key);
    parameters.add("child_name",escape(child_name));
    parameters.add("begin_time_s",begin_time);
    parameters.add("end_time_s",end_time);
    acxs_q6_function('Q6CommonTrackQuery',parameters,true,callback);
}
