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

269 lines
6.1 KiB

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