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

267 lines
6.1 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
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.rangeNo">
  19. {{ `接单范围:${item.rangeNo}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.appletOutDate">
  34. {{ `${item.appletOutDate?.length}天:` }}
  35. </text>
  36. <text class="text-ellipsis" style="flex: 1;">
  37. {{ getDisabledDateDesc(item.appletOutDate) }}
  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 userInfo = computed(() => {
  109. return store.getters.userInfo;
  110. })
  111. const list = ref([])
  112. const modal = ref(null)
  113. const deleteId = ref(null);
  114. const fetchAddressList = async () => {
  115. try {
  116. let response = await getAddressList({
  117. userId : userInfo.value.userId
  118. });
  119. list.value = response.data || []
  120. } catch (err) {
  121. }
  122. }
  123. function switchAddress(item){
  124. item.status = item.status == 'true' ? 'false' : 'true'
  125. onSave(item)
  126. }
  127. const onSave = async (item) => {
  128. let code = null;
  129. let result = await udpateAddress({
  130. ...item
  131. })
  132. code = result.code
  133. }
  134. const getDisabledDateDesc = (dateArr) => {
  135. if (!dateArr?.length) {
  136. return '暂无不可接单日期'
  137. }
  138. return dateArr.map(date => dayjs(date.date).format('MM-DD')).join('、')
  139. }
  140. const toAdd = (item) => {
  141. console.log("item")
  142. console.log(item)
  143. if (item) {
  144. console.log("item")
  145. console.log(item)
  146. if(item !== undefined){
  147. uni.navigateTo({
  148. url: `/otherPages/authentication/connectAddress/detail?addressId=${item.id}`
  149. })
  150. }else{
  151. uni.navigateTo({
  152. url: '/otherPages/authentication/connectAddress/detail'
  153. })
  154. }
  155. } else {
  156. uni.navigateTo({
  157. url: '/otherPages/authentication/connectAddress/detail'
  158. })
  159. }
  160. }
  161. const fetchDeleteAddress = async () => {
  162. let response = await deleteAddress({
  163. id: deleteId.value
  164. });
  165. if (response.code == 200) {
  166. uni.showToast({
  167. title: '删除成功!',
  168. icon: "none"
  169. })
  170. fetchAddressList()
  171. }
  172. }
  173. onShow(() => {
  174. fetchAddressList()
  175. })
  176. const clickDelHandle = (delId) => {
  177. modal.value.open();
  178. deleteId.value = delId;
  179. }
  180. function settingDate(item){
  181. uni.navigateTo({
  182. url: '/otherPages/myOrdersManage/date/detail?addressId=' + item.id
  183. })
  184. }
  185. const cancelDel = () => {
  186. // 取消删除回调
  187. }
  188. const confirmDel = () => {
  189. fetchDeleteAddress();
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .page {
  194. .icon-empty {
  195. width: 259rpx;
  196. height: auto;
  197. margin-top: 240rpx;
  198. }
  199. .switchAddress-a{
  200. background-color: #FFBF6022;
  201. color: #FFBF60;
  202. padding: 10rpx 20rpx;
  203. border-radius: 14rpx;
  204. }
  205. .switchAddress-b{
  206. background-color: #33333312;
  207. color: #555;
  208. padding: 10rpx 20rpx;
  209. border-radius: 14rpx;
  210. }
  211. }
  212. .content {
  213. background-color: #F3F3F3;
  214. border-radius: 20rpx;
  215. padding: 24rpx;
  216. }
  217. .li {
  218. margin: 16rpx 24rpx 0 24rpx;
  219. border-radius: 20rpx;
  220. padding: 24rpx;
  221. }
  222. .tips {
  223. padding: 10rpx 32rpx;
  224. background-color: rgb(255, 250, 242);
  225. image {
  226. width: 32rpx;
  227. height: 32rpx;
  228. }
  229. }
  230. .text-ellipsis {
  231. overflow: hidden; //超出的文本隐藏
  232. text-overflow: ellipsis; //溢出用省略号显示
  233. white-space: nowrap; //溢出不换行
  234. }
  235. .tip {
  236. text-align: center;
  237. padding: 25rpx 0rpx;
  238. }
  239. </style>