@ -0,0 +1,300 @@ | |||
<template> | |||
<view class=""> | |||
<view class="personal-pet-basic-info"> | |||
<view class="personal-pet-info-title border-bottom"> | |||
宠物基本信息 | |||
</view> | |||
<u--form labelPosition="left" :model="model" ref="uForm"> | |||
<u-form-item required label="昵称" :prop="`petBaseInfo.name`" labelWidth="80" borderBottom> | |||
<u--input v-model="petBaseInfo.name" placeholder="请输入宠物昵称" @change="nameChange" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
</u-form-item> | |||
<u-form-item label="性别" :prop="`petBaseInfo.gender`" labelWidth="80" borderBottom | |||
@click="showSex = true"> | |||
<u--input v-model="petBaseInfo.gender" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item required label="品种" :prop="`petBaseInfo.breed`" labelWidth="80" borderBottom | |||
@click="breedSelectOpen"> | |||
<u--input v-model="petBaseInfo.breed" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item required label="体重" :prop="`petBaseInfo.bodyType`" labelWidth="80" borderBottom | |||
@click="showWeight = true" ref="item1"> | |||
<u--input v-model="petBaseInfo.bodyType" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item label="出生年月" :prop="`petBaseInfo.birthDate`" labelWidth="80" borderBottom | |||
@click="yearMonthOpen"> | |||
<u--input v-model="petBaseInfo.birthDate" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item required label="性格" :prop="`petBaseInfo.personality`" labelWidth="80" borderBottom | |||
@click="dispositionSelectOpen"> | |||
<u--input v-model="petBaseInfo.personality" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
</u--form> | |||
</view> | |||
<view style="background-color: #fffcf2;padding: 10px 20px;" v-show="showDisposition"> | |||
<view style="height: 85%;"> | |||
<u-checkbox-group v-model="petBaseInfo.personality" @change="checkboxChange" iconPlacement="left" | |||
placement="row" style="flex-wrap: wrap;" activeColor="#ffbf60"> | |||
<u-checkbox :customStyle="{margin: '8px'}" v-for="(item, index) in dispositionActions" :key="item" | |||
:label="item" :name="item"> | |||
</u-checkbox> | |||
</u-checkbox-group> | |||
</view> | |||
</view> | |||
<u-picker :show="showSex" :showToolbar='false' :columns="sexActions" @cancel="showSex = false" | |||
:immediateChange="true" @change="sexSelect"></u-picker> | |||
<u-picker :show="showWeight" :showToolbar='false' :columns="weightActions" @cancel="showWeight = false" | |||
:immediateChange="true" @change="weightSelect"></u-picker> | |||
<u-overlay :show="showBreed"> | |||
<view class="breed-select" style="height: 60%;"> | |||
<u-search shape="round" :show-action="false" v-model="searchValue" @change="searchBreed"></u-search> | |||
<view style="padding: 10px;height: 80%;overflow: auto;"> | |||
<u-radio-group v-model="tempBreed" placement="column"> | |||
<u-radio v-for="(item,index) in searchBreedData" :customStyle="{marginBottom: '8px'}" | |||
activeColor="#ffbf60" :label="item" :name="item" :key="item"></u-radio> | |||
</u-radio-group> | |||
</view> | |||
<view class="personal-pet-breed-btns"> | |||
<view class="personal-pet-breed-btn"> | |||
<u-button color="#FFF4E4" @click="breedSelectClose"> | |||
<view style="color: #FFF4E4;"> | |||
取消 | |||
</view> | |||
</u-button> | |||
</view> | |||
<view class="personal-pet-breed-btn" @click="breedSelectConfirm"> | |||
<u-button color="#FFBF60"> | |||
<view style="color: #fff;"> | |||
确定 | |||
</view> | |||
</u-button> | |||
</view> | |||
</view> | |||
</view> | |||
</u-overlay> | |||
<u-datetime-picker :maxDate='getMaxDate()' :minDate="getMinDate()" :show="showBirthday" v-model="tempBirthday" | |||
mode="year-month" @confirm="yearMonthConfirm" @cancel="yearMonthClose"></u-datetime-picker> | |||
</view> | |||
</template> | |||
<script setup> | |||
import { | |||
ref, | |||
onMounted, | |||
watch | |||
} from 'vue'; | |||
// 定义 props | |||
const props = defineProps({ | |||
petType: { | |||
type: String, | |||
default: 'dog' | |||
}, | |||
petBaseInfo: { | |||
type: Object, | |||
default: () => ({ | |||
name: '', | |||
gender: '', | |||
breed: '', | |||
bodyType: '', | |||
birthDate: '', | |||
personality: '' | |||
}) | |||
} | |||
}); | |||
// 定义 emits | |||
const emits = defineEmits(['update:petBaseInfo']); | |||
// 定义响应式数据 | |||
const showSex = ref(false); | |||
const showBreed = ref(false); | |||
const showWeight = ref(false); | |||
const showBirthday = ref(false); | |||
const showDisposition = ref(false); | |||
const sexActions = ref([ | |||
['男生', '女生'] | |||
]); | |||
const weightActions = ref([ | |||
['小型(<10 KG)', '中型(10~20KG)', '大型(20KG以上)'] | |||
]); | |||
const dispositionActions = ref([]); | |||
const breedData = ref([]); | |||
const searchBreedData = ref([]); | |||
const tempBreed = ref(''); | |||
const searchValue = ref(''); | |||
const tempBirthday = ref(''); | |||
const tempDisposition = ref(''); | |||
const uForm = ref(null); | |||
const item1 = ref(null); | |||
// 定义方法 | |||
const nameChange = () => { | |||
updatePetBaseInfo(); | |||
}; | |||
const sexSelect = (e) => { | |||
props.petBaseInfo.gender = e.value[0]; | |||
showSex.value = false; | |||
updatePetBaseInfo(); | |||
}; | |||
const weightSelect = (e) => { | |||
props.petBaseInfo.bodyType = e.value[0]; | |||
showWeight.value = false; | |||
updatePetBaseInfo(); | |||
}; | |||
const breedSelectOpen = () => { | |||
searchBreedData.value = breedData.value; | |||
searchValue.value = ''; | |||
tempBreed.value = props.petBaseInfo.breed; | |||
showBreed.value = true; | |||
}; | |||
const searchBreed = () => { | |||
if (searchValue.value && searchValue.value !== '') { | |||
searchBreedData.value = breedData.value.filter(e => e.includes(searchValue.value)); | |||
} else { | |||
searchBreedData.value = breedData.value; | |||
} | |||
}; | |||
const breedSelectClose = () => { | |||
tempBreed.value = ''; | |||
showBreed.value = false; | |||
}; | |||
const breedSelectConfirm = () => { | |||
props.petBaseInfo.breed = tempBreed.value; | |||
showBreed.value = false; | |||
updatePetBaseInfo(); | |||
}; | |||
const yearMonthOpen = () => { | |||
if (props.petBaseInfo.birthDate) { | |||
tempBirthday.value = Number(new Date(props.petBaseInfo.birthDate)); | |||
} else { | |||
tempBirthday.value = Number(new Date()); | |||
} | |||
showBirthday.value = true; | |||
}; | |||
const yearMonthClose = () => { | |||
showBirthday.value = false; | |||
}; | |||
const yearMonthConfirm = (e) => { | |||
const timeFormat = uni.$u.timeFormat; | |||
props.petBaseInfo.birthDate = timeFormat(e.value, 'yyyy-mm'); | |||
showBirthday.value = false; | |||
updatePetBaseInfo(); | |||
}; | |||
const dispositionSelectOpen = () => { | |||
tempDisposition.value = props.petBaseInfo.personality; | |||
showDisposition.value = true; | |||
}; | |||
const dispositionSelectClose = () => { | |||
tempDisposition.value = ''; | |||
showDisposition.value = false; | |||
}; | |||
const dispositionSelectConfirm = () => { | |||
props.petBaseInfo.personality = tempDisposition.value; | |||
showDisposition.value = false; | |||
updatePetBaseInfo(); | |||
}; | |||
const checkboxChange = (n) => { | |||
console.log('change', n); | |||
updatePetBaseInfo(); | |||
}; | |||
const updatePetBaseInfo = () => { | |||
// 触发 update 事件,将修改后的 petBaseInfo 对象发送给父组件 | |||
emits('update:petBaseInfo', props.petBaseInfo); | |||
}; | |||
const getPersonalityDataList = () => { | |||
// getDictList('pet_personality').then(res => { | |||
// if (res.code === 200) { | |||
// dispositionActions.value = Array.from(new Set(res.data.map(e => e.dictLabel))); | |||
// } else { | |||
// uni.showToast({ | |||
// title: '获取性格失败', | |||
// icon: 'none' | |||
// }); | |||
// } | |||
// }); | |||
}; | |||
const getPetBreed = () => { | |||
let petBreedType = props.petType === 'cat' ? 'pet_brand_cat' : 'pet_brand_dog'; | |||
// getDictList(petBreedType).then(res => { | |||
// if (res.code === 200) { | |||
// breedData.value = Array.from(new Set(res.data.map(e => e.dictLabel))); | |||
// } else { | |||
// uni.showToast({ | |||
// title: '获取种类失败', | |||
// icon: 'none' | |||
// }); | |||
// } | |||
// }); | |||
}; | |||
const getMaxDate = () => { | |||
return Date.now(); | |||
}; | |||
const getMinDate = () => { | |||
let dt = new Date(); | |||
dt.setFullYear(dt.getFullYear() - 30); | |||
return Date.parse(dt); | |||
}; | |||
// 生命周期钩子 | |||
onMounted(() => { | |||
// getPersonalityDataList(); | |||
// getPetBreed(); | |||
}); | |||
</script> | |||
<style> | |||
.personal-pet-basic-info { | |||
background-color: #fff; | |||
margin-top: 10px; | |||
padding: 10px 20px; | |||
} | |||
.personal-pet-breed-btns { | |||
display: flex; | |||
justify-content: space-between; | |||
box-sizing: border-box; | |||
background-color: #FFFFFF; | |||
padding: 20rpx 20rpx 40rpx 20rpx; | |||
width: 100%; | |||
height: 160rpx; | |||
position: fixed; | |||
bottom: 0; | |||
z-index: 100; | |||
} | |||
.personal-pet-breed-btn { | |||
width: 40%; | |||
} | |||
</style> |
@ -0,0 +1,226 @@ | |||
<template> | |||
<view class=""> | |||
<view class="personal-pet-health-info"> | |||
<view class="personal-pet-info-title border-bottom"> | |||
宠物健康情况 | |||
</view> | |||
<u--form labelPosition="left" :model="petHealthInfo" ref="uForm"> | |||
<u-form-item required label="疫苗" :prop="`petHealthInfo.vaccineStatus`" labelWidth="80" borderBottom | |||
@click="showVaccine = true"> | |||
<u--input v-model="petHealthInfo.vaccineStatus" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item required label="驱虫" :prop="`petHealthInfo.dewormingStatus`" labelWidth="80" borderBottom | |||
@click="showExpelling = true"> | |||
<u--input v-model="petHealthInfo.dewormingStatus" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item label="绝育" :prop="`petHealthInfo.sterilization`" labelWidth="80" borderBottom | |||
@click="showSterilization = true" ref="item1"> | |||
<u--input v-model="petHealthInfo.sterilization" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<u-form-item v-if="petType === 'dog' || petType === '狗狗' " label="狗证" :prop="`petHealthInfo.doglicenseStatus`" labelWidth="80" borderBottom | |||
@click="showDog = true" ref="item1"> | |||
<u--input v-model="petHealthInfo.doglicenseStatus" disabled disabledColor="#ffffff" placeholder="请选择" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<u-icon slot="right" name="arrow-right" color="#AAA"></u-icon> | |||
</u-form-item> | |||
<view class="dog-tips" v-if="petType === 'dog' || petType === '狗狗'"> | |||
<u-icon name="info-circle" color="#A94F20" size="12"></u-icon> | |||
<view style="margin-left: 3px;"> | |||
未办理养犬许可证且需要外出遛狗, 犬只存在被相关单位收缴 | |||
甚至捕杀的可能,请您遵守当地养犬规范,合法文明养犬。具体 | |||
请您查看当地养犬条例 | |||
</view> | |||
</view> | |||
<u-form-item required label="健康" :prop="`petHealthInfo.healths`" labelWidth="80" | |||
@click="healthsSelect"> | |||
<u--input disabled disabledColor="#ffffff" placeholder="请选择(多选)" :value="petHealthInfo.healthStatus && petHealthInfo.healthStatus.join(',')" | |||
placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input> | |||
<view slot="right"> | |||
<u-icon v-if="showHealths" name="arrow-down" color="#AAA"></u-icon> | |||
<u-icon v-else name="arrow-right" color="#AAA" ></u-icon> | |||
</view> | |||
</u-form-item> | |||
</u--form> | |||
</view> | |||
<view class="health-select" v-show="showHealths"> | |||
<view style="padding: 10px;height: 85%;"> | |||
<u-checkbox-group v-model="petHealthInfo.healthStatus" @change="checkboxChange" placement="column" activeColor="#ffbf60"> | |||
<u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in healthData" | |||
:key="index" :label="item" :name="item"> | |||
</u-checkbox> | |||
</u-checkbox-group> | |||
<u--input placeholder="请输入其他健康特征" | |||
:disabled="!(petHealthInfo.healthStatus && petHealthInfo.healthStatus.includes('其他'))" | |||
border="surround" maxlength='20' | |||
:customStyle="{backgroundColor: '#fff'}" | |||
@change="updatePetHealthInfo()" | |||
v-model="petHealthInfo.remark"></u--input> | |||
</view> | |||
</view> | |||
<u-picker :show="showVaccine" :showToolbar='false' :columns="vaccineActions" @cancel="showVaccine = false" :immediateChange="true" | |||
:defaultIndex="defaultVaccine" | |||
@change="vaccineSelect"></u-picker> | |||
<u-picker :show="showExpelling" :showToolbar='false' :columns="expellingActions" @cancel="showExpelling = false" :immediateChange="true" | |||
:defaultIndex="defaultDeworming" | |||
@change="expellingSelect"></u-picker> | |||
<u-picker :show="showSterilization" :showToolbar='false' :columns="sterilizationActions" @cancel="showSterilization = false" :immediateChange="true" | |||
:defaultIndex="defaultSterilization" | |||
@change="sterilizationSelect"></u-picker> | |||
<u-picker :show="showDog" :showToolbar='false' :columns="dogActions" @cancel="showDog = false" :immediateChange="true" | |||
:defaultIndex="defaultDoglicense" | |||
@change="dogSelect"></u-picker> | |||
</view> | |||
</template> | |||
<script setup> | |||
import { ref, onMounted, watch } from 'vue'; | |||
// 定义 props | |||
const props = defineProps({ | |||
petType: { | |||
type: String, | |||
default: 'dog' | |||
}, | |||
petHealthInfo: { | |||
type: Object, | |||
default: () => ({ | |||
vaccineStatus: '', | |||
dewormingStatus: '', | |||
sterilization: '', | |||
doglicenseStatus: '', | |||
healthStatus: [], | |||
remark: '' | |||
}) | |||
}, | |||
defaultVaccine: { | |||
type: Number, | |||
default: 0 | |||
}, | |||
defaultDeworming: { | |||
type: Number, | |||
default: 0 | |||
}, | |||
defaultSterilization: { | |||
type: Number, | |||
default: 0 | |||
}, | |||
defaultDoglicense: { | |||
type: Number, | |||
default: 0 | |||
} | |||
}); | |||
// 定义 emits | |||
const emits = defineEmits(['update:petHealthInfo']); | |||
// 定义响应式数据 | |||
const showVaccine = ref(false); | |||
const showExpelling = ref(false); | |||
const showSterilization = ref(false); | |||
const showDog = ref(false); | |||
const showHealths = ref(false); | |||
const vaccineActions = ref([[ '每年都免疫','有免疫史','未免疫']]); | |||
const expellingActions = ref([['未驱虫', '定期驱虫', '有驱虫史']]); | |||
const sterilizationActions = ref([['已绝育','未绝育']]); | |||
const dogActions = ref([[ '是','否']]); | |||
const healthData = ref([]); | |||
const tempHealths = ref([]); | |||
const uForm = ref(null); | |||
const item1 = ref(null); | |||
// 定义方法 | |||
const getHealthDataList = () => { | |||
// getDictList('pet_health_status').then(res => { | |||
// if (res.code === 200) { | |||
// healthData.value = res.data.map(e => e.dictLabel); | |||
// } else { | |||
// uni.showToast({ | |||
// title: '获取健康类型失败', | |||
// icon: 'none' | |||
// }); | |||
// } | |||
// }); | |||
}; | |||
const vaccineSelect = (e) => { | |||
props.petHealthInfo.vaccineStatus = e.value[0]; | |||
showVaccine.value = false; | |||
updatePetHealthInfo(); | |||
}; | |||
const expellingSelect = (e) => { | |||
props.petHealthInfo.dewormingStatus = e.value[0]; | |||
showExpelling.value = false; | |||
updatePetHealthInfo(); | |||
}; | |||
const sterilizationSelect = (e) => { | |||
props.petHealthInfo.sterilization = e.value[0]; | |||
showSterilization.value = false; | |||
updatePetHealthInfo(); | |||
}; | |||
const dogSelect = (e) => { | |||
props.petHealthInfo.doglicenseStatus = e.value[0]; | |||
showDog.value = false; | |||
updatePetHealthInfo(); | |||
}; | |||
const healthsSelect = () => { | |||
showHealths.value = !showHealths.value; | |||
uni.pageScrollTo({ | |||
scrollTop: 2000, | |||
duration: 300 | |||
}); | |||
}; | |||
const checkboxChange = (n) => { | |||
console.log('change', n); | |||
updatePetHealthInfo(); | |||
}; | |||
const changeRemark = (e) => { | |||
props.petHealthInfo.remark = e; | |||
updatePetHealthInfo(); | |||
}; | |||
const updatePetHealthInfo = () => { | |||
// 触发 update 事件,将修改后的 petHealthInfo 对象发送给父组件 | |||
emits('update:petHealthInfo', props.petHealthInfo); | |||
}; | |||
// 生命周期钩子 | |||
onMounted(() => { | |||
// getHealthDataList(); | |||
// defaultVaccine.value = vaccineActions.value[0].indexOf(props.petHealthInfo.vaccineStatus); | |||
// defaultDeworming.value = expellingActions.value[0].indexOf(props.petHealthInfo.dewormingStatus); | |||
// defaultSterilization.value = sterilizationActions.value[0].indexOf(props.petHealthInfo.sterilization); | |||
// defaultDoglicense.value = dogActions.value[0].indexOf(props.petHealthInfo.doglicenseStatus); | |||
}); | |||
</script> | |||
<style lang="scss"> | |||
.personal-pet-health-info{ | |||
background-color: #fff; | |||
padding: 10px 20px 0 20px; | |||
margin-top: 10px; | |||
} | |||
.health-select{ | |||
background-color: #fffcf2; | |||
padding: 10px 20px; | |||
} | |||
.dog-tips{ | |||
color: #A94F20; | |||
font-size: 12px; | |||
display: flex; | |||
align-items: baseline; | |||
margin-top: 5px; | |||
} | |||
</style> |
@ -0,0 +1,447 @@ | |||
<template> | |||
<view class="personal-pet-cat container"> | |||
<view class="personal-pet-img"> | |||
<view class="personal-pet-info-title"> | |||
宠物头像 | |||
</view> | |||
<view style="display: flex;justify-content: center;"> | |||
<u-upload accept="image" :capture="['album','camera']" :fileList="fileList" @afterRead="afterRead" | |||
@delete="deletePic" :max-count="1" name="pet" width="60" height="60" :custom-style="{flex:0}"> | |||
<image src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/cat_new.png" | |||
style="width: 60px;height: 60px;"></image> | |||
</u-upload> | |||
</view> | |||
</view> | |||
<PetBaseInfo :petType="petType" v-model:petBaseInfo="petBaseInfo" /> | |||
<PetHealthInfo :petType="petType" v-model:petHealthInfo="petHealthInfo" /> | |||
<view class="personal-pet-info-btns"> | |||
<view class="personal-pet-btns"> | |||
<view class="personal-pet-btn"> | |||
<u-button :disabled="optionType!='edit'" color="#FFF4E4" @click="deletePet"> | |||
<view style="color: #A9A9A9;"> | |||
删除 | |||
</view> | |||
</u-button> | |||
</view> | |||
<view class="personal-pet-btn" @click="save"> | |||
<u-button color="#FFBF60" :loading="loading"> | |||
<view style="color: #fff;"> | |||
保存 | |||
</view> | |||
</u-button> | |||
</view> | |||
</view> | |||
</view> | |||
<u-modal :show="showDel" @confirm="confirmDel" @cancel="showDel = false" ref="uModal" showCancelButton | |||
:asyncClose="true" :content="delContent"> | |||
</u-modal> | |||
</view> | |||
</template> | |||
<script setup> | |||
import { | |||
ref, | |||
onMounted | |||
} from 'vue'; | |||
import { | |||
addPet, | |||
getPetDetails, | |||
updatePet, | |||
delByPetId | |||
} from '@/api/pet/index.js'; | |||
import PetBaseInfo from './components/petBaseInfo.vue'; | |||
import PetHealthInfo from './components/petHealthInfo.vue'; | |||
import { | |||
useRoute, | |||
useRouter | |||
} from 'vue-router'; | |||
import { | |||
onLoad | |||
} from '@dcloudio/uni-app' | |||
const route = useRoute(); | |||
const router = useRouter(); | |||
const loading = ref(false); | |||
const fileList = ref([]); | |||
const petId = ref(''); | |||
const petType = ref('dog'); | |||
const optionType = ref('add'); | |||
const isNewOrder = ref(false); | |||
const delContent = ref(''); | |||
const photo = ref(''); | |||
const petBaseInfo = ref({ | |||
name: '', | |||
gender: '', | |||
breed: '', | |||
bodyType: '', | |||
birthDate: '', | |||
personality: '' | |||
}); | |||
const petHealthInfo = ref({ | |||
vaccineStatus: '', | |||
dewormingStatus: '', | |||
sterilization: '', | |||
doglicenseStatus: '', | |||
healthStatus: [], | |||
remark: '' | |||
}); | |||
const showDel = ref(false); | |||
const uModal = ref(null); | |||
onLoad((option) => { | |||
petType.value = option.petType; | |||
optionType.value = option.optionType; | |||
if (optionType.value === 'edit') { | |||
petId.value = option.petId; | |||
getPetDetailsFunc(option.petId); | |||
} | |||
if (option.isNewOrder) { | |||
isNewOrder.value = true; | |||
} | |||
}); | |||
const deletePic = (event) => { | |||
fileList.value.splice(event.index, 1); | |||
}; | |||
const afterRead = async (event) => { | |||
let lists = [].concat(event.file); | |||
let fileListLen = fileList.value.length; | |||
lists.map((item) => { | |||
fileList.value.push({ | |||
...item, | |||
status: 'uploading', | |||
message: '上传中' | |||
}); | |||
}); | |||
for (let i = 0; i < lists.length; i++) { | |||
const result = await uploadFilePromise(lists[i].url); | |||
let item = fileList.value[fileListLen]; | |||
fileList.value.splice(fileListLen, 1, Object.assign(item, { | |||
status: 'success', | |||
message: '', | |||
url: result | |||
})); | |||
fileListLen++; | |||
} | |||
}; | |||
const uploadFilePromise = (url) => { | |||
return new Promise((resolve, reject) => { | |||
uni.uploadFile({ | |||
url: 'https://store-test.catmdogd.com/test-api/h5/oss/upload', | |||
filePath: url, | |||
name: 'file', | |||
formData: { | |||
user: 'test' | |||
}, | |||
success: (res) => { | |||
setTimeout(() => { | |||
if (res && res.data) { | |||
let resData = JSON.parse(res.data); | |||
resolve(resData.url); | |||
} | |||
reject("上传失败"); | |||
}, 1000); | |||
} | |||
}); | |||
}); | |||
}; | |||
const getPetDetailsFunc = (petId) => { | |||
getPetDetails(petId).then((res) => { | |||
if (res && res.id) { | |||
const { | |||
photo, | |||
name, | |||
gender, | |||
breed, | |||
bodyType, | |||
birthDate, | |||
personality, | |||
vaccineStatus, | |||
dewormingStatus, | |||
sterilization, | |||
doglicenseStatus, | |||
healthStatus, | |||
remark | |||
} = res; | |||
petBaseInfo.value = { | |||
name, | |||
gender, | |||
breed, | |||
bodyType, | |||
birthDate, | |||
personality | |||
}; | |||
petHealthInfo.value = { | |||
vaccineStatus, | |||
dewormingStatus, | |||
sterilization, | |||
doglicenseStatus, | |||
healthStatus, | |||
remark | |||
}; | |||
fileList.value = [{ | |||
url: photo | |||
}]; | |||
} else { | |||
uni.showToast({ | |||
title: '获取pet失败', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
} | |||
}); | |||
}; | |||
const save = () => { | |||
if (!(fileList.value.length > 0 && fileList.value[0].url)) { | |||
uni.showToast({ | |||
title: '请上传宠物照片!', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
return; | |||
} | |||
photo.value = fileList.value[0].url; | |||
let params = { | |||
...{ | |||
petType: petType.value, | |||
photo: photo.value | |||
}, | |||
...petBaseInfo.value, | |||
...petHealthInfo.value | |||
}; | |||
if (!params.name) { | |||
uni.showToast({ | |||
title: '请填写宠物昵称!', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
return; | |||
} | |||
// if (!params.breed) { | |||
// uni.showToast({ | |||
// title: '请选择宠物品种!', | |||
// duration: 3000, | |||
// icon: "none" | |||
// }); | |||
// return; | |||
// } | |||
if (!params.bodyType) { | |||
uni.showToast({ | |||
title: '请选择宠物体重!', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
return; | |||
} | |||
// if (!params.personality) { | |||
// uni.showToast({ | |||
// title: '请选择宠物性格,可多选!', | |||
// duration: 3000, | |||
// icon: "none" | |||
// }); | |||
// return; | |||
// } | |||
if (!params.vaccineStatus) { | |||
uni.showToast({ | |||
title: '请选择宠物疫苗情况!', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
return; | |||
} | |||
if (!params.dewormingStatus) { | |||
uni.showToast({ | |||
title: '请选择宠物驱虫情况!', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
return; | |||
} | |||
// if (params.healthStatus == null || !params.healthStatus.length) { | |||
// uni.showToast({ | |||
// title: '请选择宠物健康情况,可多选!', | |||
// duration: 3000, | |||
// icon: "none" | |||
// }); | |||
// return; | |||
// } | |||
console.log(params) | |||
loading.value = true; | |||
if (optionType.value === 'edit') { | |||
params.id = petId.value; | |||
updatePet(params).then((res) => { | |||
if (res && res.code === 200) { | |||
uni.showToast({ | |||
title: '保存成功', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
setTimeout(() => { | |||
loading.value = false; | |||
if (isNewOrder.value) { | |||
router.push('/pages/newOrder/petList'); | |||
} else { | |||
const len = getCurrentPages().length; | |||
if (len >= 2) { | |||
uni.navigateBack(); | |||
} else { | |||
router.push('/pages/personalCenter/pet'); | |||
} | |||
} | |||
}, 1000); | |||
} else { | |||
loading.value = false; | |||
uni.showToast({ | |||
title: '更新pet失败', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
} | |||
}); | |||
} else if (optionType.value === 'add') { | |||
addPet(params).then((res) => { | |||
if (res && res === 1) { | |||
uni.showToast({ | |||
title: '保存成功', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
setTimeout(() => { | |||
loading.value = false; | |||
if (isNewOrder.value) { | |||
router.push('/pages/newOrder/petList'); | |||
} else { | |||
const len = getCurrentPages().length; | |||
if (len >= 2) { | |||
uni.navigateBack(); | |||
} else { | |||
router.push('/pages/personalCenter/pet'); | |||
} | |||
} | |||
}, 1000); | |||
} else { | |||
loading.value = false; | |||
uni.showToast({ | |||
title: '新增pet失败', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
} | |||
}); | |||
} | |||
}; | |||
const deletePet = () => { | |||
delContent.value = `确定要删除${petBaseInfo.value.name}?`; | |||
showDel.value = true; | |||
}; | |||
const confirmDel = () => { | |||
delByPetId(petId.value).then((res) => { | |||
console.log(res); | |||
uni.showToast({ | |||
title: '删除成功', | |||
duration: 3000, | |||
icon: "none" | |||
}); | |||
showDel.value = false; | |||
setTimeout(() => { | |||
const len = getCurrentPages().length; | |||
loading.value = false; | |||
if (len >= 2) { | |||
uni.navigateBack(); | |||
} else { | |||
router.push('/pages/personalCenter/pet'); | |||
} | |||
}, 2000); | |||
}); | |||
}; | |||
</script> | |||
<style lang="scss"> | |||
.personal-pet-cat { | |||
.breed-select { | |||
background-color: #fff; | |||
width: 100%; | |||
padding: 20px; | |||
border-radius: 8px 8px 0 0; | |||
position: absolute; | |||
bottom: 0; | |||
.breed-select-btn { | |||
display: flex; | |||
justify-content: space-around; | |||
align-items: center; | |||
} | |||
} | |||
.personal-pet-info-title { | |||
font-size: 14px; | |||
color: #333; | |||
font-weight: bold; | |||
padding-bottom: 10px; | |||
} | |||
.border-bottom { | |||
border-bottom: 1px solid #efefef; | |||
} | |||
.personal-pet-img { | |||
width: 100%; | |||
height: 118px; | |||
background-color: #fff; | |||
padding: 10px 20px; | |||
} | |||
.personal-pet-basic-info { | |||
background-color: #fff; | |||
margin-top: 10px; | |||
padding: 10px 20px; | |||
} | |||
} | |||
.container { | |||
position: relative; | |||
height: 100%; | |||
padding-bottom: 90px; | |||
.personal-pet-info-btns { | |||
box-sizing: border-box; | |||
background-color: #FFFFFF; | |||
padding: 20rpx 20rpx 40rpx 20rpx; | |||
width: 100%; | |||
height: 160rpx; | |||
position: fixed; | |||
bottom: 0; | |||
z-index: 100; | |||
display: flex; | |||
.personal-pet-btns { | |||
display: flex; | |||
justify-content: space-around; | |||
align-items: center; | |||
flex-wrap: nowrap; | |||
width: 100%; | |||
height: 90rpx; | |||
border-radius: 6px; | |||
font-size: 16px; | |||
color: #FFFFFF; | |||
.personal-pet-btn { | |||
width: 40%; | |||
} | |||
} | |||
} | |||
} | |||
</style> |
@ -0,0 +1,6 @@ | |||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> | |||
<g id="Group 1000001678"> | |||
<circle id="Ellipse 1243" cx="10" cy="10" r="10" fill="#51B6FF"/> | |||
<path id="Vector" d="M15.103 4.42184C15.0575 4.40884 15.012 4.40234 14.9665 4.40234H11.723C11.359 4.40234 11.0665 4.69484 11.0665 5.05884C11.0665 5.42284 11.359 5.71534 11.723 5.71534H13.2895L11.19 7.81484C10.41 7.30134 9.48049 6.99584 8.47949 6.99584C5.76249 6.99584 3.55249 9.20584 3.55249 11.9228C3.55249 14.6398 5.76249 16.8498 8.47949 16.8498C11.1965 16.8498 13.4065 14.6398 13.4065 11.9228C13.4065 10.6813 12.945 9.54384 12.1845 8.67284L14.1995 6.65784V8.17884C14.1995 8.54284 14.492 8.83534 14.856 8.83534C15.22 8.83534 15.5125 8.54284 15.5125 8.17884V4.94184C15.506 4.69484 15.337 4.48034 15.103 4.42184ZM8.47299 15.6668C6.41249 15.6668 4.73549 13.9898 4.73549 11.9293C4.73549 9.86884 6.41249 8.19184 8.47299 8.19184C10.5335 8.19184 12.2105 9.86884 12.2105 11.9293C12.2105 13.9898 10.5335 15.6668 8.47299 15.6668Z" fill="white"/> | |||
</g> | |||
</svg> |
@ -0,0 +1,8 @@ | |||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> | |||
<g id="Group 1000001402"> | |||
<circle id="Ellipse 1243" cx="10" cy="10" r="10" fill="#FF7878"/> | |||
<g id="Frame"> | |||
<path id="Vector" d="M14.6994 5.16698C13.8873 4.37042 12.8137 3.93164 11.6765 3.93164C10.5077 3.93164 9.41323 4.39106 8.59485 5.22526C7.78752 6.04819 7.34875 7.13664 7.35981 8.28959C7.3685 9.20735 7.66217 10.078 8.19637 10.8025L7.19011 11.8279L5.09588 9.77316C5.03131 9.70846 4.95454 9.65721 4.87003 9.62237C4.78551 9.58753 4.69493 9.56979 4.60352 9.57018C4.51211 9.57058 4.42168 9.58909 4.33747 9.62466C4.25326 9.66022 4.17694 9.71214 4.11292 9.77739C4.0489 9.84264 3.99845 9.91994 3.9645 10.0048C3.93055 10.0897 3.91376 10.1805 3.91511 10.2719C3.91647 10.3633 3.93593 10.4535 3.97238 10.5373C4.00882 10.6212 4.06153 10.6969 4.12745 10.7603L6.22167 12.815L4.79648 14.2676C4.67102 14.3991 4.60236 14.5747 4.60536 14.7564C4.60836 14.9381 4.68278 15.1114 4.81251 15.2387C4.94224 15.3659 5.11687 15.437 5.29861 15.4366C5.48036 15.4361 5.65461 15.3641 5.78369 15.2361L7.20887 13.7836L9.30309 15.8383C9.43221 15.9654 9.60617 16.0364 9.78731 16.0362C9.92463 16.0362 10.0588 15.9953 10.1728 15.9187C10.2868 15.8421 10.3755 15.7334 10.4274 15.6062C10.4793 15.4791 10.4922 15.3394 10.4645 15.2049C10.4367 15.0704 10.3696 14.9473 10.2715 14.8511L8.17731 12.7965L9.18239 11.7719C9.90703 12.2865 10.771 12.5652 11.676 12.5652C12.8447 12.5652 13.9392 12.1058 14.7576 11.2715C15.565 10.4485 16.0037 9.36016 15.9927 8.20721C15.9819 7.05416 15.5224 5.9745 14.6994 5.16698ZM13.7705 10.303C13.2143 10.87 12.4706 11.1821 11.6761 11.1821C10.903 11.1821 10.1733 10.884 9.62156 10.3424C9.06207 9.7937 8.74993 9.05997 8.74262 8.27625C8.73511 7.49254 9.03313 6.75298 9.58205 6.19359C10.1383 5.6266 10.882 5.31445 11.6765 5.31445C12.4493 5.31445 13.179 5.61267 13.731 6.15418C14.2903 6.7029 14.6024 7.43673 14.6099 8.22034C14.6174 9.00406 14.3194 9.74362 13.7705 10.303Z" fill="white"/> | |||
</g> | |||
</g> | |||
</svg> |