index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view class="pet-detail-page">
  3. <nav-bar title="宠物档案详情" bgColor="#ffecd2" color="#333"></nav-bar>
  4. <view class="pet-hero">
  5. <view class="hero-bg"></view>
  6. <view class="hero-content">
  7. <image :src="petInfo.avatarUrl || petInfo.avatar || defaultAvatar" class="hero-avatar" mode="aspectFill"></image>
  8. <view class="hero-main">
  9. <text class="pet-name">{{ petInfo.name || '加载中...' }}</text>
  10. <view class="tag-list">
  11. <text class="gender-icon" :class="petInfo.gender === 1 ? 'male' : 'female'">{{ petInfo.gender === 1 ? '♂' : '♀' }}</text>
  12. <text class="size-tag">{{ sizeLabel }}</text>
  13. </view>
  14. </view>
  15. <text class="pet-summary">{{ petInfo.breed }} · {{ petInfo.age || 0 }}岁 · {{ petInfo.weight || 0 }}kg</text>
  16. </view>
  17. </view>
  18. <view class="detail-container">
  19. <!-- 基础信息 -->
  20. <view class="section-card">
  21. <view class="section-header">
  22. <view class="title-line"></view>
  23. <text class="section-title">基础信息</text>
  24. </view>
  25. <view class="info-grid">
  26. <view class="info-item">
  27. <text class="label">所属主人</text>
  28. <text class="value">{{ petInfo.ownerName || petInfo.userName || petInfo.customerName || '-' }}</text>
  29. </view>
  30. <view class="info-item">
  31. <text class="label">主人电话</text>
  32. <text class="value">{{ petInfo.ownerPhone || petInfo.phonenumber || '-' }}</text>
  33. </view>
  34. <view class="info-item col-2">
  35. <text class="label">性格关键词</text>
  36. <text class="value">{{ petInfo.personality || '无' }}</text>
  37. </view>
  38. <view class="info-item col-2">
  39. <text class="label">萌宠性格</text>
  40. <text class="value block">{{ petInfo.cutePersonality || '暂无详细描述' }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 家庭信息 -->
  45. <view class="section-card">
  46. <view class="section-header">
  47. <view class="title-line"></view>
  48. <text class="section-title">家庭信息</text>
  49. </view>
  50. <view class="info-grid">
  51. <view class="info-item">
  52. <text class="label">房屋类型</text>
  53. <text class="value">{{ houseTypeLabel }}</text>
  54. </view>
  55. <view class="info-item">
  56. <text class="label">入门方式</text>
  57. <text class="value">{{ entryMethodLabel }}</text>
  58. </view>
  59. <view class="info-item col-2" v-if="petInfo.entryMethod === 'password'">
  60. <text class="label">门锁密码</text>
  61. <text class="value highlight">{{ petInfo.entryPassword || '-' }}</text>
  62. </view>
  63. <view class="info-item col-2" v-if="petInfo.entryMethod === 'key'">
  64. <text class="label">钥匙存放处</text>
  65. <text class="value">{{ petInfo.keyLocation || '-' }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 健康状况 -->
  70. <view class="section-card">
  71. <view class="section-header">
  72. <view class="title-line"></view>
  73. <text class="section-title">健康状况</text>
  74. </view>
  75. <view class="info-grid">
  76. <view class="info-item">
  77. <text class="label">健康状态</text>
  78. <text class="value" :class="healthClass">{{ petInfo.healthStatus || '未知' }}</text>
  79. </view>
  80. <view class="info-item">
  81. <text class="label">疫苗情况</text>
  82. <text class="value">{{ petInfo.vaccineStatus || '未记录' }}</text>
  83. </view>
  84. <view class="info-item">
  85. <text class="label">攻击倾向</text>
  86. <text class="value" :class="petInfo.aggression ? 'red' : ''">{{ petInfo.aggression ? '是' : '否' }}</text>
  87. </view>
  88. <view class="info-item col-2">
  89. <text class="label">既往病史</text>
  90. <text class="value block">{{ petInfo.medicalHistory || '无' }}</text>
  91. </view>
  92. <view class="info-item col-2">
  93. <text class="label">过敏史</text>
  94. <text class="value block">{{ petInfo.allergies || '无' }}</text>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 备注信息 -->
  99. <view class="section-card" v-if="petInfo.remark">
  100. <view class="section-header">
  101. <view class="title-line"></view>
  102. <text class="section-title">补充备注</text>
  103. </view>
  104. <view class="remark-content">
  105. {{ petInfo.remark }}
  106. </view>
  107. </view>
  108. </view>
  109. <view class="footer-bar">
  110. <button class="edit-btn" @click="goToEdit">编辑档案</button>
  111. </view>
  112. </view>
  113. </template>
  114. <script setup>
  115. // @Author: Antigravity
  116. import { ref, computed } from 'vue'
  117. import { onLoad } from '@dcloudio/uni-app'
  118. import { getPet } from '@/api/archieves/pet'
  119. import navBar from '@/components/nav-bar/index.vue'
  120. import customerEnums from '@/json/customer.json'
  121. const defaultAvatar = 'https://images.unsplash.com/photo-1552053831-71594a27632d?q=80&w=600&auto=format&fit=crop'
  122. const petId = ref(null)
  123. const petInfo = ref({})
  124. const genderOptions = { 0: '未知', 1: '公', 2: '母' }
  125. const sizeOptions = { 'small': '小型', 'medium': '中型', 'large': '大型' }
  126. const { houseTypeOptions, entryMethodOptions } = customerEnums
  127. onLoad((options) => {
  128. if (options.id) {
  129. petId.value = options.id
  130. fetchDetail()
  131. }
  132. })
  133. const fetchDetail = async () => {
  134. try {
  135. uni.showLoading({ title: '加载中...' })
  136. const res = await getPet(petId.value)
  137. petInfo.value = res || {}
  138. uni.hideLoading()
  139. } catch (e) {
  140. uni.hideLoading()
  141. console.error('获取详情失败', e)
  142. }
  143. }
  144. const sizeLabel = computed(() => sizeOptions[petInfo.value.size] || '未知体型')
  145. const houseTypeLabel = computed(() => {
  146. const opt = houseTypeOptions.find(o => o.value === petInfo.value.houseType)
  147. return opt ? opt.label : '未记录'
  148. })
  149. const entryMethodLabel = computed(() => {
  150. const opt = entryMethodOptions.find(o => o.value === petInfo.value.entryMethod)
  151. return opt ? opt.label : '未记录'
  152. })
  153. const healthClass = computed(() => {
  154. const s = petInfo.value.healthStatus
  155. if (s === '健康') return 'green'
  156. if (s === '疾病') return 'red'
  157. return 'orange'
  158. })
  159. const goToEdit = () => {
  160. uni.navigateTo({
  161. url: `/pages/my/pet/edit/index?id=${petId.value}`
  162. })
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. .pet-detail-page {
  167. min-height: 100vh;
  168. background: #f4f6f9;
  169. padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
  170. }
  171. .pet-hero {
  172. position: relative;
  173. height: 460rpx;
  174. width: 100%;
  175. display: flex;
  176. flex-direction: column;
  177. align-items: center;
  178. justify-content: center;
  179. overflow: hidden;
  180. }
  181. .hero-bg {
  182. position: absolute;
  183. top: 0; left: 0; right: 0; bottom: 0;
  184. background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  185. }
  186. .hero-avatar {
  187. width: 200rpx;
  188. height: 200rpx;
  189. border-radius: 50%;
  190. border: 6rpx solid #fff;
  191. box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.12);
  192. z-index: 5;
  193. flex-shrink: 0;
  194. }
  195. .hero-content {
  196. position: relative;
  197. z-index: 5;
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. margin-top: 20rpx;
  202. padding: 0 48rpx;
  203. }
  204. .hero-main {
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. margin-bottom: 12rpx;
  209. gap: 16rpx;
  210. }
  211. .pet-name {
  212. font-size: 44rpx;
  213. font-weight: 800;
  214. color: #333;
  215. }
  216. .tag-list {
  217. display: flex;
  218. gap: 12rpx;
  219. }
  220. .size-tag {
  221. padding: 6rpx 20rpx;
  222. border-radius: 30rpx;
  223. font-size: 22rpx;
  224. background: rgba(255, 255, 255, 0.85);
  225. color: #555;
  226. }
  227. .gender-icon {
  228. font-size: 36rpx;
  229. margin-right: 8rpx;
  230. }
  231. .gender-icon.male { color: #409eff; }
  232. .gender-icon.female { color: #f56c6c; }
  233. .pet-summary {
  234. font-size: 26rpx;
  235. color: #777;
  236. text-align: center;
  237. }
  238. .detail-container {
  239. margin-top: -40rpx;
  240. position: relative;
  241. z-index: 10;
  242. padding: 0 24rpx;
  243. }
  244. .section-card {
  245. background: #fff;
  246. border-radius: 24rpx;
  247. padding: 32rpx;
  248. margin-bottom: 24rpx;
  249. box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.02);
  250. }
  251. .section-header {
  252. display: flex;
  253. align-items: center;
  254. margin-bottom: 32rpx;
  255. }
  256. .title-line {
  257. width: 8rpx;
  258. height: 32rpx;
  259. background: #ff9500;
  260. border-radius: 4rpx;
  261. margin-right: 16rpx;
  262. }
  263. .section-title {
  264. font-size: 32rpx;
  265. font-weight: bold;
  266. color: #333;
  267. }
  268. .info-grid {
  269. display: grid;
  270. grid-template-columns: 1fr 1fr;
  271. gap: 32rpx 24rpx;
  272. }
  273. .info-item {
  274. display: flex;
  275. flex-direction: column;
  276. gap: 8rpx;
  277. }
  278. .info-item.col-2 {
  279. grid-column: span 2;
  280. }
  281. .label {
  282. font-size: 24rpx;
  283. color: #999;
  284. }
  285. .value {
  286. font-size: 26rpx;
  287. color: #333;
  288. font-weight: 500;
  289. }
  290. .value.block {
  291. line-height: 1.6;
  292. color: #666;
  293. font-weight: normal;
  294. }
  295. .value.highlight {
  296. color: #ff9500;
  297. font-weight: bold;
  298. }
  299. .value.green { color: #4caf50; }
  300. .value.red { color: #f44336; }
  301. .value.orange { color: #ff9800; }
  302. .remark-content {
  303. font-size: 28rpx;
  304. color: #666;
  305. line-height: 1.6;
  306. }
  307. .footer-bar {
  308. position: fixed;
  309. bottom: 0;
  310. left: 0;
  311. right: 0;
  312. background: #fff;
  313. padding: 20rpx 32rpx calc(20rpx + env(safe-area-inset-bottom));
  314. box-shadow: 0 -4rpx 16rpx rgba(0,0,0,0.05);
  315. z-index: 100;
  316. }
  317. .edit-btn {
  318. width: 100%;
  319. height: 88rpx;
  320. background: linear-gradient(90deg, #ffd53f, #ff9500);
  321. color: #fff;
  322. border: none;
  323. border-radius: 44rpx;
  324. font-size: 32rpx;
  325. font-weight: bold;
  326. line-height: 88rpx;
  327. }
  328. </style>