猫妈狗爸伴宠师小程序前端代码
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.

234 lines
5.3 KiB

3 months ago
3 months ago
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
  1. <template>
  2. <view class="personal-pet">
  3. <view v-if="petLists.length > 0" class="personal-pet-list">
  4. <view v-for="(item, index) in petLists" :key="index">
  5. <view
  6. :class="['personal-pet-list-item', item.gender === '男生' ? '.personal-pet-list-item_backgroud_m' : '.personal-pet-list-item_backgroud_f']">
  7. <view class="personal-pet-info">
  8. <view>
  9. <u-avatar :src="item.photo? item.photo : defaultPhoto" size="60" shape="circle"></u-avatar>
  10. </view>
  11. <view class="personal-pet-info-1">
  12. <view class="personal-pet-info-2">
  13. <view class="personal-pet-name">
  14. {{ item.name }}
  15. </view>
  16. <view class="personal-pet-sex">
  17. <img :src="item.gender === '男生' ? '../../../static/images/sex/boy.svg' : '../../../static/images/sex/girl.svg'"
  18. alt="sex" style="width: 16px;height: 16px;" />
  19. </view>
  20. </view>
  21. <view class="personal-pet-info-3" style="width: 100%;">
  22. <view style="max-width: 25%;">
  23. {{ item.breed || '未知' }}
  24. </view>
  25. <view class="personal-pet-info-age" style="max-width: 90px;">
  26. {{ item.type || '未知' }}
  27. </view>
  28. <view>
  29. {{ item.bodyType }}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="personal-pet-info-disposition ellipsis">
  35. 性格 {{ item.personality }}
  36. </view>
  37. <view class="view-pets">
  38. <view @click="toDetail(item.id)" class="btn">
  39. 查看详细信息
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view v-else class="personal-pet-none">
  46. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png" alt="pet"
  47. style="width: 149px;height: 124px;" mode="widthFix" />
  48. <view class="personal-pet-none-text">这里还没有您的宠物,请点击添加吧~</view>
  49. </view>
  50. </view>
  51. </template>
  52. <script setup>
  53. import {
  54. ref,
  55. onMounted
  56. } from 'vue';
  57. // import {
  58. // getpetList
  59. // } from "@/api/pet/index.js";
  60. import {
  61. getOrderPetById
  62. } from "@/api/order/order.js";
  63. import {
  64. onShow,
  65. onPullDownRefresh,
  66. onLoad,
  67. } from "@dcloudio/uni-app"
  68. onLoad((options) => {
  69. orderId.value = options.id || null;
  70. getPetListData()
  71. });
  72. // 定义响应式数据
  73. const defaultPhoto = ref('https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png');
  74. const petLists = ref([]);
  75. const orderId = ref(0)
  76. // 获取宠物列表
  77. const getPetListData = async () => {
  78. petLists.value = [];
  79. try {
  80. const res = await getOrderPetById(orderId.value);
  81. if (res && res.data) {
  82. petLists.value = res.data;
  83. }
  84. } catch (error) {
  85. console.error('获取宠物列表失败', error);
  86. }
  87. };
  88. onPullDownRefresh(() => {
  89. getPetListData();
  90. });
  91. const toDetail = (id) => {
  92. uni.navigateTo({
  93. url: `/otherPages/orderTakingManage/pet/detail?id=${id}`
  94. })
  95. }
  96. </script>
  97. <style lang="scss">
  98. .personal-pet {
  99. position: relative;
  100. height: 100%;
  101. padding-bottom: 90px;
  102. .personal-pet-list {
  103. .personal-pet-list-add {
  104. width: 100%;
  105. height: 44px;
  106. background-color: #FFFFFF;
  107. display: flex;
  108. justify-content: space-between;
  109. align-items: center;
  110. padding: 0 15px;
  111. .personal-pet-list-add-btn {
  112. font-size: 14px;
  113. color: #AAA;
  114. display: flex;
  115. align-items: center;
  116. }
  117. }
  118. .personal-pet-list-item_backgroud_m {
  119. background: linear-gradient(179deg, #EDF5FE 0.75%, #FFF 34.11%);
  120. }
  121. .personal-pet-list-item_backgroud_f {
  122. background: linear-gradient(179deg, #FFF4F6 0.75%, #FFF 34.11%);
  123. }
  124. .personal-pet-list-item {
  125. margin: 10px 10px 0 10px;
  126. border-radius: 5px;
  127. padding: 20px 10px 10px;
  128. .personal-pet-info {
  129. display: flex;
  130. align-items: center;
  131. justify-content: flex-start;
  132. .personal-pet-info-1 {
  133. margin-left: 10px;
  134. .personal-pet-info-2 {
  135. display: flex;
  136. flex-wrap: wrap;
  137. .personal-pet-name {
  138. color: #333;
  139. font-size: 16px;
  140. margin-right: 10px;
  141. }
  142. }
  143. .personal-pet-info-3 {
  144. display: flex;
  145. align-items: baseline;
  146. font-size: 14px;
  147. margin-top: 5px;
  148. color: #7D8196;
  149. .personal-pet-info-age {
  150. padding: 0 10px;
  151. margin: 0 10px;
  152. border-left: solid 2px #7D8196;
  153. border-right: solid 2px #7D8196;
  154. }
  155. }
  156. }
  157. }
  158. .personal-pet-info-disposition {
  159. padding: 10px;
  160. color: #7D8196;
  161. font-size: 14px;
  162. background: #f9f9f9;
  163. border-radius: 5px;
  164. margin: 10px 0rpx;
  165. }
  166. .view-pets {
  167. display: flex;
  168. justify-content: flex-end;
  169. .btn {
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. width: 220rpx;
  174. height: 50rpx;
  175. border-radius: 25rpx;
  176. border: 2rpx solid #FFBF60;
  177. color: #FFBF60;
  178. font-size: 24rpx;
  179. }
  180. }
  181. .personal-pet-info-btns {
  182. display: flex;
  183. justify-content: flex-end;
  184. margin-top: 10px;
  185. .personal-pet-info-btn {
  186. display: flex;
  187. font-size: 14px;
  188. color: #7D8196;
  189. margin-left: 20px;
  190. }
  191. }
  192. }
  193. }
  194. .personal-pet-none {
  195. display: flex;
  196. justify-content: center;
  197. align-items: center;
  198. flex-wrap: wrap;
  199. margin-top: 40%;
  200. .personal-pet-none-text {
  201. color: #666;
  202. text-align: center;
  203. font-size: 14px;
  204. width: 100%;
  205. margin-top: 10px;
  206. }
  207. }
  208. }
  209. </style>