Browse Source

fix: 修复用户信息和宠物信息显示及选择器逻辑

修复了用户信息获取时未检查userId的问题,优化了宠物信息显示逻辑,确保仅在有效数据时显示。调整了宠物健康信息选择器的触发事件为@confirm,确保选择后正确更新数据。
master
前端-胡立永 3 months ago
parent
commit
c71cf10c55
5 changed files with 31 additions and 22 deletions
  1. +15
    -15
      otherPages/userManage/pet/components/petHealthInfo.vue
  2. +1
    -1
      otherPages/userManage/pet/index.vue
  3. +11
    -2
      otherPages/userManage/pet/petInfo.vue
  4. +3
    -3
      pages/userManage/index.vue
  5. +1
    -1
      store/modules/user.js

+ 15
- 15
otherPages/userManage/pet/components/petHealthInfo.vue View File

@ -66,14 +66,14 @@
</view> </view>
</view> --> </view> -->
<u-picker :show="showVaccine" :showToolbar='false' :columns="vaccineActions" @cancel="showVaccine = false"
:immediateChange="true" @change="vaccineSelect"></u-picker>
<u-picker :show="showExpelling" :showToolbar='false' :columns="expellingActions" @cancel="showExpelling = false"
:immediateChange="true" @change="expellingSelect"></u-picker>
<u-picker :show="showSterilization" :showToolbar='false' :columns="sterilizationActions"
@cancel="showSterilization = false" :immediateChange="true" @change="sterilizationSelect"></u-picker>
<u-picker :show="showDog" :showToolbar='false' :columns="dogActions" @cancel="showDog = false"
:immediateChange="true" @change="dogSelect"></u-picker>
<u-picker :show="showVaccine" :columns="vaccineActions" @cancel="showVaccine = false"
:immediateChange="true" @confirm="vaccineSelect"></u-picker>
<u-picker :show="showExpelling" :columns="expellingActions" @cancel="showExpelling = false"
:immediateChange="true" @confirm="expellingSelect"></u-picker>
<u-picker :show="showSterilization" :columns="sterilizationActions"
@cancel="showSterilization = false" :immediateChange="true" @confirm="sterilizationSelect"></u-picker>
<u-picker :show="showDog" :columns="dogActions" @cancel="showDog = false"
:immediateChange="true" @confirm="dogSelect"></u-picker>
</view> </view>
</template> </template>
@ -105,7 +105,7 @@
}); });
// emits // emits
const emits = defineEmits(['update:petHealthInfo']);
const emits = defineEmits(['update:petHealthInfo', 'updatePetHealthInfo']);
// //
const showVaccine = ref(false); const showVaccine = ref(false);
@ -176,25 +176,25 @@
}; };
const vaccineSelect = (e) => { const vaccineSelect = (e) => {
props.petHealthInfo.vaccine = e.index;
props.petHealthInfo.vaccine = e.indexs[0];
showVaccine.value = false; showVaccine.value = false;
updatePetHealthInfo(); updatePetHealthInfo();
}; };
const expellingSelect = (e) => { const expellingSelect = (e) => {
props.petHealthInfo.deworm = e.index;
props.petHealthInfo.deworm = e.indexs[0];
showExpelling.value = false; showExpelling.value = false;
updatePetHealthInfo(); updatePetHealthInfo();
}; };
const sterilizationSelect = (e) => { const sterilizationSelect = (e) => {
props.petHealthInfo.neutered = e.index;
props.petHealthInfo.neutered = e.indexs[0];
showSterilization.value = false; showSterilization.value = false;
updatePetHealthInfo(); updatePetHealthInfo();
}; };
const dogSelect = (e) => { const dogSelect = (e) => {
props.petHealthInfo.petCard = e.index;
props.petHealthInfo.petCard = e.indexs[0];
showDog.value = false; showDog.value = false;
updatePetHealthInfo(); updatePetHealthInfo();
}; };
@ -216,7 +216,7 @@
updatePetHealthInfo(); updatePetHealthInfo();
}; };
const updatePetHealthInfo = () => {
const updatePetHealthInfo = (map) => {
// update petHealthInfo // update petHealthInfo
emits('update:petHealthInfo', props.petHealthInfo); emits('update:petHealthInfo', props.petHealthInfo);
}; };
@ -231,7 +231,7 @@
}); });
</script> </script>
<style lang="scss">
<style lang="scss" scoped>
.personal-pet-health-info { .personal-pet-health-info {
background-color: #fff; background-color: #fff;
padding: 10px 20px 0 20px; padding: 10px 20px 0 20px;


+ 1
- 1
otherPages/userManage/pet/index.vue View File

@ -66,7 +66,7 @@
</view> </view>
<view> <view>
<u-picker :showToolbar='false' :show="show" :columns="petTypes" @change="petTypeChange" @cancel="cancel"
<u-picker :show="show" :columns="petTypes" @confirm="petTypeChange" @cancel="cancel"
:immediateChange="true"></u-picker> :immediateChange="true"></u-picker>
</view> </view>


+ 11
- 2
otherPages/userManage/pet/petInfo.vue View File

@ -14,7 +14,8 @@
</view> </view>
<PetBaseInfo :petType="petType" v-model:petBaseInfo="petBaseInfo" /> <PetBaseInfo :petType="petType" v-model:petBaseInfo="petBaseInfo" />
<PetHealthInfo :petType="petType" v-model:petHealthInfo="petHealthInfo" />
<PetHealthInfo :petType="petType" v-model:petHealthInfo="petHealthInfo"
@upPetHealthInfo="updatePetHealthInfo"/>
<view class="personal-pet-info-btns"> <view class="personal-pet-info-btns">
<view class="personal-pet-btns"> <view class="personal-pet-btns">
@ -128,6 +129,13 @@
fileListLen++; fileListLen++;
} }
}; };
function updatePetHealthInfo(data){
// petHealthInfo.value = {
// ...petHealthInfo.value,
// ...data
// }
}
const uploadFilePromise = (url) => { const uploadFilePromise = (url) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -218,6 +226,7 @@
...petBaseInfo.value, ...petBaseInfo.value,
...petHealthInfo.value ...petHealthInfo.value
}; };
console.log(params);
if (!params.nickName) { if (!params.nickName) {
uni.showToast({ uni.showToast({
title: '请填写宠物昵称!', title: '请填写宠物昵称!',
@ -355,7 +364,7 @@
}; };
</script> </script>
<style lang="scss">
<style lang="scss" scoped>
.personal-pet-cat { .personal-pet-cat {
.breed-select { .breed-select {


+ 3
- 3
pages/userManage/index.vue View File

@ -65,12 +65,12 @@
<!-- <up-button v-if="getIsLogin()" class="mb20" size="large" style="width: 500rpx" type="primary" <!-- <up-button v-if="getIsLogin()" class="mb20" size="large" style="width: 500rpx" type="primary"
text="请添加您的爱宠" shape="circle" text="请添加您的爱宠" shape="circle"
color="linear-gradient(to right, rgb(255 ,191 ,96 ,1), rgb(255, 51, 186))"></up-button> --> color="linear-gradient(to right, rgb(255 ,191 ,96 ,1), rgb(255, 51, 186))"></up-button> -->
<view v-if="isLogin" class="cw-box radius20 pd20 flex">
<view v-if="isLogin && pet.id" class="cw-box radius20 pd20 flex">
<up-image class="mr20" width="140rpx" style="flex-shrink: 0" height="140rpx" <up-image class="mr20" width="140rpx" style="flex-shrink: 0" height="140rpx"
:src="pet?.headImage" shape="circle"></up-image> :src="pet?.headImage" shape="circle"></up-image>
<view style="width: 418rpx"> <view style="width: 418rpx">
<view class="font32 mb20">{{ pet.type }}</view>
<view class="font24 ellipsis">澳大利亚雾猫澳洲斑点雾猫| 1 个月</view>
<view class="font32 mb20">{{ pet.nickName }}</view>
<view class="font24 ellipsis">{{ pet.type }} | {{ pet.age }}</view>
</view> </view>
</view> </view>
</view> </view>


+ 1
- 1
store/modules/user.js View File

@ -79,7 +79,7 @@ const user = {
commit, commit,
state state
}) { }) {
if (getIsLogin()) {
if (getIsLogin() && state.userInfo.userId) {
const response = await getbaseInfo(state.userInfo.userId); const response = await getbaseInfo(state.userInfo.userId);
if (response.code == 200) { if (response.code == 200) {
commit("setUserInfo", response.data); commit("setUserInfo", response.data);


Loading…
Cancel
Save