猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
8.3 KiB

3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <!-- <div>宠物信息页 </div> -->
  3. <view class="box">
  4. <view class="top box-size">
  5. <view class="form-title">
  6. 宠物头像
  7. </view>
  8. <view class="img">
  9. <image :src="petInfo.photo" mode="" style="width: 157rpx;height: 157rpx;"
  10. :style="{borderRadius:'100rpx'}"></image>
  11. <!-- <view >
  12. 点击更换头像
  13. <view class="top_item">
  14. <image src="/static/images/tabBar/Group 1000001460@2x.png" mode=""
  15. style="width: 55rpx;height: 55rpx;" :style="{borderRadius:'50rpx'}"></image>
  16. </view>
  17. </view> -->
  18. </view>
  19. </view>
  20. <view class="information">
  21. <view class="form-title">
  22. 宠物基本信息
  23. </view>
  24. <view class="information_item box-size margin_top_3%">
  25. <view class="level name box-size pad_4">
  26. 昵称
  27. <!-- <input type="text" placeholder="请输入宠物名字" /> -->
  28. <view class="item_">
  29. {{ petInfo.name }}
  30. </view>
  31. </view>
  32. <view class="line1">
  33. </view>
  34. <view class="level name box-size pad_4">
  35. 性别
  36. <!-- <view>
  37. <up-picker :show="show" :columns="columns"></up-picker>
  38. <up-button @click="show = true">请选择</up-button>
  39. </view> -->
  40. <view class="item_">
  41. <!-- {{ petInfo.sex == 0 ? '男' : '女' }} -->
  42. {{ petInfo.gender }}
  43. </view>
  44. </view>
  45. <view class="line1">
  46. </view>
  47. <view class="level name box-size pad_4">
  48. 品种
  49. <view class="item_">
  50. <!-- {{ petInfo.type }} -->
  51. {{ petInfo.breed }}
  52. </view>
  53. </view>
  54. <view class="line1">
  55. </view>
  56. <view class="level name box-size pad_4">
  57. 出生年月
  58. <view class="item_">
  59. {{ petInfo.birthDate || '未知' }}
  60. </view>
  61. </view>
  62. <view class="line1">
  63. </view>
  64. <view class="level name box-size pad_4">
  65. 体重
  66. <view class="item_">
  67. <!-- {{ petInfo.weight }} -->
  68. {{ petInfo.bodyType || '未知' }}
  69. </view>
  70. </view>
  71. <view class="line1">
  72. </view>
  73. <view class="level name box-size pad_4">
  74. 性格
  75. <view class="item_">
  76. <!-- {{ petInfo.personality }} -->
  77. {{ petInfo.personality && petInfo.personality.join ? petInfo.personality.join(',') : petInfo.personality }}
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="information">
  83. <view class="form-title">
  84. 宠物健康情况
  85. </view>
  86. <view class="information_item box-size margin_top_3% item">
  87. <view class="level name box-size pad_4">
  88. 疫苗
  89. <!-- <input type="text" placeholder="请输入宠物名字" /> -->
  90. <view class="item_">
  91. <!-- 有免疫史 -->
  92. <!-- {{ vaccineText }} -->
  93. {{ petInfo.vaccineStatus || '未知' }}
  94. </view>
  95. </view>
  96. <view class="line1">
  97. </view>
  98. <view class="level name box-size pad_4">
  99. 驱虫
  100. <!-- <view>
  101. <up-picker :show="show" :columns="columns"></up-picker>
  102. <up-button @click="show = true">请选择</up-button>
  103. </view> -->
  104. <view class="item_">
  105. <!-- {{ dewormText }} -->
  106. <!-- 未驱虫 -->
  107. {{ petInfo.dewormingStatus || '未知' }}
  108. </view>
  109. </view>
  110. <view class="line1">
  111. </view>
  112. <view class="level name box-size pad_4">
  113. 绝育
  114. <view class="item_">
  115. <!-- {{ neuteredText }} -->
  116. <!-- 已绝育 -->
  117. {{ petInfo.sterilization || '未知' }}
  118. </view>
  119. </view>
  120. <view class="line1">
  121. </view>
  122. <view class="level name box-size pad_4">
  123. 健康
  124. </view>
  125. </view>
  126. </view>
  127. <!-- <view class="container box-size">
  128. <view class="container_item level">
  129. <view class="icon" :style="{borderRadius:'30rpx'}">
  130. <up-icon name="checkbox-mark" color="#FFFFFF" size="40"></up-icon>
  131. </view>
  132. 身体健康无异常
  133. </view>
  134. <view class="container_item level">
  135. <view class="icon_" :style="{borderRadius:'30rpx'}">
  136. <up-icon name="checkbox-mark" color="#FFFFFF" size="40"></up-icon>
  137. </view>
  138. 近三个月有做过手术
  139. </view>
  140. <view class="bottom box-size" :style="{borderRadius:'8rpx'}">
  141. 右腿骨折右眼有轻微白内障
  142. </view>
  143. </view> -->
  144. <view class="container box-size">
  145. <view class="container_item level" v-for="(value, index) in healthData"
  146. :key="index">
  147. <view class="icon" :style="{borderRadius:'30rpx'}" v-if="petInfo.healthStatus.includes(value)">
  148. <up-icon name="checkbox-mark" color="#FFFFFF" size="40"></up-icon>
  149. </view>
  150. <view class="icon_" :style="{borderRadius:'30rpx'}" v-else>
  151. <up-icon name="checkbox-mark" color="#FFFFFF" size="40"></up-icon>
  152. </view>
  153. {{ value }}
  154. </view>
  155. <view class="bottom box-size" :style="{borderRadius:'8rpx'}"
  156. v-if="petInfo.remark">
  157. {{ petInfo.remark }}
  158. </view>
  159. </view>
  160. </view>
  161. </template>
  162. <script setup>
  163. import {
  164. ref,
  165. reactive,
  166. computed,
  167. } from "vue"
  168. import {
  169. onLoad,
  170. onShow
  171. } from '@dcloudio/uni-app'
  172. import {
  173. getPetById
  174. } from "@/api/order/order.js"
  175. import { getDictList } from "@/api/system/user"
  176. onLoad((options) => {
  177. petId.value = options.id || null;
  178. getPetDetail()
  179. });
  180. // const
  181. const healthData = ref([])
  182. const vaccineText = computed(() => {
  183. const vaccineMap = {
  184. 0: '每年都免疫',
  185. 1: '有免疫史',
  186. 2: '未免疫'
  187. };
  188. return vaccineMap[petInfo.value.vaccine] || ''
  189. });
  190. const dewormText = computed(() => {
  191. const dewormMap = {
  192. 0: '未驱虫',
  193. 1: '定期驱虫',
  194. 2: '有驱虫史'
  195. };
  196. return dewormMap[petInfo.value.deworm] || ''
  197. });
  198. const neuteredText = computed(() => {
  199. const neuteredMap = {
  200. 0: '已绝育',
  201. 1: '未绝育'
  202. };
  203. return neuteredMap[petInfo.value.neutered] || ''
  204. });
  205. const petCartText = computed(() => {
  206. const petCartMap = {
  207. 0: '是',
  208. 1: '否'
  209. };
  210. return petCartMap[petInfo.value.petCard] || ''
  211. });
  212. const petId = ref(null);
  213. const petInfo = ref({})
  214. const getPetDetail = async () => {
  215. if (!petId.value) return;
  216. let response = await getPetById(petId.value)
  217. if (response.code == 200 && response.data) {
  218. petInfo.value = response.data;
  219. }
  220. }
  221. function getDictListInfo(){
  222. getDictList('pet_health_status').then(res=>{
  223. if (res.code == 200) {
  224. healthData.value = res.data.map(e=>e.dictLabel)
  225. }
  226. })
  227. }
  228. getDictListInfo()
  229. </script>
  230. <style lang="scss">
  231. .box {
  232. width: 100vw;
  233. height: 100vh;
  234. .top {
  235. width: 100vw;
  236. height: 300rpx;
  237. background-color: #FFFFFF;
  238. padding: 0 1%;
  239. .img {
  240. width: 165rpx;
  241. height: 165rpx;
  242. // background-color: pink;
  243. color: #7D8196;
  244. font-size: 28rpx;
  245. margin: 1% 39%;
  246. display: grid;
  247. jplace-items: center;
  248. // position: relative;
  249. // .top_item {
  250. // position: absolute;
  251. // top: 100rpx;
  252. // left: 100rpx;
  253. // }
  254. }
  255. }
  256. .item {
  257. height: 360rpx !important;
  258. }
  259. .information {
  260. width: 100vw;
  261. height: auto;
  262. background-color: #FFFFFF;
  263. margin-top: 17rpx;
  264. padding: 0 1%;
  265. .information_item {
  266. width: 100vw;
  267. height: 550rpx;
  268. font-size: 30rpx;
  269. display: grid;
  270. justify-content: space-around;
  271. .item_ {
  272. width: auto;
  273. height: 40rpx;
  274. }
  275. .name {
  276. width: 100vw;
  277. height: 40rpx;
  278. justify-content: space-between;
  279. // .name input {
  280. // width: 50rpx;
  281. // background-color: #FFFFFF;
  282. // }
  283. }
  284. // .sex {
  285. // width: 200rpx;
  286. // height: 40rpx;
  287. // background-color: #7D8196;
  288. // }
  289. .line1 {
  290. position: relative;
  291. margin-bottom: 30rpx;
  292. &::before {
  293. position: absolute;
  294. top: 5rpx;
  295. left: 17rpx;
  296. content: "";
  297. width: 706rpx;
  298. height: 0.5rpx;
  299. background-color: #EFEFEF;
  300. // background-color: red;
  301. }
  302. }
  303. }
  304. }
  305. .container {
  306. width: 100vw;
  307. height: 500rpx;
  308. background-color: #FFF4E4;
  309. padding: 3% 3% 5% 5%;
  310. font-size: 30rpx;
  311. .container_item {
  312. width: auto;
  313. height: 40rpx;
  314. margin-bottom: 20rpx;
  315. .icon {
  316. width: 40rpx;
  317. height: 40rpx;
  318. background-color: #FFBF60;
  319. margin-right: 15rpx;
  320. }
  321. .icon_ {
  322. width: 38rpx;
  323. height: 38rpx;
  324. border: 1rpx solid gray;
  325. background-color: #FFF;
  326. margin-right: 15rpx;
  327. }
  328. }
  329. .bottom {
  330. width: 680rpx;
  331. height: 80rpx;
  332. background-color: #FFFFFF;
  333. padding-left: 2%;
  334. border: 1rpx solid #FFBF60;
  335. line-height: 80rpx;
  336. }
  337. }
  338. }
  339. .box-size {
  340. box-sizing: border-box;
  341. }
  342. .level {
  343. display: flex;
  344. }
  345. .pad_4 {
  346. padding: 0 4%;
  347. }
  348. .margin_top_3 {
  349. margin-top: 3%;
  350. }
  351. </style>