|
@@ -44,7 +44,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<!-- 提交按钮 -->
|
|
<!-- 提交按钮 -->
|
|
|
- <view class="btn">
|
|
|
|
|
|
|
+ <view class="btn" style="padding: 60rpx 0;">
|
|
|
<u-button type="primary" shape="circle" :loading="submitting" @click="submitChanges">提交</u-button>
|
|
<u-button type="primary" shape="circle" :loading="submitting" @click="submitChanges">提交</u-button>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -93,7 +93,6 @@ export default {
|
|
|
// 昵称输入
|
|
// 昵称输入
|
|
|
onNicknameInput(e) {
|
|
onNicknameInput(e) {
|
|
|
this.userInfo.nickName = e.detail.value
|
|
this.userInfo.nickName = e.detail.value
|
|
|
- this.updateUserInfo()
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 选择并上传头像
|
|
// 选择并上传头像
|
|
@@ -117,13 +116,10 @@ export default {
|
|
|
this.userInfo.imgPath = uploadRes.data
|
|
this.userInfo.imgPath = uploadRes.data
|
|
|
uni.$u.toast('头像上传成功')
|
|
uni.$u.toast('头像上传成功')
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ this.uploading = false
|
|
|
|
|
+ uni.hideLoading()
|
|
|
throw new Error(uploadRes.msg || '上传失败')
|
|
throw new Error(uploadRes.msg || '上传失败')
|
|
|
}
|
|
}
|
|
|
- } catch (error) {
|
|
|
|
|
- uni.$u.toast('头像上传失败,请重试')
|
|
|
|
|
-
|
|
|
|
|
- // 还原头像
|
|
|
|
|
- this.userInfo.imgPath = this.originalInfo.imgPath
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
this.uploading = false
|
|
this.uploading = false
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
@@ -156,13 +152,6 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 跳转换绑手机号页面
|
|
|
|
|
- goToChangeMobile() {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages-mine/pages/change-mobile/index'
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
// 获取手机号
|
|
// 获取手机号
|
|
|
async getPhoneNumber(e) {
|
|
async getPhoneNumber(e) {
|
|
|
if (e.detail.errMsg !== 'getPhoneNumber:ok') {
|
|
if (e.detail.errMsg !== 'getPhoneNumber:ok') {
|
|
@@ -175,7 +164,9 @@ export default {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 调用后端接口解密手机号
|
|
// 调用后端接口解密手机号
|
|
|
- uni.$u.http.post('/token/user/wxMobileUpdate', { code: e.detail.code }).then(res => {
|
|
|
|
|
|
|
+ uni.$u.http.post('/token/user/wxMobileUpdate', {
|
|
|
|
|
+ code: e.detail.code
|
|
|
|
|
+ }).then(res => {
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
// 更新本地用户信息
|
|
// 更新本地用户信息
|
|
|
this.userInfo.mobile = res.data.mobile
|
|
this.userInfo.mobile = res.data.mobile
|
|
@@ -196,58 +187,22 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
//更新用户信息
|
|
//更新用户信息
|
|
|
- updateUserInfo() {
|
|
|
|
|
|
|
+ submitChanges() {
|
|
|
|
|
+ this.submitting = true
|
|
|
uni.$u.http.post('/token/user/wxBasicUpdate', {
|
|
uni.$u.http.post('/token/user/wxBasicUpdate', {
|
|
|
nickName: this.userInfo.nickName,
|
|
nickName: this.userInfo.nickName,
|
|
|
imgPath: this.userInfo.imgPath
|
|
imgPath: this.userInfo.imgPath
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // 提交修改
|
|
|
|
|
- async submitChanges() {
|
|
|
|
|
- if (this.uploading) {
|
|
|
|
|
- return uni.$u.toast('头像上传中,请稍候...')
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!this.hasChanges) return
|
|
|
|
|
-
|
|
|
|
|
- if (!this.userInfo.nickName.trim()) {
|
|
|
|
|
- return uni.$u.toast('请输入昵称')
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.submitting = true
|
|
|
|
|
- try {
|
|
|
|
|
- const { code, data } = await this.$u.api.setUserBaseInfoAjax({
|
|
|
|
|
- nickName: this.userInfo.nickName,
|
|
|
|
|
- imgPath: this.userInfo.imgPath
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- if (code === 1) {
|
|
|
|
|
- uni.$u.toast('保存成功')
|
|
|
|
|
- this.originalInfo = { ...this.userInfo }
|
|
|
|
|
- uni.$emit("getUserInfo")
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- uni.navigateBack()
|
|
|
|
|
- }, 1500)
|
|
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ this.$u.toast('更新成功')
|
|
|
|
|
+ uni.navigateBack({
|
|
|
|
|
+ delta: 1
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- } catch (error) {
|
|
|
|
|
- uni.$u.toast('保存失败,请重试')
|
|
|
|
|
- } finally {
|
|
|
|
|
|
|
+ }).finally(() => {
|
|
|
this.submitting = false
|
|
this.submitting = false
|
|
|
- }
|
|
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
- // 更新计算属性中的判断逻辑
|
|
|
|
|
- computed: {
|
|
|
|
|
- hasChanges() {
|
|
|
|
|
- return !this.uploading && (
|
|
|
|
|
- this.userInfo.nickName !== this.originalInfo.nickName ||
|
|
|
|
|
- this.userInfo.imgPath !== this.originalInfo.imgPath
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
@@ -329,4 +284,4 @@ export default {
|
|
|
border-radius: 50%;
|
|
border-radius: 50%;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|