index.vue 9.0 KB

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