$(function () { initProvince(); // 省份数据 }) // 省市级联 function initProvince() { var obj = document.getElementById("sProvice"); SingGooJS.getXml("Xml/Provinces.xml", "Province", obj); } // 加载城市 function loadCity() { var proviceId = SingGooJS.GetSelectValue("sProvice"); // 省份ID var obj = document.getElementById("sCity"); // 清理 document.getElementById("sCity").innerHTML = ""; $.ajax({ url: "Xml/Cities.xml", dataType: 'xml', type: 'GET', cache: true, timeout: 10000, error: function (xml) { alert( '加载XML文件出错!', 'error'); }, success: function (xml) { $(xml).find("City").each(function (i) { var id = $(this).attr("ID"); // 取属性值 var name = $(this).attr("CityName"); var pid = $(this).attr("PID"); if (proviceId == pid) SingGooJS.selectAddOption(obj, name, id); }); } }); } // 检查手机号是否已被注册过了 function checkMobile() { var mobile = $("#txtMobile").val(); if (mobile == "") { alert( '手机号码不能为空!', 'error'); document.getElementById("txtMobile").focus(); return false; } else { $.ajax({ type: 'POST', url: 'tools/registered.ashx', data: 'param=CheckMobile&mobile=' + mobile, timeout: 30000, dataType: 'text', error: function () { //$.messager.alert('温馨提示', '系统繁忙,请稍候后试!', 'error'); }, success: function (outmsg) { if (outmsg == "0") { document.getElementById("txtMobile").value = ""; alert( "该手机号已被注册过了!"); } } }); } } // 手机号是否已经是会员 function checkMobileIsTrue() { var mobile = $("#txtMobile").val(); if (mobile == "") { alert( '手机号码不能为空!', 'error'); document.getElementById("txtMobile").focus(); return false; } else { $.ajax({ type: 'POST', url: 'tools/registered.ashx', data: 'param=CheckMobile&mobile=' + mobile, timeout: 30000, dataType: 'text', error: function () { // alert('温馨提示', '系统繁忙,请稍候后试!', 'error'); }, success: function (outmsg) { if (outmsg == "0") { //document.getElementById("txtMobile").value = ""; //$.messager.alert('温馨提示', "该手机号已被注册过了!"); } else { document.getElementById("txtMobile").value = ""; alert( "手机号暂未注册,请您先注册成为本站会员!"); } } }); } } // 检查业务是否存在 function checkSales(obj) { var sales = obj.value; if (sales == "") { alert( '业务员编号或手机号码不能为空!', 'error'); obj.focus(); return false; } else { $.ajax({ type: 'POST', url: 'tools/registered.ashx', data: 'param=CheckSales&sales=' + sales, timeout: 30000, dataType: 'text', error: function () { //$.messager.alert('温馨提示', '系统繁忙,请稍候后试!', 'error'); }, success: function (outmsg) { if (outmsg == "0") { obj.value = ""; alert( "该业务员编号或手机号码不存在!"); } $("#hSalesID").val(outmsg); } }); } } //提交注册 function btnOK_onclick() { debugger var mobile = $("#txtMobile").val(); if (mobile == "") { $("#txtMobile").parent().siblings(".error-msg").removeClass("undis").children("p").children("span").text('手机号码不能为空!'); document.getElementById("txtMobile").focus(); return false; } var email = $("#txtEmail").val(); //if (email == "") { // $.messager.alert('温馨提示', '电子邮箱不能为空!', 'error'); // document.getElementById("txtEmail").focus(); // return false; //} var pwd = $("#txtPwd").val(); if (pwd == "") { $("#txtPwd").parent().siblings(".error-msg").removeClass("undis").children("p").children("span").text('密码不能为空!'); document.getElementById("txtPwd").focus(); return false; } var pwd1 = $("#txtPwd1").val(); if (pwd1 == "") { $("#txtPwd1").parent().siblings(".error-msg").removeClass("undis").children("p").children("span").text('确认密码不能为空!'); document.getElementById("txtPwd1").focus(); return false; } if (pwd != pwd1) { $("#txtPwd1").parent().siblings(".error-msg").removeClass("undis").children("p").children("span").text('确认密码输入不一致,请重新输入确认密码!'); $("#txtPwd1").val(""); document.getElementById("txtPwd1").focus(); return false; } var company = $("#txtCompany").val(); var name = $("#txtName").val(); if (name == "") { alert( '联系人不能为空!', 'error'); return false; } var qq = $("#txtQQ").val(); //if (qq == "") { // $.messager.alert('温馨提示', 'QQ号码人不能为空!', 'error'); // return false; //} var tel = $("#txtTel").val(); var fax = $("#txtFax").val(); var proviceId = "";// SingGooJS.GetSelectValue("sProvice"); //if (proviceId <= 0) { // $.messager.alert('温馨提示', '省份不能为空!', 'error'); // return false; //} var cityId="";// = SingGooJS.GetSelectValue("sCity"); //if (cityId <= 0) { // $.messager.alert('温馨提示', '城市不能为空!', 'error'); // return false; //} var address = $("#txtAddress").val(); //if (address == "") { // $.messager.alert('温馨提示', '街道地址不能为空!', 'error'); // return false; //} // 验证码 var validateCode = $("#SendValidateCode").val(); if (validateCode == "" || validateCode == undefined) { $("#SendValidateCode").parent().siblings(".error-msg").removeClass("undis").children("p").children("span").text('请输入验证码!'); document.getElementById("SendValidateCode").focus(); return false; } //是否同意隐私协议 if ($("#IsCheckUserAgreement").attr("checked") != "checked") { $("#req_Agreement").removeClass("undis"); return false; } //指定的业务员ID var salesId = $("#hSalesID").val(); //1.业务专员 2.朋友介绍 3.广告传单 4.搜索引擎或其他 var from_type = $('input[name="hidType"]:checked').val(); //朋友介绍,朋友的手机号 var user_no = $("#txtSales1").val(); // 防止重复提交 $("#btnOK").attr("value", "正在提交..."); $("#btnOK").attr("disabled", "disabled"); $.ajax({ type: 'POST', url: 'tools/registered.ashx', data: 'param=AddUser&mobile=' + mobile + "&email=" + email + "&pwd=" + pwd + "&company=" + escape(company) + "&name=" + name + "&qq=" + qq + "&tel=" + tel + "&fax=" + fax + "&proviceId=" + proviceId + "&cityId=" + cityId + "&address=" + address + "&validateCode=" + validateCode + "&salesId=" + salesId + "&from_type=" + from_type + "&friend_mobile=" + user_no, timeout: 30000, dataType: 'text', error: function () { alert( '系统繁忙,请稍候后试!', 'error'); }, success: function (outmsg) { var alertMessage = ""; if (outmsg == "恭喜您,注册成功!") { alertMessage = "恭喜您注册成功,您的用户名是" + mobile + ",密码是" + pwd + ",请您记好,方便下单"; alert( alertMessage); setTimeout("goToLogin()", 5000); } else { $("#SendValidateCode").parent().siblings(".error-msg").removeClass("undis").children("p").children("span").text(outmsg); document.getElementById("SendValidateCode").focus(); } $("#btnOK").attr("value", "马上注册"); $("#btnOK").removeAttr("disabled"); } }); } function goToLogin() { window.location.href = "login.aspx"; } //首页提交注册 function btnOK_onclick2() { var mobile = $("#txtMobile").val(); if (mobile == "") { alert( '手机号码不能为空!', 'error'); document.getElementById("txtMobile").focus(); return false; } var pwd = $("#txtPwd").val(); if (pwd == "") { alert( '密码不能为空!', 'error'); document.getElementById("txtPwd").focus(); return false; } var pwd1 = $("#txtPwd1").val(); if (pwd1 == "") { alert( '确认密码不能为空!', 'error'); document.getElementById("txtPwd1").focus(); return false; } if (pwd != pwd1) { alert( '确认密码输入不一致,请重新输入确认密码!', 'error'); $("#txtPwd1").val(""); document.getElementById("txtPwd1").focus(); return false; } var company = $("#txtCompany").val(); var name = $("#txtName").val(); if (name == "") { alert( '联系人不能为空!', 'error'); return false; } // 验证码 var validateCode = $("#txtCode").val(); if (validateCode == "") { alert( '请输入验证码!', 'error'); document.getElementById("txtCode").focus(); return false; } // 防止重复提交 $("#btnOK").attr("value", "正在提交..."); $("#btnOK").attr("disabled", "disabled"); $.ajax({ type: 'POST', url: 'tools/registered.ashx', data: 'param=AddUser2&mobile=' + mobile + "&pwd=" + pwd + "&company=" + escape(company) + "&name=" + name + "&validateCode=" + validateCode, timeout: 30000, dataType: 'text', error: function () { //$.messager.alert('温馨提示', '系统繁忙,请稍候后试!', 'error'); }, success: function (outmsg) { alert(outmsg); var alertMessage = ""; if (outmsg == "恭喜您,注册成功!") { alertMessage = "恭喜您注册成功,您的用户名是" + mobile + ",密码是" + pwd + ",请您记好,方便下单"; } alert( alertMessage); if (outmsg == "恭喜您,注册成功!") { setTimeout("goToLogin()", 5000); } //$("#btnOK").attr("value", "马上注册"); //$("#btnOK").removeAttr("disabled"); } }); } //手机验证码登录 function Button1_Click() { var mobile = $("#txtMobile").val(); if (mobile == "") { alert( '手机号码不能为空!', 'error'); document.getElementById("txtMobile").focus(); return false; } // 验证码 var validateCode = $("#txtCode").val(); if (validateCode == "") { alert( '请输入验证码!', 'error'); document.getElementById("txtCode").focus(); return false; } $.ajax({ type: 'POST', url: 'tools/registered.ashx', data: 'param=IsLogin2&mobile=' + mobile + "&validateCode=" + validateCode, timeout: 30000, dataType: 'text', error: function () { //$.messager.alert('温馨提示', '系统繁忙,请稍候后试!', 'error'); }, success: function (outmsg) { if (outmsg.length < 3) { if (Number(outmsg) == 2) { window.location.href = "client/order.aspx"; } else { window.location.href = "admin/index.aspx"; } //window.location.href = "client/order.aspx"; } else { alert( outmsg, 'error'); } } }); } //客户来源 1业务专员 2朋友介绍 3广告传单 4搜索引擎或其他 function fromType_OnClick(id){ if (id == 1) { $("#spanFromType1").show(); $("#spanFromType2").hide(); $("#spanFromType3").hide(); } else if (id == 2) { $("#spanFromType1").hide(); $("#spanFromType2").show(); $("#spanFromType3").hide(); } else if (id == 3) { $("#spanFromType1").hide(); $("#spanFromType2").hide(); $("#spanFromType3").show(); } else if (id == 4) { $("#spanFromType1").hide(); $("#spanFromType2").hide(); $("#spanFromType3").hide(); } } // 刷新验证码 function ToggleCode(obj, codeurl) { $(obj).attr("src", codeurl + "?time=" + Math.random()); } /************** 短信验证码 ****************/ function sendMessage() { debugger; var mobile = $("#txtMobile").val(); if (mobile == "" || mobile == "输入手机号码") { alert( '手机号码不能为空!', 'error'); document.getElementById("txtMobile").focus(); return false; } else { var num = random(); //6位数据随机验证码 $.ajax({ type: "GET", url: "tools/registered.ashx", data: "param=SendMessage&phone=" + mobile + "&smsCodeRand=" + num, timeout: 30000, dataType: 'text', error: function () { alert( '系统繁忙,请稍候后试!', 'error'); }, success: function (result) { if (result == "Y") { alert( '验证码已发送至您输入的手机号!有效期5分钟!', 'error'); //防止重复提交 $("#send_reg_msg_btn").attr("disabled", "disabled"); RemainTime(); } else { alert( '验证码获取失败!请重新获取!', 'error'); } } }) } } //获取6位随机验证码 function random() { var num = ""; for (i = 0; i < 6; i++) { num = num + Math.floor(Math.random() * 10); } return num; } //验证码有效期倒计时 var iTime = 300; function RemainTime() { var iSecond; var sSecond = "", sTime = ""; if (iTime >= 0) { iSecond = parseInt(iTime % 60); if (iSecond >= 0) { sSecond = iTime + "秒"; } sTime = "" + sSecond + ""; if (iTime == 0) { clearTimeout(Account); sTime = "重新获取"; $("#send_reg_msg_btn").removeAttr("disabled"); } else { Account = setTimeout("RemainTime()", 1000); } iTime = iTime - 1; } //$("#endtime").html(sTime); $("#send_reg_msg_btn").html(sTime); } //*************************生产订单查询********************************** $(function () { $("#btnSearch").click(function () { subSearch(); }).bind('keypress', function (event) { if (event.keyCode == "13") { subSearch(); } }); function subSearch() { var v = $("#txtSearch").val(); if (v == "请输入订单号") { $(".searchordertip").html("").append("

请输入订单号!

"); return; } $.ajax({ type: "post", url: "../tools/submit_ajax.ashx?action=order_process&orderno=" + v, success: function (data) { $(".searchordertip").html("").append(data); } }); } //index页面的生产订单查询 $("#selectBut").click(function () { var v = $("#paraValue").val(); if (v == "" || v == "请输入订单号!") { $("#paraValue").val("请输入订单号!"); } else { location = "orderprocess.aspx?orderno=" + v; } }) $("#paraValue").focus(function () { if (this.value = '请输入订单号!') { this.value = ''; } }); var para = self.location.href.indexOf("?") if (para > 0) { var v = self.location.href.substr((para + 1)); $("#txtSearch").val(getUrlParameter("orderno")); subSearch(); } //获取url指定的参数 function getUrlParameter(param) { var query = window.location.search; var iLen = param.length; var iStart = query.indexOf(param); if (iStart == -1) return ""; iStart += iLen + 1; var iEnd = query.indexOf("&", iStart); if (iEnd == -1) return query.substring(iStart); return query.substring(iStart, iEnd); } })