diff --git a/src/pagesMember/profile/profile.vue b/src/pagesMember/profile/profile.vue index 32fb8cf..be3eaff 100644 --- a/src/pagesMember/profile/profile.vue +++ b/src/pagesMember/profile/profile.vue @@ -16,7 +16,10 @@ const headIcon = ref() const getMemberProfileData = async () => { const res = await getMemberProfileAPI() const obj = res.data - const avatar = serviceDomain + JSON.parse(obj.headIcon)[0].url + let avatar = '' + if (obj.headIcon) { + avatar = serviceDomain + JSON.parse(obj.headIcon)[0].url + } profile.value = { avatar, gender: obj.gender + '', @@ -78,18 +81,22 @@ const onGenderChange: UniHelper.RadioGroupOnChange = (ev) => { // 点击保存提交表单 const onSubmit = async () => { const { staffsName, gender } = profile.value - const params = { - headIcon: headIcon.value, - staffsName, - gender, + if (headIcon.value && staffsName && gender) { + const params = { + headIcon: headIcon.value, + staffsName, + gender, + } + const res = await postMemberProfileAPI(params) + // 更新Store昵称 + // memberStore.profile!.staffsName = staffsName + uni.showToast({ icon: 'success', title: '保存成功' }) + setTimeout(() => { + uni.navigateBack() + }, 400) + } else { + uni.showToast({ icon: 'none', title: '请填写完整数据' }) } - const res = await postMemberProfileAPI(params) - // 更新Store昵称 - // memberStore.profile!.staffsName = staffsName - uni.showToast({ icon: 'success', title: '保存成功' }) - setTimeout(() => { - uni.navigateBack() - }, 400) } onLoad(() => {