123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- Namespace.register("U.MD.U.F");
- U.MD.U.F.findPassword = function () {
- var _parent = $("#U_MD_U_L_login");
-
- var _child = _parent.Child();
- _child[1].style.display = "none";
- _child[2].style.display = "none";
-
- $("div", _child[0])[2].innerHTML = "找回密码";
-
- var _head = $(_child[0]).childs()[1];
- $(_head).addAttrArray({
- "innerHTML": "",
- "onclick": null,
- "className": "",
- "title": ""
- });
-
- U.MD.U.F.findPasswordProcessing($(_child[3]).Child()[1], 0);
-
- U.MD.U.F.switchEmailOrSecurityFind($("span", _child[3])[0], 'security');
- _child[3].style.display = "block";
- }
- U.MD.U.F.findPasswordProcessing = function (el, displaynum) {
- var _inputs,
- _len,
- _bottom,
- _child = $(el).Child(),
- _parentel = $(el).Parent();
-
- for (i = 0; i < _child.length; i++) {
-
- if (i == displaynum) {
- _child[i].style.display = "block";
- _inputs = $("input", _child[i]);
- _len = _inputs.length;
- }
- else {
- _child[i].style.display = "none";
- }
- }
-
- while (_len--) {
- _inputs[_len].value = "";
- _inputs[_len].innerText = "6-20位字符或数字";
- _inputs[_len].focus();
- _inputs[_len].blur();
- }
- }
- U.MD.U.F.switchEmailOrSecurityFind = function (el, typename) {
- var _input,
- _tempel,
- _parentel = $(el).Parent(2),
- _childs = $(_parentel).Child(),
- _inputs = $("input", _parentel),
- _span = $("span", _parentel),
- _is = $("i", _parentel),
- _bottom = $(_parentel).Child()[2],
- _code = $("#U_MD_U_L_Overflow_Code")[0];
-
- if (typename == "email") {
- _input = _inputs[1];
- _tempel = $$("input", {
- "type": "text",
- "onblur": function () {
- U.MD.U.F.checkEmail(this); $(this).parentElement(2).removeClass('U_MD_U_L_Box_Border');
- },
- "onfocus": _input.onfocus,
- "onkeyup": _input.onkeyup
- });
- _input.parentNode.replaceChild(_tempel, _input);
- _is[1].innerText = "请输入邮箱";
- _span[1].className = "U_MD_U_F_T_Hover";
- _span[0].className = "";
- _code.style.display = "none";
- _bottom.onclick = function () {
- U.MD.U.F.findPasswordByEmail(_childs[1]);
- }
- }
-
- else if (typename == 'security') {
- _input = _inputs[1];
- _tempel = $$("input", {
- "type": "text",
- "onblur": function () {
- U.MD.U.F.checkPhone(this); $(this).parentElement(2).removeClass('U_MD_U_L_Box_Border');
- },
- "onfocus": _input.onfocus,
- "onkeyup": _input.onkeyup
- });
- _input.parentNode.replaceChild(_tempel, _input);
- _is[1].innerText = "请输入手机号";
- _span[0].className = "U_MD_U_F_T_Hover";
- _span[1].className = "";
- _code.style.display = "block";
- _inputs[3].value = "发送";
- _inputs[3].onclick = function () {
- U.MD.U.F.userName(U.MD.U.F.phoneSend);
- }
- _bottom.onclick = function () {
- U.MD.U.F.phoneConfirm(_childs[1]);
- }
- }
- }
- U.MD.U.F.checkSecurityCode = function (el) {
- var _inputs = $("input", el),
- _username = _inputs[0],
- _phone = _inputs[1];
- if (U.MD.U.F.checkUserName(_username) && U.MD.U.F.checkPhone(_phone)) {
- U.MD.U.F.phoneCheckSecurityCode(["", el, _username, _phone])
- }
- }
- U.MD.U.F.phoneSend = function () {
- var _username = $("#U_MD_U_L_Box_height")[0].children[0].children[0].value;
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserName", _username], function (r) {
- if (r.value[0] == undefined) {
- U.MD.U.R.setInputStyle($("#userphone")[0].children[0], {
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "输入的手机号与账号不匹配");
- return false;
- }
- if (r.value[0].UserTelephoneNumber != $("#userphone")[0].children[0].children[0].value) {
- U.MD.U.R.setInputStyle($("#userphone")[0].children[0], {
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "输入的手机号与账号不匹配");
- return false;
- }
- else {
-
-
-
- var _xhttp = new XMLHttpRequest();
- _xhttp.onreadystatechange = function () {
- if (this.readyState == 4) {
- if (this.status == 201) {
- U.Alert('发送成功');
- U.MD.U.F.setTime($("#U_MD_U_L_Overflow_Code")[0].children[1].children[0]);
- } else {
- U.Alert(JSON.parse(this.response).err || '验证码发送失败,请重新发送...');
- }
- }
- };
- _xhttp.open("POST", "http://api.cloudsql.1473.cn/postnumber", true);
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- _xhttp.withCredentials = true;
- _xhttp.send("number=" + $("#userphone")[0].children[0].children[0].value);
-
-
-
-
- }
- })
- }
- U.MD.U.F.phoneConfirm = function (el) {
- var _xhttp = new XMLHttpRequest();
- _xhttp.onreadystatechange = function () {
- if (this.readyState == 4) {
- if (this.status == 201) {
- U.MD.U.F.checkSecurityCode(el);
- U.Alert("验证成功");
- } else {
- U.Alert(JSON.parse(this.response).err || "验证码有误");
- }
- }
- };
- _xhttp.open("POST", "http://api.cloudsql.1473.cn/verifi", true);
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- _xhttp.withCredentials = true;
- _xhttp.send("code=" + $("#U_MD_U_L_Overflow_Code")[0].children[0].children[0].value);
- }
- U.MD.U.F.setTime = function (obj, countdown) {
- var countdown = 60;
- var _settime = setInterval(function () {
- if (countdown == 0) {
- obj.removeAttribute("disabled");
- obj.value = "重新获取验证码";
- clearInterval(_settime);
- return;
- } else {
- obj.setAttribute("disabled", true);
- obj.value = "重新发送(" + countdown + ")";
- countdown--;
- }
- }, 1000);
- }
- U.MD.U.F.userName = function (cb) {
- U.A.Request(US.USER, ["CheckUserName", U_MD_U_L_Box_height.children[0].children[0].value],
- function (r) {
- var _str = U.UF.C.jsonToStr(r.value);
- if (_str == "false") {
- U.MD.U.R.setInputStyle(U_MD_U_L_Box_height, {
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "用户名不存在");
- }
- cb();
- })
- }
- U.MD.U.F.phoneCheckSecurityCode = function (r) {
- var _bottom,
- _childs,
- _username = r[2],
- _enterpassword = r[3],
- _el = $(_username).Parent(4)
- ;
-
- if (r) {
-
- U.MD.U.F.findPasswordProcessing(_el, 1);
- _bottom = $(_el.parentNode).Child()[2];
- _childs = $("input", _el);
-
- _bottom.onclick = function () {
- U.MD.U.F.setNewUserPassword(r, _childs[1]);
- };
- }
- else {
-
- U.MD.U.R.setInputStyle(_enterpassword, {
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "账号或者密保错误");
- }
- }
- U.MD.U.F.setNewUserPassword = function (userinfo, phone) {
-
- var _newpassword = userinfo[1].children[1].children[0].children[0].children[0].value;
- var _newpasswordt = userinfo[1].children[1].children[1].children[0].children[0].value;
- if (U.MD.U.F.checkConfirmPassword(_newpassword, _newpasswordt)) {
- U.A.Request(US.USER, ["UpdateUserPasswordByOldPhoneNumber", phone.value, _newpassword],
- U.MD.U.F.asynSetNewUserPassword);
- }
- }
- U.MD.U.F.asynSetNewUserPassword = function (r) {
- if (r.value) {
- U.alert("修改密码成功,请登录");
- U.MD.U.L.login();
- };
- }
- U.MD.U.F.findPasswordByEmail = function (el) {
- var _inputs = $("input", el),
- _username = _inputs[0],
- _email = _inputs[1];
-
- if (U.MD.U.F.checkEmail(_email) && U.MD.U.F.checkUserName(_username)) {
- U.A.Request(US.USER, ["FindPasswordByEmail", _username.value, _email.value], U.MD.U.F.asynFindPasswordByEmail);
- }
- }
- U.MD.U.F.asynFindPasswordByEmail = function (r) {
-
- if (r.value == "2") {
- U.alert("已经发送邮箱,请及时查看密码");
- U.MD.U.L.init();
-
- }
-
- else if (r.value == "0") {
- U.alert("您输入的账号不存在");
- }
-
- else if (r.value == "1") {
- U.alert("邮箱账号不匹配");
- }
- }
- U.MD.U.F.checkEmail = function (inputel) {
- var _email = inputel.value;
-
- if (_email == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "请输入邮箱");
- }
-
- else if (!U.UF.S.Email.test(_email)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right' }, "请输入正确邮箱");
- }
- else {
- return true;
- }
- return false;
- }
- U.MD.U.F.checkPhone = function (inputel) {
- var _password = inputel.value;
-
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "请输入手机号");
- }
-
- else if (!/^1[3|4|5|8][0-9]\d{4,8}$/.test(_password)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right' }, "请输入有效手机号");
- }
- else {
- return true;
- }
- return false;
- }
- U.MD.U.F.checkPass = function (inputel) {
- var _password = inputel.value;
-
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "6-20位字符或数字");
- }
-
- else if (!U.UF.S.PassWord.test(_password)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right' }, "6-20位字符或数字");
- }
- else {
- return true;
- }
- return false;
- }
- U.MD.U.F.Verification = function (inputel) {
- var _code = inputel.value;
-
- if (_code == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "请输入验证码");
- }
-
- else if (!/^\d{4,6}$/.test(_code)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right' }, "请输入4-6位数的验证码");
- }
- else {
- return true;
- }
- return false;
- }
- U.MD.U.F.checkUserName = function (inputel) {
- var _username = inputel.value;
-
- if (_username == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "云端账号");
- }
-
- else if (!U.UF.S.UserName.test(_username)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right' }, "4-14位数字或者字母");
- }
- else {
- return true;
- }
- return false;
- }
- U.MD.U.F.checkConfirmPassword = function (inputo, inputt) {
- var _password = inputt.value;
-
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputt, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "6-20位字符或数字");
- }
-
- else if (!U.UF.S.PassWord.test(_password)) {
- U.MD.U.R.setInputStyle(inputt, { "display": "block", "color": "red", 'textAlign': 'right' }, "6-20位字符或数字");
- }
-
- else if (inputo.value != inputt.value) {
- U.MD.U.R.setInputStyle(inputt, { "display": "block", "color": "red", 'textAlign': 'right' }, "密码不一致");
- }
- else {
- return true;
- }
- return false;
- }
|