diff --git a/JC-Salon-WeChat/pages/profile-edit/index.js b/JC-Salon-WeChat/pages/profile-edit/index.js
index daec287b..5e337023 100644
--- a/JC-Salon-WeChat/pages/profile-edit/index.js
+++ b/JC-Salon-WeChat/pages/profile-edit/index.js
@@ -48,9 +48,12 @@ Page({
const app = getApp()
const state = buildPageState(app.globalData.userInfo || {}, app.globalData.shopName || BRAND_CONFIG.defaultShopName)
this.setData(state)
+ this.loadProfile()
},
onShow() {
+ if (!this._refreshAfterAccountSettings) return
+ this._refreshAfterAccountSettings = false
this.loadProfile()
},
@@ -107,22 +110,30 @@ Page({
},
goAccountSettings() {
- wx.navigateTo({ url: '/pages/account-settings/index' })
+ this._refreshAfterAccountSettings = true
+ wx.navigateTo({
+ url: '/pages/account-settings/index',
+ fail: () => { this._refreshAfterAccountSettings = false }
+ })
},
async uploadAvatar(filePath) {
if (!filePath) return
- this.setData({ avatarUploading: true })
+ const previousAvatar = this.data.form.avatar
+ this.setData({ avatarUploading: true, 'form.avatar': filePath })
try {
const avatar = await uploadProfileImage(filePath)
this.setData({ 'form.avatar': avatar })
+ } catch (error) {
+ this.setData({ 'form.avatar': previousAvatar })
+ throw error
} finally {
this.setData({ avatarUploading: false })
}
},
async chooseAvatar() {
- if (this.data.avatarUploading || this.data.saving) return
+ if (this.data.loading || this.data.avatarUploading || this.data.saving) return
try {
const filePath = await chooseImageFilePath()
if (!filePath) return
@@ -133,7 +144,7 @@ Page({
},
async chooseWechatAvatar(event) {
- if (this.data.avatarUploading || this.data.saving) return
+ if (this.data.loading || this.data.avatarUploading || this.data.saving) return
try {
await this.uploadAvatar(event.detail && event.detail.avatarUrl)
} catch (error) {
diff --git a/JC-Salon-WeChat/pages/profile-edit/index.wxml b/JC-Salon-WeChat/pages/profile-edit/index.wxml
index 774ebb12..9cd7da6b 100644
--- a/JC-Salon-WeChat/pages/profile-edit/index.wxml
+++ b/JC-Salon-WeChat/pages/profile-edit/index.wxml
@@ -20,7 +20,7 @@
›
-