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

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