Address.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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>
  7. <up-button type="error" text="确定" @click="handlOk" style="Button-btn"></up-button>
  8. </view>
  9. </view>
  10. </template>
  11. <script setup>
  12. import {
  13. ref,
  14. reactive
  15. } from 'vue';
  16. import {
  17. useraDdressData
  18. } from "@/api/userSettings.js"
  19. import pickerAddress from '@/components/pickerAddress/pickerAddress.vue' // 地区选择器组件
  20. import addComponent from '@/pages_mine/components/setupUser/Add.vue'
  21. const addComponentRef = ref(null)
  22. const addInfoArr = ref([
  23. {}
  24. ])
  25. function handleAdd() {
  26. if(addInfoArr.value.length < 4 ) addInfoArr.value.push({})
  27. }
  28. const handlOk = async () => {
  29. const params = []
  30. addInfoArr.value.forEach((item, index) => {
  31. params.push(addComponentRef.value[index].modelForm)
  32. })
  33. params.forEach(async (obj) => {
  34. const res = await useraDdressData(obj)
  35. if(res.code == 200){
  36. wx.showToast({
  37. title: '新增成功',
  38. icon: 'success', // 或者 'none'
  39. duration: 1500, // 显示时间,单位毫秒,默认1500
  40. mask: true, // 是否显示透明蒙层,防止触摸穿透,默认false
  41. });
  42. }
  43. })
  44. }
  45. </script>
  46. <style scoped lang="scss">
  47. .address-inp {
  48. color: #929292;
  49. }
  50. .Button-btn{
  51. width: 40rpx;
  52. height: 40rpx;
  53. }
  54. </style>