var httpData; var m_projcode = ''; var runid = ''; var m_godate = ''; var m_gotime = ''; var m_backdate = ''; var m_backtime = ''; var ticket = ''; if (window.ActiveXObject) { var myreq = new ActiveXObject("Microsoft.XMLHTTP"); } else { var myreq = new XMLHttpRequest(); } function getPar(par){ //获取当前URL var local_url = document.location.href; local_url = decodeURI(local_url); //获取要取得的get参数位置 var get = local_url.indexOf(par +"="); if(get == -1){ return false; } //截取字符串 var get_par = local_url.slice(par.length + get + 1); //判断截取后的字符串是否还有其他get参数 var nextPar = get_par.indexOf("&"); if(nextPar != -1){ get_par = get_par.slice(0, nextPar); } return get_par; } var user_id = ''; var link_name = ''; var link_phone = ''; var link_id = ''; window.onload = function(){ m_projcode = getPar('prodcode'); ticket = getPar('ticket'); runid = getPar('runid'); m_godate = getPar('m_godate'); m_gotime = getPar('m_gotime'); m_backdate = getPar('m_backdate'); m_backtime = getPar('m_backtime'); user_id = getPar("user_id"); link_name = getPar("link_name"); link_phone = getPar("link_phone"); link_id = getPar("link_id"); if(user_id < 0){ document.getElementById("user_id").value = user_id; document.getElementById("link_name").value = ""; document.getElementById("link_phone").value = ""; document.getElementById("link_id").value = ""; }else{ document.getElementById("user_id").value = user_id; document.getElementById("link_name").value = link_name; document.getElementById("link_phone").value = link_phone; document.getElementById("link_id").value = link_id; } } function submit_user(){ var user_id_edit = document.getElementById("user_id").value; var link_name_edit = document.getElementById("link_name").value; var link_phone_edit = document.getElementById("link_phone").value; var link_idno_edit = document.getElementById("link_id").value; if(!link_name_edit){ alert("联系人不能为空"); }else if(!link_phone_edit){ alert("手机号不能为空"); }else if(!link_idno_edit){ alert("身份证不能为空"); }else{ if(user_id < 0){ add_user_info(link_name_edit, link_phone_edit, link_idno_edit); }else{ edit_user_info(user_id_edit, link_name_edit, link_phone_edit, link_idno_edit); } } } function add_user_info(link_name, link_phone, link_idno){ c_url = 'http://xmwx.zhizhuchuxing.cn/core/customer_add.asp?name=' + link_name + '&mobile=' + link_phone + '&idno=' + link_idno; myreq.open('get', c_url, true); myreq.onreadystatechange = add_account; myreq.send(); } function add_account(){ if (myreq.readyState == 4) { var newstr = myreq.responseText; httpData = JSON.parse(newstr); var c_code = httpData.code; if (c_code == '0'){ var listURL = "./select_contacts.html?prodcode="+m_projcode; if(!ticket){ }else{ listURL += "&ticket="+ticket; } if(!runid){ }else{ listURL += "&runid="+runid; if(!m_godate || !m_gotime){ }else{ listURL += "&m_godate="+m_godate; listURL += "&m_gotime="+m_gotime; } if(!m_backdate || !m_backtime){ }else{ listURL += "&m_backdate="+m_backdate; listURL += "&m_backtime="+m_backtime; } } // 跳转前将URL编码 listURL = encodeURI(listURL); window.location.href = listURL; }else{ alert(httpData.info); return; } } } function edit_user_info(link_id, link_name, link_phone, link_idno){ myreq.open("get", "http://xmwx.zhizhuchuxing.cn/core/customer_modify.asp?id="+link_id+"&name="+link_name+"&mobile="+link_phone+ "&idno="+link_idno, true); myreq.onreadystatechange = edit_account; myreq.send(); } function edit_account(){ if (myreq.readyState == 4) { var newstr = myreq.responseText; httpData = JSON.parse(newstr); var c_code = httpData.code; if (c_code == '0'){ var listURL = "./select_contacts.html?prodcode="+m_projcode; if(!ticket){ }else{ listURL += "&ticket="+ticket; } if(!runid){ }else{ listURL += "&runid="+runid; if(!m_godate || !m_gotime){ }else{ listURL += "&m_godate="+m_godate; listURL += "&m_gotime="+m_gotime; } if(!m_backdate || !m_backtime){ }else{ listURL += "&m_backdate="+m_backdate; listURL += "&m_backtime="+m_backtime; } } // 跳转前将URL编码 listURL = encodeURI(listURL); window.location.href = listURL;H }else{ alert(httpData.info); return; } } }