Merge pull request 'dengjie' (#69) from dengjie into dev

Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/69
This commit is contained in:
odjbin
2023-01-30 15:15:34 +00:00

View File

@@ -34,6 +34,7 @@
data() { data() {
return { return {
avatar: '', avatar: '',
avatarUrl: '',
model: { model: {
userInfo: { userInfo: {
name: '' name: ''
@@ -57,7 +58,7 @@
//获取头像昵称 //获取头像昵称
getUser() { getUser() {
this.$apiServe.getUser().then(res => { this.$apiServe.getUser().then(res => {
console.log('头像昵称', res.data); // console.log('头像昵称', res.data);
var data = res.data.data var data = res.data.data
this.avatar = data.avatar this.avatar = data.avatar
this.model.userInfo.name = data.nickname this.model.userInfo.name = data.nickname
@@ -77,7 +78,7 @@
success: (res) => { success: (res) => {
console.log('上传头像', JSON.parse(res.data)); console.log('上传头像', JSON.parse(res.data));
// setTimeout(() => { // setTimeout(() => {
resolve(JSON.parse(res.data).data.uri) resolve(JSON.parse(res.data).data.url)
// }, 1000) // }, 1000)
} }
}); });
@@ -90,24 +91,22 @@
sizeType: ['original', 'compressed'], //original 原图compressed 压缩图,默认二者都有 sizeType: ['original', 'compressed'], //original 原图compressed 压缩图,默认二者都有
success: (res) => { success: (res) => {
// console.log(res.tempFilePaths[0]); //成功则返回图片的本地文件路径列表 tempFilePaths // console.log(res.tempFilePaths[0]); //成功则返回图片的本地文件路径列表 tempFilePaths
// this.avatar = res.tempFilePaths[0] //更新本地浏览头像图片 this.avatar = res.tempFilePaths[0] //更新本地浏览头像图片
if (res.tempFilePaths[0]) { if (res.tempFilePaths[0]) {
this.updatePromise(res.tempFilePaths[0]) //上传图片 const result = this.updatePromise(res.tempFilePaths[0]) //上传图片
result.then(value => {
this.avatarUrl = '/' + value
console.log(this.avatarUrl);
})
} }
const result = this.updatePromise(res.tempFilePaths[0])
result.then(value => {
this.avatar = value
})
} }
}); });
}, },
//提交头像和昵称 //提交头像和昵称
handleSubmit() { handleSubmit() {
console.log('昵称', this.model.userInfo.name);
console.log('头像', this.avatar);
this.$apiServe.updateUser({ this.$apiServe.updateUser({
nickname: this.model.userInfo.name, nickname: this.model.userInfo.name,
avatar: this.avatar avatar: this.avatarUrl
}).then(res => { }).then(res => {
console.log('修改头像昵称==', res); console.log('修改头像昵称==', res);
this.$toast.success(res.data.msg) this.$toast.success(res.data.msg)