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

179 lines
4.1 KiB

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="petList.length>0" class="personal-service-list">
  4. <view v-for="(item,index) in petList" :key="index">
  5. <view class="personal-service-list-item" @click="goServiceInfo(item)">
  6. <view style="display: flex;align-items: center;">
  7. <u-avatar :src="item.photo?item.photo:defaultPhoto" size="46" shape="circle"></u-avatar>
  8. <view class="personal-service-tips ellipsis">
  9. {{serviceTips(item)}}
  10. </view>
  11. </view>
  12. <view>
  13. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- <view v-else class="personal-pet-none">
  19. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png" alt="pet"
  20. style="width: 149px;height: 124px;" mode="widthFix"/>
  21. <view class="personal-pet-none-text">这里还没有您的宠物,请点击添加吧~</view>
  22. </view>
  23. <view class="personal-pet-add" v-if="petList.length==0">
  24. <button class="personal-pet-add-btn" @click="addPet">添加宠物</button>
  25. </view>
  26. <view class="">
  27. <u-picker
  28. :showToolbar='false'
  29. :show="show"
  30. :columns="petTypes"
  31. @change="petTypeChange"
  32. @cancel="cancel"
  33. @confirm="confirm"
  34. ></u-picker>
  35. </view> -->
  36. </view>
  37. </template>
  38. <script>
  39. import { getpetList } from "@/api/pet/index.js"
  40. import { getDictList } from "@/api/system/user.js"
  41. import {
  42. getOrderPetById
  43. } from "@/api/order/order.js";
  44. export default{
  45. data(){
  46. return{
  47. petList:[],
  48. show:false,
  49. petTypes:[],
  50. petType:'',
  51. orderId : 0,
  52. }
  53. },
  54. onLoad(options) {
  55. this.orderId = options.id
  56. this.getPetList()
  57. },
  58. methods:{
  59. getPetList(){
  60. getOrderPetById(this.orderId).then(res=>{
  61. this.petList=res.data
  62. })
  63. },
  64. getPetTypeList(){
  65. getDictList('pet_type').then(res=>{
  66. if (res.code == 200) {
  67. let petType = res.data.map(e=>e.dictLabel)
  68. this.petTypes=[petType]
  69. console.log(this.petTypes)
  70. } else {
  71. this.$modal.showToast('获取pet type失败')
  72. }
  73. })
  74. },
  75. addPet(){
  76. this.show = true;
  77. },
  78. cancel() {
  79. this.show = false
  80. },
  81. petTypeChange(e){
  82. console.log(e)
  83. this.petType=e.value[0]
  84. },
  85. confirm(e) {
  86. this.show = false
  87. if(this.petType==='猫猫'){
  88. uni.navigateTo({
  89. url: `/pages/personalCenter/petInfo?petType=cat&optionType=add`
  90. });
  91. }
  92. if(this.petType==='狗狗'){
  93. uni.navigateTo({
  94. url: `/pages/personalCenter/petInfo?petType=dog&optionType=add`
  95. });
  96. }
  97. if(!this.petType){
  98. if(e.value[0]==='猫猫'){
  99. uni.navigateTo({
  100. url: `/pages/personalCenter/petInfo?petType=cat&optionType=add`
  101. });
  102. }
  103. if(e.value[0]==='狗狗'){
  104. uni.navigateTo({
  105. url: `/pages/personalCenter/petInfo?petType=dog&optionType=add`
  106. });
  107. }
  108. }
  109. },
  110. serviceTips(item){
  111. return `查看${item.petType=='dog'?"狗狗":"猫猫"}"${item.name}"的服务信息`
  112. },
  113. goServiceInfo(item){
  114. uni.navigateTo({
  115. url: `/otherPages/myOrdersManage/service/detail?petType=${item.petType}&petId=${item.id}`
  116. });
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .personal-pet{
  123. position: relative;
  124. height: 100%;
  125. padding-bottom: 58px;
  126. .personal-pet-add{
  127. background-color: #FFFFFF;
  128. padding: 10px 20px 40px;
  129. width: 100%;
  130. height: 90px;
  131. position: fixed;
  132. bottom: 0;
  133. z-index: 100;
  134. display: flex;
  135. .personal-pet-add-btn{
  136. width: 100%;
  137. border-radius: 6px;
  138. background: #FFB13F;
  139. font-size: 16px;
  140. color: #FFFFFF;
  141. }
  142. }
  143. .personal-service-list{
  144. .personal-service-list-item{
  145. background-color: #fff;
  146. margin: 10px 10px 0 10px;
  147. border-radius: 5px;
  148. padding: 10px;
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-between;
  152. .personal-service-tips{
  153. margin-left: 10px;
  154. color:#333;
  155. font-size: 14px;
  156. }
  157. }
  158. }
  159. .personal-pet-none{
  160. display:flex;
  161. justify-content: center;
  162. align-items: center;
  163. flex-wrap: wrap;
  164. margin-top: 40%;
  165. .personal-pet-none-text{
  166. color: #666;
  167. text-align: center;
  168. font-size: 14px;
  169. width: 100%;
  170. margin-top: 10px;
  171. }
  172. }
  173. }
  174. </style>