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

192 lines
4.3 KiB

3 months ago
3 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <view class="tips flex-rowl">
  4. <image src="@/static/images/ydd/icon2.png" mode=""></image>
  5. <text class="color-ffb size-22 ml16">普通喂养员可设置3个接单地址优选喂养员可设置5个接单地址</text>
  6. </view>
  7. <view v-if="list.length">
  8. <view class="li bg-fff" v-for="(item, index) in list" :key="`address-${index}`">
  9. <view class="size-30">
  10. {{ item.area }}
  11. </view>
  12. <view class="size-22 color-777 mt16">
  13. {{ `接单范围:${item.distance}km` }}
  14. </view>
  15. <view class="content mt16">
  16. <view class="flex-between">
  17. <text class="size-22 color-999">不接单日期</text>
  18. <view class="flex-rowr">
  19. <text class="size-22 color-ccc">修改</text>
  20. <image src="@/static/images/ydd/right.png" mode="widthFix" style="width: 20rpx;"></image>
  21. </view>
  22. </view>
  23. <view class="color-999 size-22 mt16 flex-rowl">
  24. <text>
  25. {{ `${item.disabledDate?.length}天:` }}
  26. </text>
  27. <text class="text-ellipsis" style="flex: 1;">
  28. {{ getDisabledDateDesc(item.disabledDate) }}
  29. </text>
  30. </view>
  31. </view>
  32. <view class="flex-between mt16">
  33. <view class="flex-rowl">
  34. <view class="color-ffb size-22">
  35. 接单中
  36. </view>
  37. <switch :checked="item.status" color="#FFBF60" style="transform: scale(0.6);" />
  38. </view>
  39. <view class="flex-rowr">
  40. <view @click="toAdd(item)" class="flex-rowl">
  41. <image src="@/static/images/ydd/edit.png" mode="widthFix" style="width: 20rpx;"></image>
  42. <text class="size-22 color-777 ml10">编辑</text>
  43. </view>
  44. <view @click="clickDelHandle(item.id)" class="flex-rowl" style="margin-left: 50rpx;">
  45. <image src="@/static/images/ydd/cancel.png" mode="widthFix" style="width: 20rpx;"></image>
  46. <text class="size-22 color-777 ml10">删除</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-else class="flex-rowc">
  53. <image class="icon-empty" src="../static/connectAddress/icon-empty.png" mode="widthFix"></image>
  54. </view>
  55. <view class="footer-btn">
  56. <view class="btn" @click="toAdd()">
  57. 新增接单地址
  58. </view>
  59. </view>
  60. </view>
  61. <Modal @confirm="confirmDel" @cancel="cancel" ref="modal">
  62. <template>
  63. <view class="tip">
  64. 确认要删除此地址?
  65. </view>
  66. </template>
  67. </Modal>
  68. </template>
  69. <script setup>
  70. import {
  71. ref
  72. } from 'vue'
  73. import {
  74. onShow
  75. } from '@dcloudio/uni-app'
  76. import dayjs from 'dayjs'
  77. import {
  78. getAddressList,
  79. deleteAddress
  80. } from "@/api/address/address.js"
  81. import Modal from "@/components/Modal/index.vue"
  82. const list = ref([])
  83. const modal = ref(null)
  84. const deleteId = ref(null);
  85. const fetchAddressList = async () => {
  86. try {
  87. let response = await getAddressList();
  88. list.value = response.data || []
  89. } catch (err) {
  90. }
  91. }
  92. const getDisabledDateDesc = (dateArr) => {
  93. if (!dateArr?.length) {
  94. return '暂无不可接单日期'
  95. }
  96. return dateArr.map(date => dayjs(date).format('MM-DD')).join('、')
  97. }
  98. const toAdd = (item) => {
  99. if (item) {
  100. uni.navigateTo({
  101. url: `/otherPages/authentication/connectAddress/detail?item=${JSON.stringify(item)}`
  102. })
  103. } else {
  104. uni.navigateTo({
  105. url: '/otherPages/authentication/connectAddress/detail'
  106. })
  107. }
  108. }
  109. const fetchDeleteAddress = async () => {
  110. let response = await deleteAddress({
  111. id: deleteId.value
  112. });
  113. if (response.code == 200) {
  114. uni.showToast({
  115. title: '删除成功!',
  116. icon: "none"
  117. })
  118. fetchAddressList()
  119. }
  120. }
  121. onShow(() => {
  122. fetchAddressList()
  123. })
  124. const clickDelHandle = (delId) => {
  125. modal.value.open();
  126. deleteId.value = delId;
  127. }
  128. const cancelDel = () => {
  129. // 取消删除回调
  130. }
  131. const confirmDel = () => {
  132. fetchDeleteAddress();
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .page {
  137. .icon-empty {
  138. width: 259rpx;
  139. height: auto;
  140. margin-top: 240rpx;
  141. }
  142. }
  143. .content {
  144. background-color: #F3F3F3;
  145. border-radius: 20rpx;
  146. padding: 24rpx;
  147. }
  148. .li {
  149. margin: 16rpx 24rpx 0 24rpx;
  150. border-radius: 20rpx;
  151. padding: 24rpx;
  152. }
  153. .tips {
  154. padding: 10rpx 32rpx;
  155. background-color: rgb(255, 250, 242);
  156. image {
  157. width: 32rpx;
  158. height: 32rpx;
  159. }
  160. }
  161. .text-ellipsis {
  162. overflow: hidden; //超出的文本隐藏
  163. text-overflow: ellipsis; //溢出用省略号显示
  164. white-space: nowrap; //溢出不换行
  165. }
  166. .tip {
  167. text-align: center;
  168. padding: 25rpx 0rpx;
  169. }
  170. </style>