123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- Namespace.register("U.MD.U.P");
- U.MD.U.P.inpEl = {}
- U.MD.U.P.userDataSet = function () {
- U.MD.U.P.L_init()
- }
- U.MD.U.P.L_init = function () {
- if (!U.MD.U.L.isLogin()) {
- var _form = $('#U_MD_U_P_Set'), _personal = $("#U_MD_U_P_Uc_B")[0];
- if (!_form.length) {
- new U.UF.UI.form("<div class='U_MD_F_S_TI'>个人设置</div>", _personal, { "id": "U_MD_U_P_Set", "style": { "width": "664px", "height": "549px" } }, { isenlarge: false, isstretching: false }).form;
- U.MD.U.P.L_eventBind();
- _personal.style.display = 'block';
- } else {
- $('#U_MD_U_P_tab_lable_info')[0].checked = 'checked';
- _form[0].style.display = 'block';
- }
- }
- }
- U.MD.U.P.L_eventBind = function () {
- U.MD.U.P.EL = {
- "headImage": $('#U_MD_U_P_simpleInfo_img')[0],
- "name": $('.U_MD_U_P_simpleInfo_name')[0],
- "nickName": $('#U_MD_U_P_tab_userNickName')[0],
- "selfIntroduction": $('#U_MD_U_P_tab_selfIntroduction')[0],
- "email": $('#U_MD_U_P_tab_email')[0],
- "phoneNumber": $('#U_MD_U_P_tab_phoneNumber')[0],
- "address": $('#U_MD_U_P_tab_address')[0],
- "trueName": $('#U_MD_U_P_tab_trueName')[0],
- "birthday": $('#U_MD_U_P_tab_birthday')[0],
- "loginName": $('#U_MD_U_P_tab_loginName')[0],
- "oldPW": $('#U_MD_U_P_tab_oldPW')[0],
- "newPW": $('#U_MD_U_P_tab_newPW')[0],
- "confirmPW": $('#U_MD_U_P_tab_confirmPW')[0],
- "phone": $('#U_MD_U_P_tab_phone')[0],
- "accountNPW": $('#U_MD_U_P_tab_lable_accountNext_n')[0],
- "accountCPW": $('#U_MD_U_P_tab_lable_accountNext_c')[0]
- };
- var _bindEl = ["nickName", "email", "phoneNumber", "newPW", "confirmPW,newPW", "phone", "accountNPW", "accountCPW,accountNPW"],
- _bindString = ["NickName", "Email", "TelephoneNumber", "PassWord", "contrastPW", "TelephoneNumber", "PassWord", "contrastPW"],
- _lastPage = $('.U_MD_U_P_tab_inp')[0],
- _isDataChanged = false,
- _changeDataNum = "",
- _isNextStep = false;
- U.UF.DL.asynLoadJs({ type: "text/javascript", src: "/js/Controls/Basic/City.js" }, function () { new U.MD.UI.city(); });
- U.UF.DL.asynLoadCss({ "href": "/css/Controls/Basic/City.css", type: "text/css", rel: "stylesheet" });
- $('#U_MD_U_P_tab_address').bind({
- click: function () {
- U.MD.UI.city(this);
- $("#U_MD_UI_city_cityBox")[0].style.display = "block";
- $("#U_MD_UI_city_cityBox")[0].style.zIndex = "999";
- }
- });
- $('#U_MD_U_P_tab_birthday').bind({
- click: function () {
- U.MD.UI.calendar(this, $('#U_MD_U_P_tab_calendar')[0], false);
- }
- })
- $('#U_MD_U_P_save').bind({
- click: function () {
- switch (_lastPage.value) {
- case "0": case "1":
- U.MD.U.P.L_updateUserBasicInfo(_lastPage.value); break;
- case "2":
- if ($('.U_MD_U_P_tab_accountRadio:checked')[0].value == 0) {
- U.MD.U.P.L_setPassword(_bindEl, _bindString);
- } else if ($('.U_MD_U_P_tab_accountRadio:checked')[0].value == 1) {
- U.MD.U.P.L_updatePassword();
- }
- break;
- }
- $('.U_MD_U_P_simpleInfo_address')[0].innerText = $("#U_MD_U_P_tab_address")[0].value;
- }
- })
- $('.U_MD_U_P_tab_inp').bind({
- change: function () {
- U.MD.U.P.L_reset(_changeDataNum, _isDataChanged);
- _lastPage = this;
- _isDataChanged = false;
- }
- })
- $('.U_MD_U_P_tab_lable_content input').bind({
- change: function () {
- if (!_isDataChanged) {
- _changeDataNum = _lastPage.value;
- _isDataChanged = true;
- }
- }
- })
- $('.U_MD_U_P_tab_accountRadio').bind({
- change: function () {
- if (this.value == 0) {
- $('#U_MD_U_P_save')[0].style.display = "inline-block";
- $('#U_MD_U_P_next')[0].style.display = "none";
- } else {
- $('#U_MD_U_P_save')[0].style.display = "none";
- $('#U_MD_U_P_next')[0].style.display = "inline-block";
- }
- }
- })
- $('#U_MD_U_P_authCodeBtn').bind({
- click: function () {
- _isNextStep = U.MD.U.P.L_sendAuthCode(_isNextStep);
- }
- })
- $('#U_MD_U_P_next').bind({
- click: function () {
- U.MD.U.P.L_phoneConfirm();
- }
- })
- $('#U_MD_U_P_authCodeInp').bind({
- change: function () {
- if (this.value.trim().length > 0) {
- $(this).removeClass('U_MD_U_P_tab_user_emptyInp')
- }
- }
- })
- $('#U_MD_U_P_cancel').bind({
- click: function () {
- $('#U_MD_U_P_Set')[0].style.display = 'none';
- }
- })
- $('#U_MD_U_P_tab_oldPW').bind({
- change: function () {
- var _bool = U.MD.U.P.L_checkEmpty(this);
- !_bool && $(this).removeClass('U_MD_U_P_tab_user_emptyInp');
- }
- })
- U.MD.U.P.L_dataPrint();
- U.MD.U.P.L_bindCheckFormat(_bindEl, _bindString);
- }
- U.MD.U.P.L_bindCheckFormat = function (elarr, eventarr) {
- var _len = elarr.length;
- for (var i = 0; i < _len; i++) {
- var _el = U.MD.U.P.EL[elarr[i].split(',')[0]];
- _el.i = i;
- $(_el).bind({
- change: function () {
- U.MD.U.P.L_inpFormatCheck(this, elarr, eventarr);
- }
- })
- }
- }
- U.MD.U.P.L_inpFormatCheck = function (that, elarr, eventarr) {
- var _bool = false;
- if (U.UF.S[eventarr[that.i]]) {
- _bool = U.UF.S[eventarr[that.i]].test(that.value.trim());
- } else if (eventarr[that.i] == 'contrastPW') {
- _bool = (U.MD.U.P.EL[elarr[that.i].split(',')[0]].value === U.MD.U.P.EL[elarr[that.i].split(',')[1]].value);
- }
- if (!_bool) {
- if (!that.value.trim().length) {
- $(that).removeClass('U_MD_U_P_tab_user_errorInp');
- $(that).addClass('U_MD_U_P_tab_user_emptyInp');
- $(that).next().removeClass('U_MD_U_P_tab_errorAlear');
- } else {
- $(that).removeClass('U_MD_U_P_tab_user_emptyInp');
- $(that).addClass('U_MD_U_P_tab_user_errorInp');
- $(that).next().addClass('U_MD_U_P_tab_errorAlear');
- }
- } else {
- $(that).removeClass('U_MD_U_P_tab_user_errorInp');
- $(that).removeClass('U_MD_U_P_tab_user_emptyInp');
- $(that).next().removeClass('U_MD_U_P_tab_errorAlear');
- }
- }
- U.MD.U.P.L_reset = function (mark, flag) {
- if (!flag)
- return;
- var _info = US.userInfo, _elObj = U.MD.U.P.EL;
- switch (mark) {
- case "0":
- U.MD.U.P.L_dataPrint.simpleInfo(_info, _elObj);
- break;
- case "1":
- U.MD.U.P.L_dataPrint.privacy(_info, _elObj);
- break;
- case "2":
- U.MD.U.P.L_dataPrint.account(_info, _elObj);
- break;
- }
- }
- U.MD.U.P.L_dataPrint = function () {
- var _info = US.userInfo, _elObj = U.MD.U.P.EL;
- U.MD.U.P.L_dataPrint.privacy(_info, _elObj);
- U.MD.U.P.L_dataPrint.simpleInfo(_info, _elObj);
- U.MD.U.P.L_dataPrint.account(_info, _elObj);
- U.MD.U.P.L_dataPrint.left(_info, _elObj);
- }
- U.MD.U.P.L_dataPrint.left = function (info, elobj) {
- elobj["headImage"].src = U.MD.C.getHeadImage(info.UserImageHead);
-
- $('.U_MD_U_P_simpleInfo_address')[0].innerText = elobj["address"].value;
- elobj["name"].innerText = info.UserNickName || "";
- elobj["name"].title = info.UserNickName || "";
- }
- U.MD.U.P.L_dataPrint.privacy = function (info, elobj) {
- elobj["trueName"].value = info.TrueName;
- elobj["birthday"].value = U.UF.D.getYearMonthDay(info.Birthday);
- }
- U.MD.U.P.L_dataPrint.simpleInfo = function (info, elobj) {
- $(".U_MD_U_P_tab_user_radio[value$=" + (info.UserSex ? "'1'" : "'0'") + "]")[0].checked = true;
- elobj["selfIntroduction"].value = info.UserIndividualitysignature;
- elobj["address"].innerText = info.Province || "";
- elobj["nickName"].value = info.UserNickName || "";
- elobj["email"].value = info.UserEmail;
- elobj["phoneNumber"].value = info.UserTelephoneNumber;
- elobj["address"].value = info.City;
- elobj["loginName"].innerText = info.UserName;
- }
- U.MD.U.P.L_dataPrint.account = function (info, elobj) {
- $('#U_MD_U_P_tab_lable_accountNext_t')[0].innerText = info.UserName;
- $('.U_MD_U_P_tab_lable_account').css('display', 'block');
- $('.U_MD_U_P_tab_lable_accountNext').css('display', 'none');
- $('.U_MD_U_P_tab_accountRadio')[0].checked = "checked";
- var _arr = Array.prototype.slice.call($('.U_MD_U_P_tab_item')[2].querySelectorAll('[type="text"]')).concat(Array.prototype.slice.call($('.U_MD_U_P_tab_item')[2].querySelectorAll('[type="password"]')));
- for (var i = 0; i < _arr.length; i++) {
- _arr[i].value = "";
- $(_arr[i]).removeClass('U_MD_U_P_tab_user_errorInp');
- $(_arr[i]).removeClass('U_MD_U_P_tab_user_emptyInp');
- $(_arr[i]).next().removeClass('U_MD_U_P_tab_errorAlear');
- }
- $('#U_MD_U_P_save').css('display', 'inline-block');
- $('#U_MD_U_P_next').css('display', 'none');
- }
- U.MD.U.P.L_updateUserBasicInfo = function (type) {
- var _info = US.userInfo, _elObj = U.MD.U.P.EL, _sex = parseInt($('.U_MD_U_P_tab_user_radio:checked')[0].value);
- if (!parseInt(type)) {
- var _bool = U.MD.U.P.L_checkEmpty(_elObj['nickName']) || U.MD.U.P.L_checkEmpty(_elObj['email']) || U.MD.U.P.L_checkEmpty(_elObj['phoneNumber']) || U.MD.U.P.L_checkEmpty(_elObj['address']);
- if ($('.U_MD_U_P_tab_user_errorInp').length || $('.U_MD_U_P_tab_user_emptyInp').length || _bool) {
- if ($(".U_MD_U_P_tab_user_errorInp")[0].id == "U_MD_U_P_tab_email" && $(".U_MD_U_P_tab_user_errorInp").length == 1) {
- U.Alert("邮箱填写错误!");
- return;
- } else if ($(".U_MD_U_P_tab_user_errorInp")[0].id == "U_MD_U_P_tab_phoneNumber" && $(".U_MD_U_P_tab_user_errorInp").length == 1) {
- U.Alert("手机号码填写错误!");
- return;
- } else {
- U.Alert("信息录入错误!");
- return;
- }
- }
- }
- U.A.Request(US.USER, ["UpdateUserBasicInfo", _info.UserId, _elObj["trueName"].value, _elObj["nickName"].value, _elObj["phoneNumber"].value, '', '', _elObj["selfIntroduction"].value, _sex, _elObj["email"].value,
- "中国", _elObj["address"].textContent, _elObj["address"].value || "", _elObj["birthday"].value],
- function (r) {
- if (r.value) {
- US.userInfo.UserSex = _sex ? true : false;
- US.userInfo.TrueName = _elObj["trueName"].value;
- US.userInfo.UserNickName = _elObj["nickName"].value;
- US.userInfo.UserTelephoneNumber = _elObj["phoneNumber"].value;
- US.userInfo.UserIndividualitysignature = _elObj["selfIntroduction"].value;
- US.userInfo.UserEmail = _elObj["email"];
- US.userInfo.Province = _elObj["address"].value;
- US.userInfo.City = _elObj["address"].value;
- U.Alert("更改个人资料成功");
- }
- else {
- U.alert("更改个人资料失败");
- }
- })
- }
- U.MD.U.P.L_setPassword = function (elarr, eventarr) {
- var _elObj = U.MD.U.P.EL,
- _emptyEl = $($('.U_MD_U_P_tab_lable_content')[2]).find('.U_MD_U_P_tab_user_emptyInp'),
- _errorEl = $($('.U_MD_U_P_tab_lable_content')[2]).find('.U_MD_U_P_tab_user_errorInp');
- if (!_emptyEl.length && !_errorEl.length) {
- if (_elObj["oldPW"].value == "") {
- U.MD.U.P.L_inpFormatCheck(_elObj["oldPW"], elarr, eventarr);
- return;
- } else if (_elObj["newPW"].value == "") {
- U.MD.U.P.L_inpFormatCheck(_elObj["newPW"], elarr, eventarr);
- return;
- } else if (_elObj["confirmPW"].value == "") {
- U.MD.U.P.L_inpFormatCheck(_elObj["confirmPW"], elarr, eventarr);
- return;
- }
- U.A.Request(US.USER, ["UpdateUserPasswordByOldPassword", US.userInfo.userid, _elObj["oldPW"].value, _elObj["confirmPW"].value], function (r) {
- if (r.value) {
- U.Alert("更改密码成功,请重新登录");
- U.MD.U.LO.logout();
- U.MD.U.L.login();
- } else {
- U.Alert("原密码错误");
- $(_elObj["oldPW"]).addClass("U_MD_U_P_tab_user_emptyInp");
- }
- });
- }
- }
- U.MD.U.P.L_updatePassword = function () {
- var _pw = $('#U_MD_U_P_tab_lable_accountNext_n')[0];
- var _pwconfirm = $('#U_MD_U_P_tab_lable_accountNext_c')[0];
- if (U.MD.U.P.inputFormat(_pw, false, 'PassWord') && U.MD.U.P.inputFormat(_pwconfirm, false, 'PassWord')) {
- if (_pwconfirm.value == _pw.value) {
- U.A.Request(US.USER, ["UpdateUserPassword", US.userInfo.userid, _pw.value], function (r) {
- if (r.value) {
- U.Alert('更改密码成功');
- }
- else {
- U.Alert('更改密码失败');
- }
- });
- } else {
- U.Alert('请输入相同的新密码');
- }
- }
- }
- U.MD.U.P.L_sendAuthCode = function (flag) {
- if (flag) {
- U.Aleart('请在60秒后重试');
- return;
- }
- var _phoneInp = U.MD.U.P.EL["phone"],
- _bool = U.MD.U.P.L_checkEmpty(_phoneInp) || U.MD.U.P.L_isCanUse(_phoneInp);
- if (_bool) {
- U.Alert('信息录入错误!');
- return;
- }
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserName", US.userInfo.username], function (r) {
- if (r.value[0].UserTelephoneNumber != _phoneInp.value) {
- U.Alert('输入的手机号与账号不匹配');
- } else {
- var _xhttp = new XMLHttpRequest();
- _xhttp.onreadystatechange = function () {
- if (this.readyState == 4) {
- if (this.status == 201) {
- U.Alert('发送成功');
- U.MD.U.P.L_setTime($('#U_MD_U_P_authCodeBtn')[0]);
- return true;
- } 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=" + _phoneInp.value);
- }
- });
- }
- U.MD.U.P.L_phoneConfirm = function () {
- var _input = $('#U_MD_U_P_authCodeInp')[0];
- if (U.MD.U.P.L_checkEmpty(_input)) {
- U.Alert('验证码不为空');
- return;
- }
- var _xhttp = new XMLHttpRequest();
- _xhttp.onreadystatechange = function (r) {
- if (this.readyState == 4) {
- if (this.status == 201) {
- $('#U_MD_U_P_save').css('display', 'inline-block');
- $('#U_MD_U_P_next').css('display', 'none');
- $('.U_MD_U_P_tab_lable_account').css('display', 'none');
- $('.U_MD_U_P_tab_lable_accountNext').css('display', 'block');
- 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=" + _input.value);
- }
- U.MD.U.P.L_setTime = function (inp) {
- if (this._timer) {
- U.Alert('请在60后重试!');
- return;
- }
- var _second = 60,
- _this = this;
- this._timer = setInterval(function () {
- inp.innerText = --_second + 's';
- if (!_second) {
- inp.innerText = '发送验证码';
- clearInterval(_this._timer);
- _this._timer = null;
- }
- }, 1000);
- }
- U.MD.U.P.L_restoreInp = function (el) {
- el.value = "";
- $(el).removeClass('U_MD_U_P_tab_user_errorInp');
- $(el).removeClass('U_MD_U_P_tab_user_emptyInp');
- }
- U.MD.U.P.L_isCanUse = function (el) {
- return $(el).hasClass('U_MD_U_P_tab_user_emptyInp') || $(el).hasClass('U_MD_U_P_tab_user_errorInp');
- }
- U.MD.U.P.L_checkEmpty = function (el) {
- if (el.value.trim() == "" || !!!el.value) {
- $(el).addClass('U_MD_U_P_tab_user_emptyInp');
- return true;
- }
- return false;
- }
- U.MD.U.P.uploadUserHeadImg = function (input) {
-
-
- if (window.FileReader) {
- var reader = new FileReader();
- } else {
- U.alert("您的设备不支持图片预览功能,如需该功能请升级您的设备!");
- }
-
- var file = input.files[0];
- var imageType = /^image\//;
-
- if (!imageType.test(file.type)) {
- U.alert("请选择图片!");
- return;
- }
- var img = $('#U_MD_U_P_simpleInfo_img')[0];
-
- reader.onload = function (e) {
-
-
- img.src = e.target.result;
- };
- reader.readAsDataURL(file);
-
- U.UF.UP.inputUpload([input], "http://main.1473.cn/USUpfile.ashx?typename=UploadHeadImage", function (url) {
-
-
- U.A.Request(US.USER, ["UpdateUserHeaderImage", US.userInfo.userid, url.value.UserFilesServerName, url.value.UseFilesServerThumbnailName], function (r) {
- if (r.value) {
-
- US.userInfo.UserImageHead = url.value.UserFilesServerName;
- US.userInfo.UserThumbnailImageHead = url.value.UseFilesServerThumbnailName;
- U.Alert('头像修改成功!');
- } else {
- U.Alert('头像修改失败!');
- }
- });
- }, []);
- }
|