整理个人信息界面的接口

pull/65/head
fengshuonan 4 years ago
parent bc09b61a36
commit 891e4e3f94

@ -107,11 +107,22 @@ layui.define(['jquery'], function (exports) {
*
* 此参数组装的是param方式传参的参数如需传递json请用 setJsonData(data)
*
* 如果只传了一个key则key可以是object类型会将object所有属性都set上
*
* @param key 参数的key
* @param value 参数值
*/
set: function (key, value) {
if (typeof key === "object") {
// 遍历object的属性
for (var item in key) {
if (typeof item != "function") {
this.dataObject[item] = key[item];
}
}
} else {
this.dataObject[key] = (typeof value === "undefined") ? $("#" + key).val() : value;
}
return this;
},

@ -1,9 +1,9 @@
layui.use(['form', 'upload', 'element', 'ax', 'laydate'], function () {
layui.use(['form', 'upload', 'element', 'HttpRequest', 'laydate'], function () {
var $ = layui.jquery;
var form = layui.form;
var upload = layui.upload;
var element = layui.element;
var $ax = layui.ax;
var HttpRequest = layui.HttpRequest;
var laydate = layui.laydate;
//渲染时间选择框
@ -12,21 +12,21 @@ layui.use(['form', 'upload', 'element', 'ax', 'laydate'], function () {
});
//获取用户详情
var ajax = new $ax(Feng.ctxPath + "/system/currentUserInfo");
var result = ajax.start();
var request = new HttpRequest(Feng.ctxPath + "/sysUser/currentUserInfo", 'get');
var result = request.start();
//用这个方法必须用在class有layui-form的元素上
form.val('userInfoForm', result.data);
//表单提交事件
form.on('submit(userInfoSubmit)', function (data) {
var ajax = new $ax(Feng.ctxPath + "/mgr/edit", function (data) {
var updateUserInfoRequest = new HttpRequest(Feng.ctxPath + "/sysUser/updateInfo", 'post', function (data) {
Feng.success("修改成功!");
}, function (data) {
Feng.error("修改失败!" + data.responseJSON.message + "!");
}, function (response) {
Feng.error("修改失败!" + response.message + "!");
});
ajax.set(data.field);
ajax.start();
updateUserInfoRequest.set(data.field);
updateUserInfoRequest.start(true);
});
upload.render({
@ -38,13 +38,13 @@ layui.use(['form', 'upload', 'element', 'ax', 'laydate'], function () {
});
}
, done: function (res) {
var ajax = new $ax(Feng.ctxPath + "/system/updateAvatar", function (data) {
var updateAvatarRequest = new HttpRequest(Feng.ctxPath + "/system/updateAvatar", function (data) {
Feng.success(res.message);
}, function (data) {
Feng.error("修改失败!" + data.responseJSON.message + "!");
Feng.error("修改失败!" + data.message + "!");
});
ajax.set("fileId", res.data.fileId);
ajax.start();
updateAvatarRequest.set("fileId", res.data.fileId);
updateAvatarRequest.start();
}
, error: function () {
Feng.error("上传头像失败!");

@ -1,4 +1,4 @@
@layout("/layout/_container.html", {title:"个人中心", css:["/assets/modular/frame/user_info.css"], js:["/assets/modular/frame/user_info.js"]}){
@layout("/layout/_container.html", {title:"个人中心", css:["/assets/modular/frame/user_info.css"], js:["/assets/modular/frame/personal_info.js"]}){
<div class="layui-body-header">
<span class="layui-body-header-title">个人信息</span>
<span class="layui-breadcrumb pull-right">
@ -66,7 +66,7 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">性别:</label>
<label class="layui-form-label">性别:<span style="color: red;">*</span></label>
<div class="layui-input-block">
<input type="radio" name="sex" value="M" title="男">
<input type="radio" name="sex" value="F" title="女">
@ -81,7 +81,7 @@
<div class="layui-form-item">
<label class="layui-form-label">姓名:<span style="color: red;">*</span></label>
<div class="layui-input-block">
<input type="text" name="name" class="layui-input" lay-verify="required" required/>
<input type="text" name="realName" class="layui-input" lay-verify="required" required/>
</div>
</div>
<div class="layui-form-item">

Loading…
Cancel
Save