diff --git a/pages/portfolio/post/_portfolio_id.vue b/pages/portfolio/post/_portfolio_id.vue index 40167ae..c9ef9a4 100644 --- a/pages/portfolio/post/_portfolio_id.vue +++ b/pages/portfolio/post/_portfolio_id.vue @@ -156,7 +156,8 @@ export default { portfolioDescription: '', portfolioDescriptionHtml: '' }, - isLoading: false + isLoading: false, + headImgType: '0' } }, methods: { @@ -195,6 +196,7 @@ export default { reader.readAsDataURL(file); reader.onload = function () { _ts.$set(_ts, 'headImgUrl', this.result); + _ts.$set(_ts, 'headImgType', '1'); // _ts.$refs.cropper?.replace(this.result); } }, @@ -204,7 +206,7 @@ export default { let data = _ts.portfolio; data.portfolioDescription = _ts.$refs.contentEditor.contentValue(); data.portfolioDescriptionHtml = await _ts.$refs.contentEditor.contentHtml(); - data.headImgType = 0; + data.headImgType = _ts.headImgType; data.headImgUrl = _ts.headImgUrl; if ((data.portfolioDescription || undefined) === undefined || (data.portfolioDescriptionHtml || undefined) === undefined) { this.$message.error('请输入必填信息'); @@ -287,6 +289,7 @@ export default { }, reset() { this.headImgUrl = '' + this.$set(this, 'headImgType', '0'); // this.$refs.cropper.clearCrop() }, }, diff --git a/pages/user/settings/avatar.vue b/pages/user/settings/avatar.vue index 1b70746..6367127 100644 --- a/pages/user/settings/avatar.vue +++ b/pages/user/settings/avatar.vue @@ -155,7 +155,7 @@ export default { if (res && res.data && res.data.url) { let user = _ts.user; user.avatarUrl = res.data.url; - user.avatarType = '0'; + user.avatarType = '1'; _ts.$set(_ts, 'user', user); _ts.$set(_ts, 'avatarUrl', res.data.url); } else { @@ -193,7 +193,13 @@ export default { }) }, reset() { - this.avatarUrl = JSON.parse(JSON.stringify(this.oldAvatarUrl)) + let _ts = this; + const avatarUrl = JSON.parse(JSON.stringify(this.oldAvatarUrl)) + let user = _ts.user; + user.avatarUrl = avatarUrl; + user.avatarType = '0'; + _ts.$set(_ts, 'user', user); + _ts.$set(_ts, 'avatarUrl', avatarUrl); // this.$refs.cropper.clearCrop(); }, // get image data for post processing, e.g. upload or setting image src