Address.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/pages/selectAddress/index`
  51. })
  52. }, 1500)
  53. }
  54. })
  55. }
  56. const handleQux = () => {
  57. uni.navigateBack({
  58. delta: 2,
  59. })
  60. }
  61. const hadlClickEdit = {
  62. width: '240rpx',
  63. marginTop: '30rpx',
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. .address-inp {
  68. color: #929292;
  69. }
  70. .Wrapper-Btn {
  71. display: flex;
  72. justify-content: center;
  73. align-items: center;
  74. }
  75. </style>