// 账号:test01密码:qwe123 // 账号:test02密码:rty456 // 账号:test03密码:uio789 // 账号:test04密码:asdfgh // 账号:test05密码:zxcvbn function repws_close() { document.getElementById("mask").style.display = "none"; document.getElementById("repsw").style.display = "none"; } function repsw_open() { document.getElementById("mask").style.display = "block"; document.getElementById("repsw").style.display = "block"; } function repsw_Sbumit() { psw = document.getElementById('re_password').value; uid = sessionStorage.getItem('user_id'); var repsw_url = 'https://www.5y6qi.com/ssms/api/getmessage?method=repassword&id=' + uid +'&password=' + psw; check = document.getElementById('check_password').value; console.log(psw, check); if (psw == '') { document.getElementById('psw_alert').innerHTML = '密码不可为空!'; document.getElementById('psw_alert').style.display = 'block'; } else if (psw.length < 6) { document.getElementById('psw_alert').innerHTML = '密码长度不得少于六位!'; document.getElementById('psw_alert').style.display = 'block'; } else if (psw != check) { document.getElementById('check_alert').innerHTML = '两次输入不一致!'; document.getElementById("check_alert").style.display = "block"; } else { document.getElementById('check_alert').innerHTML = ''; document.getElementById('psw_alert').innerHTML = ''; document.getElementById("psw_alert").style.display = "none"; document.getElementById("check_alert").style.display = "none"; ajax(repsw_url, function (xhr) { suc = JSON.parse(xhr.responseText).status; console.log(suc, '修改成功'); alert('修改成功!'); document.getElementById("mask").style.display = "none"; document.getElementById("repsw").style.display = "none"; }, function () { console.log('Repasswoed Error!'); alert('修改失败!'); }); } } function ajax(url, success, error) { var xmlhttp; //1、创建异步对象 if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", url, "true"); //2、设置请求方式和请求地址 xmlhttp.send(); //3、发送请求 xmlhttp.onreadystatechange = function (ev2) { //4、监听状态变化 if (xmlhttp.status >= 200 && xmlhttp.status < 300 || xmlhttp.status === 304) { if (xmlhttp.readyState === 4) { //5、处理返回结果: success(xmlhttp); } } else { error(xmlhttp); } }; }