Commit 0688d1ef by 陈超

T

parent 343fadd5
......@@ -284,6 +284,7 @@
show: false,
innerShow: false,
value: "",
savedUrl: "",
currentAvatar: "{:getUserFace($user['uid'],'b')}",
currentNickName: "{:getUserName($user['uid'])}",
currentGender: "{$user['sex'] ==1 ? 男 : 女}"
......@@ -299,18 +300,45 @@
if (!/^[\u4E00-\u9FA5\w]{1,}$/.test(that.currentNickName)) {
ui.error('昵称仅支持中英文、数字、下划线')
return
}
if(that.savedUrl.length > 0) {
that.saveAvatar(this.saveInfo)
} else {
that.saveInfo()
}
},
saveInfo: function() {
$.post(U('home/User/saveUser'), {
}, function(data) {
if (data.status) {
ui.success('基本信息更改成功')
setTimeout('window.location.reload();', 2000)
} else {
ui.error(data.info)
}
}, 'json')
},
uname: this.currentNickName
}, function(data) {
if (data.status) {
ui.success('基本信息更改成功')
} else {
ui.error(data.info)
}
}, '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) {
let that = this
let formData = new FormData()
......@@ -325,6 +353,7 @@
success: function(res) {
let result = JSON.parse(res)
if(result.status == 1) {
that.savedUrl = result.data.save_path + result.data.save_name
that.currentAvatar = result.data.src
} else {
ui.error('上传失败')
......@@ -334,7 +363,7 @@
ui.error('上传失败')
}
})
},
},
onNickName: function() {
this.value = this.currentNickName
this.show = true
......@@ -343,7 +372,8 @@
this.innerShow = true
},
onChooseGender: function(id) {
this.currentGender = id == 1 ? '男' : '女'
this.currentGender = id == 1 ? '男' : '女',
this.innerShow = false
},
onGenderCancel: function() {
this.innerShow = false
......@@ -351,16 +381,16 @@
onAddress: function() {
},
onError: function() {
},
onEditConfirm: function() {
this.currentNickName = this.value
this.show = false
},
onPopupClose: function() {
}
},
onError: function() {
},
}
})
</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