Commit 0688d1ef by 陈超

T

parent 343fadd5
...@@ -284,6 +284,7 @@ ...@@ -284,6 +284,7 @@
show: false, show: false,
innerShow: false, innerShow: false,
value: "", value: "",
savedUrl: "",
currentAvatar: "{:getUserFace($user['uid'],'b')}", currentAvatar: "{:getUserFace($user['uid'],'b')}",
currentNickName: "{:getUserName($user['uid'])}", currentNickName: "{:getUserName($user['uid'])}",
currentGender: "{$user['sex'] ==1 ? 男 : 女}" currentGender: "{$user['sex'] ==1 ? 男 : 女}"
...@@ -300,17 +301,44 @@ ...@@ -300,17 +301,44 @@
ui.error('昵称仅支持中英文、数字、下划线') ui.error('昵称仅支持中英文、数字、下划线')
return return
} }
$.post(U('home/User/saveUser'), {
if(that.savedUrl.length > 0) {
that.saveAvatar(this.saveInfo)
} else {
that.saveInfo()
}
},
saveInfo: function() {
$.post(U('home/User/saveUser'), {
uname: this.currentNickName
}, function(data) { }, function(data) {
if (data.status) { if (data.status) {
ui.success('基本信息更改成功') ui.success('基本信息更改成功')
setTimeout('window.location.reload();', 2000)
} else { } else {
ui.error(data.info) ui.error(data.info)
} }
}, 'json') }, 'json')
}, },
saveAvatar: function(call) {
let that = this
$.ajax({
type: "POST",
url: "{:U('basic/Account/doSaveAvatar',array('step'=>'save'))}",
data: "picurl=" + that.savedUrl + "&picwidth=" + 300 + "&x1=" + 300 + "&y1=" + 300 + "&x2=" + 300 + "&y2=" + 300 + "&w=" + 300 + "&h=" + 300,
async: false,
dataType: "text",
success: function (data) {
if (data) {
call && call()
} else {
ui.error('头像修改失败');
}
}
})
},
onRead: function(r) { onRead: function(r) {
let that = this let that = this
let formData = new FormData() let formData = new FormData()
...@@ -325,6 +353,7 @@ ...@@ -325,6 +353,7 @@
success: function(res) { success: function(res) {
let result = JSON.parse(res) let result = JSON.parse(res)
if(result.status == 1) { if(result.status == 1) {
that.savedUrl = result.data.save_path + result.data.save_name
that.currentAvatar = result.data.src that.currentAvatar = result.data.src
} else { } else {
ui.error('上传失败') ui.error('上传失败')
...@@ -343,7 +372,8 @@ ...@@ -343,7 +372,8 @@
this.innerShow = true this.innerShow = true
}, },
onChooseGender: function(id) { onChooseGender: function(id) {
this.currentGender = id == 1 ? '男' : '女' this.currentGender = id == 1 ? '男' : '女',
this.innerShow = false
}, },
onGenderCancel: function() { onGenderCancel: function() {
this.innerShow = false this.innerShow = false
...@@ -351,16 +381,16 @@ ...@@ -351,16 +381,16 @@
onAddress: function() { onAddress: function() {
}, },
onError: function() {
},
onEditConfirm: function() { onEditConfirm: function() {
this.currentNickName = this.value this.currentNickName = this.value
this.show = false this.show = false
}, },
onPopupClose: function() { onPopupClose: function() {
} },
onError: function() {
},
} }
}) })
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment