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

251 lines
5.7 KiB

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