show current profile in user profile page
This commit is contained in:
@@ -72,6 +72,9 @@ export default {
|
|||||||
refreshToken: () => {
|
refreshToken: () => {
|
||||||
return axios.post('v1/tokens/refresh.json');
|
return axios.post('v1/tokens/refresh.json');
|
||||||
},
|
},
|
||||||
|
getProfile: () => {
|
||||||
|
return axios.get('v1/users/profile/get.json');
|
||||||
|
},
|
||||||
updateProfile: ({ email, nickname, password }) => {
|
updateProfile: ({ email, nickname, password }) => {
|
||||||
return axios.post('v1/users/profile/update.json', {
|
return axios.post('v1/users/profile/update.json', {
|
||||||
email,
|
email,
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ export default {
|
|||||||
'You have been successfully registered': 'You have been successfully registered',
|
'You have been successfully registered': 'You have been successfully registered',
|
||||||
'Unable to sign up': 'Unable to sign up',
|
'Unable to sign up': 'Unable to sign up',
|
||||||
'User registration is disabled': 'User registration is disabled',
|
'User registration is disabled': 'User registration is disabled',
|
||||||
|
'Unable to get user profile': 'Unable to get user profile',
|
||||||
'Nothing has been modified': 'Nothing has been modified',
|
'Nothing has been modified': 'Nothing has been modified',
|
||||||
'Your profile has been successfully updated': 'Your profile has been successfully updated',
|
'Your profile has been successfully updated': 'Your profile has been successfully updated',
|
||||||
'Unable to update user profile': 'Unable to update user profile',
|
'Unable to update user profile': 'Unable to update user profile',
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ export default {
|
|||||||
'You have been successfully registered': '注册成功',
|
'You have been successfully registered': '注册成功',
|
||||||
'Unable to sign up': '无法注册',
|
'Unable to sign up': '无法注册',
|
||||||
'User registration is disabled': '用户注册已禁用',
|
'User registration is disabled': '用户注册已禁用',
|
||||||
|
'Unable to get user profile': '无法获取用户信息',
|
||||||
'Nothing has been modified': '没有修改的项目',
|
'Nothing has been modified': '没有修改的项目',
|
||||||
'Your profile has been successfully updated': '您的用户信息更新成功',
|
'Your profile has been successfully updated': '您的用户信息更新成功',
|
||||||
'Unable to update user profile': '无法更新用户信息',
|
'Unable to update user profile': '无法更新用户信息',
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ export default {
|
|||||||
inputIsNotChangedProblemMessage() {
|
inputIsNotChangedProblemMessage() {
|
||||||
if (!this.password && !this.confirmPassword && !this.email && !this.nickname) {
|
if (!this.password && !this.confirmPassword && !this.email && !this.nickname) {
|
||||||
return 'Nothing has been modified';
|
return 'Nothing has been modified';
|
||||||
|
} else if (!this.password && !this.confirmPassword && this.email === this.oldEmail && this.nickname === this.oldNickname) {
|
||||||
|
return 'Nothing has been modified';
|
||||||
} else if (!this.password && this.confirmPassword) {
|
} else if (!this.password && this.confirmPassword) {
|
||||||
return 'Password cannot be empty';
|
return 'Password cannot be empty';
|
||||||
} else if (this.password && !this.confirmPassword) {
|
} else if (this.password && !this.confirmPassword) {
|
||||||
@@ -83,6 +85,43 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
const self = this;
|
||||||
|
const app = self.$f7;
|
||||||
|
const router = self.$f7router;
|
||||||
|
|
||||||
|
app.preloader.show();
|
||||||
|
|
||||||
|
self.$services.getProfile().then(response => {
|
||||||
|
app.preloader.hide();
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
if (!data || !data.success || !data.result) {
|
||||||
|
self.$alert('Unable to get user profile', () => {
|
||||||
|
router.back();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.oldEmail = data.result.email;
|
||||||
|
self.oldNickname = data.result.nickname;
|
||||||
|
|
||||||
|
self.email = self.oldEmail
|
||||||
|
self.nickname = self.oldNickname;
|
||||||
|
}).catch(error => {
|
||||||
|
app.preloader.hide();
|
||||||
|
|
||||||
|
if (error.response && error.response.data && error.response.data.errorMessage) {
|
||||||
|
self.$alert({ error: error.response.data }, () => {
|
||||||
|
router.back();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
self.$alert('Unable to get user profile', () => {
|
||||||
|
router.back();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
update() {
|
update() {
|
||||||
const self = this;
|
const self = this;
|
||||||
@@ -127,7 +166,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.$toast('Your profile has been successfully updated');
|
self.$toast('Your profile has been successfully updated');
|
||||||
router.back();
|
router.back('/settings', { force: true });
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
hasResponse = true;
|
hasResponse = true;
|
||||||
app.preloader.hide();
|
app.preloader.hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user