Address.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view>
  3. <template v-for="(item, index) in addInfoArr" :key="index">
  4. <add-component ref="addComponentRef"></add-component>
  5. </template>
  6. <view class="Wrapper-Btn">
  7. <up-button
  8. @click="handleQux"
  9. type="error"
  10. :plain="true"
  11. :hairline="true"
  12. text="取消"
  13. :customStyle="hadlClickEdit"
  14. ></up-button>
  15. <up-button
  16. type="error"
  17. text="确定"
  18. @click="handlOk"
  19. :customStyle="hadlClickEdit"
  20. ></up-button>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, reactive } from 'vue'
  26. import { useraDdressData } from '@/api/userSettings.js'
  27. import pickerAddress from '@/pages_home/components/pickerAddress/pickerAddress.vue' // 地区选择器组件
  28. import addComponent from '@/pages_home/components/setupUserCopy/Add.vue'
  29. const addComponentRef = ref(null)
  30. const addInfoArr = ref([{}])
  31. function handleAdd() {
  32. if (addInfoArr.value.length < 4) addInfoArr.value.push({})
  33. }
  34. const handlOk = async () => {
  35. const params = []
  36. addInfoArr.value.forEach((item, index) => {
  37. params.push(addComponentRef.value[index].modelForm)
  38. })
  39. params.forEach(async (obj) => {
  40. const res = await useraDdressData(obj)
  41. if (res.code == 200) {
  42. uni.showToast({
  43. title: '新增成功',
  44. icon: 'success', // 或者 'none'
  45. duration: 1500, // 显示时间,单位毫秒,默认1500
  46. mask: true, // 是否显示透明蒙层,防止触摸穿透,默认false
  47. })
  48. // setTimeout(() => {
  49. // uni.navigateTo({
  50. // url: `/pages_home/components/volunteerSide/adresss`
  51. // })
  52. // }, 1500)
  53. }
  54. })
  55. setTimeout(() => {
  56. uni.navigateBack({
  57. delta: 1
  58. })
  59. })
  60. }
  61. const handleQux = () => {
  62. uni.navigateBack({
  63. delta: 2,
  64. })
  65. }
  66. const hadlClickEdit = {
  67. width: '240rpx',
  68. marginTop: '30rpx',
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .address-inp {
  73. color: #929292;
  74. }
  75. .Wrapper-Btn {
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. }
  80. </style>