123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- Namespace.register("U.MD.U.P"); //个人资料设置
- U.MD.U.P.inpEl = {}
- //#region 用户登录个人资料
- //打开个人资料
- 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(); }); //加载城市控件js
- U.UF.DL.asynLoadCss({ "href": "/css/Controls/Basic/City.css", type: "text/css", rel: "stylesheet" }); //加载城市控件css
- $('#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); //绑定文本框的格式
- }
- /**
- * 绑定事件
- * @param elarr {Array} 元素数组
- * @param eventarr {Array} 绑定验证类型
- */
- 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);
- }
- })
- }
- }
- /**
- * 数据重置
- * @param that {string} 标记
- * @param elarr {Array} 是否更改数据
- * @param eventarr {Array} 是否更改数据
- */
- 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');
- }
- }
- /**
- * 数据重置
- * @param mark {string} 标记
- * @param flag {boolean} 是否更改数据
- */
- 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);
- }
- /**
- * 初始化左侧栏数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- 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 = info.LoginAddress.slice(2, 6);*/
- $('.U_MD_U_P_simpleInfo_address')[0].innerText = elobj["address"].value;
- elobj["name"].innerText = info.UserNickName || "";
- elobj["name"].title = info.UserNickName || "";
- }
- /**
- * 初始化个人隐私数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- U.MD.U.P.L_dataPrint.privacy = function (info, elobj) {
- elobj["trueName"].value = info.TrueName;
- elobj["birthday"].value = U.UF.D.getYearMonthDay(info.Birthday);
- }
- /**
- * 初始化基本信息数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- 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;
- }
- /**
- * 初始化账号安全数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- 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("更改个人资料失败");
- }
- })
- }
- /**
- * 设置密码
- * @param elarr {Array} 元素数组
- * @param eventarr {Array} 绑定验证类型
- */
- 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('请输入相同的新密码');
- }
- }
- }
- /**
- * 发送验证码
- * @param flag {boolean} 是否已发送
- */
- 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(); //XMLHttpRequest 对象用于在后台与服务器交换数据
- _xhttp.onreadystatechange = function () {//每当 readyState 属性改变时,就会调用该函数。
- 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); //指定和服务器端交互的HTTP方法,URL地址及其他请求信息
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //向一个打开但未发送的请求设置或添加一个 HTTP 请求
- _xhttp.withCredentials = true; //发送cookie等认证信息到服务端
- _xhttp.send("number=" + _phoneInp.value); //$("#userphone")[0].children[0].children[0].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(); //XMLHttpRequest 对象用于在后台与服务器交换数据
- _xhttp.onreadystatechange = function (r) {//每当 readyState 属性改变时,就会调用该函数
- 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); ////指定和服务器端交互的HTTP方法,URL地址及其他请求信息
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //向一个打开但未发送的请求设置或添加一个 HTTP 请求
- _xhttp.withCredentials = true; //发送cookie等认证信息到服务端
- _xhttp.send("code=" + _input.value);
- }
- /**
- * 设置验证码时间
- * @param inp {elenemt} 元素
- */
- 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);
- }
- /**
- * 重置文本框
- * @param inp {elenemt} 元素
- */
- 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');
- }
- /**
- * 判断元素是否有错误
- * @param inp {elenemt} 元素
- */
- 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');
- }
- /**
- * 判断元素是否为空
- * @param inp {elenemt} 元素
- */
- 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;
- }
- /**
- * 上传头像到服务器处理
- * @param input {ele} 上传图片的input
- */
- U.MD.U.P.uploadUserHeadImg = function (input) {
- //判断是否支持FileReader
- //头像预览
- 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) {
- //获取图片dom
- //图片路径设置为读取的图片
- img.src = e.target.result;
- };
- reader.readAsDataURL(file);
- //上传图片
- U.UF.UP.inputUpload([input], "http://main.1473.cn/USUpfile.ashx?typename=UploadHeadImage", function (url) {
- //console.log(url.value);
- //修改头像
- 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('头像修改失败!');
- }
- });
- }, []);
- }
|