ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 个人中心——资料修改 * * * * * ### win页面 > 代码如下 ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/> <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"> <link rel="stylesheet" type="text/css" href="../../css/aui-win.css" /> <style type="text/css"> </style> </head> <body> <header class="aui-bar aui-bar-nav aui-bar-info" id="aui-header"> <a class="aui-btn aui-btn-info aui-pull-left" tapmode onclick="closeWin()"> <span class="aui-iconfont aui-icon-left"></span> </a> <div class="aui-title">资料修改</div> <a class="aui-iconfont aui-icon-menu aui-pull-right"></a> </header> </body> <script type="text/javascript" src="../../script/api.js"></script> <script type="text/javascript"> apiready = function(){ api.parseTapmode(); var header = $api.byId('aui-header'); $api.fixStatusBar(header); var headerPos = $api.offset(header); var body_h = $api.offset($api.dom('body')).h; api.openFrame({ name: 'myalter_frm', url: 'myalter_frm.html', bounces: false, rect: { x: 0, y: headerPos.h, w: 'auto', h: 'auto' } }) }; function closeWin(){ api.closeWin(); } </script> </html> ~~~ ### frame页面 > 代码如下 ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/> <meta name="format-detection" content="telephone=no,email=no,date=no,demand=no"> <title>资料修改</title> <link rel="stylesheet" type="text/css" href="../../css/aui.css"/> <style> body { height: auto; } .aui-card { margin-top: 15px; } .aui-badge { background-color: transparent; color: #666; font-size: 14px; } .aui-input-row .check { padding: 8px; color: #f1c40f; } .avatar { margin-top: 13px; } .content { position: absolute; top: 50%; right: 30px; -webkit-transform: translateY(-50%); transform: translateY(-50%); display: inline-block; padding: 3px 6px; font-size: 16px; line-height: 1; color: #333; border-radius: 100px; } .check { margin-top: 8px; } </style> </head> <body> <div class="aui-content aui-card aui-noborder"> <ul class="aui-user-view my_info"> <li class="aui-user-view-cell aui-img" tapmode onclick="UpdateAvatar()"> <img class="aui-img-object aui-pull-right" id='avatarImg' src="../../image/demo1.png" style=" margin-right: 27px"> <div class="aui-img-body aui-arrow-right"> <h2 class='avatar'>头像</h2> </div> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateName()"> <a class="aui-arrow-right"> 姓名 <span class="content" id="nicename"></span> </a> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateSchool()"> <a class="aui-arrow-right"> 学校 <span class="content" id='school'></span></a> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateMajor()"> <a class="aui-arrow-right"> 专业<span class="content" id="major"></span></a> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateEquipment()"> <a class="aui-arrow-right"> 设备 <span class="content" id="equipment" ></span> </a> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateSpeciality()"> <a class="aui-arrow-right">特长 <span class="content" id="speciality"></span></a> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateTerritory()"> <a class="aui-arrow-right"> 研究领域 <span class="content" id='territory'></span> </a> </li> <li class="aui-list-view-cell" tapmode onclick="UpdateDetai_demand()"> <a class="aui-arrow-right"> 项目要求 <span class="content" id="demand"></span> </a> </li> </ul> </div> </body> <script type="text/javascript" src="../../script/api.js"></script> <script type="text/javascript"> //定义变量 var territory; //研究领域 var demand; //项目要求 var nicename; //姓名 var school; //学校 var major; //专业 var speciality; //特长 apiready = function() { api.parseTapmode(); nicename = $api.byId('nicename'); school = $api.byId('school'); major = $api.byId('major'); equipment = $api.byId('equipment'); speciality = $api.byId('speciality'); territory = $api.byId('territory'); demand = $api.byId('demand'); user = $api.getStorage('user'); } //上传数据 function UpdateData(field, value) { var uid = $api.getStorage('user').id; api.ajax({ url : 'http://www.sytest.com.cn/index.php?g=Osapp&m=My&a=update_PerInfo', method : 'post', cache : false, timeout : 30, dataType : 'json', data : { values : { uid : uid, value : value, field : field, } } }, function(ret, err) { if(ret){ if (ret.msg == 1) { api.toast({ msg : '修改成功!' }); }else{ api.toast({ msg:'修改不成功!' }); } }else{ api.alert({ msg : ('错误码:' + err.code + '错误信息:' + err.msg + '网络状态码:' + err.statusCode) }); return; } }); } //更换头像 function UpdateAvatar() { api.actionSheet({ cancleTitle : '取消', buttons : ['拍照', '打开相册'] }, function(ret, err) { if (ret.buttonIndex == 3) { return; } var sourceType = (ret.buttonIndex == 1) ? 'camera' : 'album'; api.getPicture({ sourceType : sourceType, destinationType:'url', allowEdit : true, quality : 70, targetWidth : 100, targetHeight : 100 }, function(ret, err) { if (ret.data) { var img=ret.data; var uid=$api.getStorage('user').id; api.ajax({ url : 'http://www.sytest.com.cn/index.php?g=App&m=My&a=updateAvatar', method : 'post', cache : false, timeout : 30, dataType : 'json', data : { files : {upfile : ret.data}, values:{uid:uid} } }, function(ret, err) { if (ret.msg==1) { $api.attr($api.byId("avatarImg"), 'src', img); var user = $api.getStorage('user'); user.avatar = img; $api.setStorage('user', user); } else { alert('上传失败'); } }); }else{ alert($api.jsonToStr(err)); } }); }); } // 更改姓名 function UpdateName() { api.prompt({ title : '输入姓名 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_nicename'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } //更改学校 function UpdateSchool() { api.prompt({ title : '输入学校名称 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_school'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } //更改专业 function UpdateMajor() { api.prompt({ title : '输入专业名称 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_major'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } //更改特长 function UpdateSpeciality() { api.prompt({ title : '输入特长 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_speciality'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } //更改设备 function UpdateEquipment() { api.prompt({ title : '输入设备名称 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_equipment'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } //更改研究领域 function UpdateTerritory() { api.prompt({ title : '输入研究领域 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_territory'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } //更改项目要求 function UpdateDetai_demand() { api.prompt({ title : '输入项目要求 ', buttons : ['确定', '取消'] }, function(ret, err) { if (ret.buttonIndex == 1) { var value = ret.text; //内容 var field = 'user_demand'; //字段名 UpdateData(field, value); nicename.innerHTML = value; var user = $api.getStorage('user'); user.user_nicename = value; $api.setStorage('user', user); } }); } </script> </html> ~~~ * * * * * > 效果如下 ![](https://box.kancloud.cn/2016-08-30_57c4e3ec73e12.PNG)