| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <template>
- <view class="pet-detail-page">
- <nav-bar title="宠物档案详情" bgColor="#ffecd2" color="#333"></nav-bar>
-
- <view class="pet-hero">
- <view class="hero-bg"></view>
- <view class="hero-content">
- <image :src="petInfo.avatarUrl || petInfo.avatar || defaultAvatar" class="hero-avatar" mode="aspectFill"></image>
- <view class="hero-main">
- <text class="pet-name">{{ petInfo.name || '加载中...' }}</text>
- <view class="tag-list">
- <text class="gender-icon" :class="petInfo.gender === 1 ? 'male' : 'female'">{{ petInfo.gender === 1 ? '♂' : '♀' }}</text>
- <text class="size-tag">{{ sizeLabel }}</text>
- </view>
- </view>
- <text class="pet-summary">{{ petInfo.breed }} · {{ petInfo.age || 0 }}岁 · {{ petInfo.weight || 0 }}kg</text>
- </view>
- </view>
- <view class="detail-container">
- <!-- 基础信息 -->
- <view class="section-card">
- <view class="section-header">
- <view class="title-line"></view>
- <text class="section-title">基础信息</text>
- </view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">所属主人</text>
- <text class="value">{{ petInfo.ownerName || petInfo.userName || petInfo.customerName || '-' }}</text>
- </view>
- <view class="info-item">
- <text class="label">主人电话</text>
- <text class="value">{{ petInfo.ownerPhone || petInfo.phonenumber || '-' }}</text>
- </view>
- <view class="info-item col-2">
- <text class="label">性格关键词</text>
- <text class="value">{{ petInfo.personality || '无' }}</text>
- </view>
- <view class="info-item col-2">
- <text class="label">萌宠性格</text>
- <text class="value block">{{ petInfo.cutePersonality || '暂无详细描述' }}</text>
- </view>
- </view>
- </view>
- <!-- 家庭信息 -->
- <view class="section-card">
- <view class="section-header">
- <view class="title-line"></view>
- <text class="section-title">家庭信息</text>
- </view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">房屋类型</text>
- <text class="value">{{ houseTypeLabel }}</text>
- </view>
- <view class="info-item">
- <text class="label">入门方式</text>
- <text class="value">{{ entryMethodLabel }}</text>
- </view>
- <view class="info-item col-2" v-if="petInfo.entryMethod === 'password'">
- <text class="label">门锁密码</text>
- <text class="value highlight">{{ petInfo.entryPassword || '-' }}</text>
- </view>
- <view class="info-item col-2" v-if="petInfo.entryMethod === 'key'">
- <text class="label">钥匙存放处</text>
- <text class="value">{{ petInfo.keyLocation || '-' }}</text>
- </view>
- </view>
- </view>
- <!-- 健康状况 -->
- <view class="section-card">
- <view class="section-header">
- <view class="title-line"></view>
- <text class="section-title">健康状况</text>
- </view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">健康状态</text>
- <text class="value" :class="healthClass">{{ petInfo.healthStatus || '未知' }}</text>
- </view>
- <view class="info-item">
- <text class="label">疫苗情况</text>
- <text class="value">{{ petInfo.vaccineStatus || '未记录' }}</text>
- </view>
- <view class="info-item">
- <text class="label">攻击倾向</text>
- <text class="value" :class="petInfo.aggression ? 'red' : ''">{{ petInfo.aggression ? '是' : '否' }}</text>
- </view>
- <view class="info-item col-2">
- <text class="label">既往病史</text>
- <text class="value block">{{ petInfo.medicalHistory || '无' }}</text>
- </view>
- <view class="info-item col-2">
- <text class="label">过敏史</text>
- <text class="value block">{{ petInfo.allergies || '无' }}</text>
- </view>
- </view>
- </view>
- <!-- 备注信息 -->
- <view class="section-card" v-if="petInfo.remark">
- <view class="section-header">
- <view class="title-line"></view>
- <text class="section-title">补充备注</text>
- </view>
- <view class="remark-content">
- {{ petInfo.remark }}
- </view>
- </view>
- </view>
- <view class="footer-bar">
- <button class="edit-btn" @click="goToEdit">编辑档案</button>
- </view>
- </view>
- </template>
- <script setup>
- // @Author: Antigravity
- import { ref, computed } from 'vue'
- import { onLoad } from '@dcloudio/uni-app'
- import { getPet } from '@/api/archieves/pet'
- import navBar from '@/components/nav-bar/index.vue'
- import customerEnums from '@/json/customer.json'
- const defaultAvatar = 'https://images.unsplash.com/photo-1552053831-71594a27632d?q=80&w=600&auto=format&fit=crop'
- const petId = ref(null)
- const petInfo = ref({})
- const genderOptions = { 0: '未知', 1: '公', 2: '母' }
- const sizeOptions = { 'small': '小型', 'medium': '中型', 'large': '大型' }
- const { houseTypeOptions, entryMethodOptions } = customerEnums
- onLoad((options) => {
- if (options.id) {
- petId.value = options.id
- fetchDetail()
- }
- })
- const fetchDetail = async () => {
- try {
- uni.showLoading({ title: '加载中...' })
- const res = await getPet(petId.value)
- petInfo.value = res || {}
- uni.hideLoading()
- } catch (e) {
- uni.hideLoading()
- console.error('获取详情失败', e)
- }
- }
- const sizeLabel = computed(() => sizeOptions[petInfo.value.size] || '未知体型')
- const houseTypeLabel = computed(() => {
- const opt = houseTypeOptions.find(o => o.value === petInfo.value.houseType)
- return opt ? opt.label : '未记录'
- })
- const entryMethodLabel = computed(() => {
- const opt = entryMethodOptions.find(o => o.value === petInfo.value.entryMethod)
- return opt ? opt.label : '未记录'
- })
- const healthClass = computed(() => {
- const s = petInfo.value.healthStatus
- if (s === '健康') return 'green'
- if (s === '疾病') return 'red'
- return 'orange'
- })
- const goToEdit = () => {
- uni.navigateTo({
- url: `/pages/my/pet/edit/index?id=${petId.value}`
- })
- }
- </script>
- <style lang="scss" scoped>
- .pet-detail-page {
- min-height: 100vh;
- background: #f4f6f9;
- padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
- }
- .pet-hero {
- position: relative;
- height: 460rpx;
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- overflow: hidden;
- }
- .hero-bg {
- position: absolute;
- top: 0; left: 0; right: 0; bottom: 0;
- background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
- }
- .hero-avatar {
- width: 200rpx;
- height: 200rpx;
- border-radius: 50%;
- border: 6rpx solid #fff;
- box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.12);
- z-index: 5;
- flex-shrink: 0;
- }
- .hero-content {
- position: relative;
- z-index: 5;
- display: flex;
- flex-direction: column;
- align-items: center;
- margin-top: 20rpx;
- padding: 0 48rpx;
- }
- .hero-main {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 12rpx;
- gap: 16rpx;
- }
- .pet-name {
- font-size: 44rpx;
- font-weight: 800;
- color: #333;
- }
- .tag-list {
- display: flex;
- gap: 12rpx;
- }
- .size-tag {
- padding: 6rpx 20rpx;
- border-radius: 30rpx;
- font-size: 22rpx;
- background: rgba(255, 255, 255, 0.85);
- color: #555;
- }
- .gender-icon {
- font-size: 36rpx;
- margin-right: 8rpx;
- }
- .gender-icon.male { color: #409eff; }
- .gender-icon.female { color: #f56c6c; }
- .pet-summary {
- font-size: 26rpx;
- color: #777;
- text-align: center;
- }
- .detail-container {
- margin-top: -40rpx;
- position: relative;
- z-index: 10;
- padding: 0 24rpx;
- }
- .section-card {
- background: #fff;
- border-radius: 24rpx;
- padding: 32rpx;
- margin-bottom: 24rpx;
- box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.02);
- }
- .section-header {
- display: flex;
- align-items: center;
- margin-bottom: 32rpx;
- }
- .title-line {
- width: 8rpx;
- height: 32rpx;
- background: #ff9500;
- border-radius: 4rpx;
- margin-right: 16rpx;
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- }
- .info-grid {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 32rpx 24rpx;
- }
- .info-item {
- display: flex;
- flex-direction: column;
- gap: 8rpx;
- }
- .info-item.col-2 {
- grid-column: span 2;
- }
- .label {
- font-size: 24rpx;
- color: #999;
- }
- .value {
- font-size: 26rpx;
- color: #333;
- font-weight: 500;
- }
- .value.block {
- line-height: 1.6;
- color: #666;
- font-weight: normal;
- }
- .value.highlight {
- color: #ff9500;
- font-weight: bold;
- }
- .value.green { color: #4caf50; }
- .value.red { color: #f44336; }
- .value.orange { color: #ff9800; }
- .remark-content {
- font-size: 28rpx;
- color: #666;
- line-height: 1.6;
- }
- .footer-bar {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background: #fff;
- padding: 20rpx 32rpx calc(20rpx + env(safe-area-inset-bottom));
- box-shadow: 0 -4rpx 16rpx rgba(0,0,0,0.05);
- z-index: 100;
- }
- .edit-btn {
- width: 100%;
- height: 88rpx;
- background: linear-gradient(90deg, #ffd53f, #ff9500);
- color: #fff;
- border: none;
- border-radius: 44rpx;
- font-size: 32rpx;
- font-weight: bold;
- line-height: 88rpx;
- }
- </style>
|